Re: [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux