[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <256e577b57eb21555de96846d1ac4cfa3b8ee238.camel@perches.com>
Date: Fri, 01 Oct 2021 06:31:21 -0700
From: Joe Perches <joe@...ches.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Cai Huoqing <caihuoqing@...du.com>, linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org, Vadim Pasternak <vadimp@...lanox.com>
Cc: Mike Marciniszyn <mike.marciniszyn@...nelisnetworks.com>,
Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>
Subject: Re: [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of
open coded variant
On Fri, 2021-10-01 at 15:31 +0300, Andy Shevchenko wrote:
> Use string_upper() from string helper module instead of open coded variant.
Perhaps these string_upper and string_lower utility functions
should return dst not void so these functions could be used in
output calls.
So instead of:
+ string_upper(prefix_name, prefix_name);
snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
this could be consolidated:
snprintf(name, sizeof(name), "%s-%s", string_upper(prefix_name), kind);
Perhaps:
---
include/linux/string_helpers.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 68189c4a2eb11..ef92a9471f2a9 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -81,18 +81,26 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
}
-static inline void string_upper(char *dst, const char *src)
+static inline char *string_upper(char *dst, const char *src)
{
+ char *rtn = dst;
+
do {
*dst++ = toupper(*src);
} while (*src++);
+
+ return rtn;
}
-static inline void string_lower(char *dst, const char *src)
+static inline char *string_lower(char *dst, const char *src)
{
+ char *rtn = dst;
+
do {
*dst++ = tolower(*src);
} while (*src++);
+
+ return rtn;
}
char *kstrdup_quotable(const char *src, gfp_t gfp);
Powered by blists - more mailing lists