Subject: Re: [PATCH] strstrip incorrectly marked __must_check
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Tue, 15 Dec 2009 02:01:15 +0000 (18:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Dec 2009 16:53:34 +0000 (08:53 -0800)
Recently, We marked strstrip() as must_check.  because it was frequently
misused and it should be checked.  However, we found one exception.
scsi/ipr.c intentionally ignore return value of strstrip.  Because it
wishes to keep the whitespace at the beginning.

Thus we need to keep with and without checked whitespace trim function.
This patch adds a new strim() and changes ipr.c to use it.

[akpm@linux-foundation.org: coding-style fixes]
Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/scsi/ipr.c
include/linux/string.h
lib/string.c

index 206c2fa8c1ba1ba51a53681975c7b1976ebacf5a..8643f5089361c220219c6404f17ee5e687354fb1 100644 (file)
@@ -1333,7 +1333,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
 
        error = &hostrcb->hcam.u.error.u.type_17_error;
        error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
-       strstrip(error->failure_reason);
+       strim(error->failure_reason);
 
        ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
                     be32_to_cpu(hostrcb->hcam.u.error.prc));
@@ -1359,7 +1359,7 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
 
        error = &hostrcb->hcam.u.error.u.type_07_error;
        error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
-       strstrip(error->failure_reason);
+       strim(error->failure_reason);
 
        ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
                     be32_to_cpu(hostrcb->hcam.u.error.prc));
index 168dad11ae03cff5861161f14a3714b7984f788d..651839a2a755ffa63aa862367fb502897df94e3c 100644 (file)
@@ -63,7 +63,14 @@ extern char * strnchr(const char *, size_t, int);
 extern char * strrchr(const char *,int);
 #endif
 extern char * __must_check skip_spaces(const char *);
-extern char * __must_check strstrip(char *);
+
+extern char *strim(char *);
+
+static inline __must_check char *strstrip(char *str)
+{
+       return strim(str);
+}
+
 #ifndef __HAVE_ARCH_STRSTR
 extern char * strstr(const char *,const char *);
 #endif
index 765566a6a0887b3054670b6b59090d4edb3430c3..afce96af3afdf7d6a0e1e343b4260c6f24765f74 100644 (file)
@@ -352,14 +352,14 @@ char *skip_spaces(const char *str)
 EXPORT_SYMBOL(skip_spaces);
 
 /**
- * strstrip - Removes leading and trailing whitespace from @s.
+ * strim - Removes leading and trailing whitespace from @s.
  * @s: The string to be stripped.
  *
  * Note that the first trailing whitespace is replaced with a %NUL-terminator
  * in the given string @s. Returns a pointer to the first non-whitespace
  * character in @s.
  */
-char *strstrip(char *s)
+char *strim(char *s)
 {
        size_t size;
        char *end;
@@ -376,7 +376,7 @@ char *strstrip(char *s)
 
        return s;
 }
-EXPORT_SYMBOL(strstrip);
+EXPORT_SYMBOL(strim);
 
 #ifndef __HAVE_ARCH_STRLEN
 /**