aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2009-12-14 21:01:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:34 -0500
commitca54cb8c9eb38095dc420b73c6380ce1dbeb10fa (patch)
tree35b5ba777b962e95039521d912d926a9372b2e8f
parent925ede0bf4ecef96fc2d939b16619530111aa16e (diff)
Subject: Re: [PATCH] strstrip incorrectly marked __must_check
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>
-rw-r--r--drivers/scsi/ipr.c4
-rw-r--r--include/linux/string.h9
-rw-r--r--lib/string.c6
3 files changed, 13 insertions, 6 deletions
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 206c2fa8c1ba..8643f5089361 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -1333,7 +1333,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1333 1333
1334 error = &hostrcb->hcam.u.error.u.type_17_error; 1334 error = &hostrcb->hcam.u.error.u.type_17_error;
1335 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0'; 1335 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1336 strstrip(error->failure_reason); 1336 strim(error->failure_reason);
1337 1337
1338 ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason, 1338 ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
1339 be32_to_cpu(hostrcb->hcam.u.error.prc)); 1339 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,
1359 1359
1360 error = &hostrcb->hcam.u.error.u.type_07_error; 1360 error = &hostrcb->hcam.u.error.u.type_07_error;
1361 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0'; 1361 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1362 strstrip(error->failure_reason); 1362 strim(error->failure_reason);
1363 1363
1364 ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason, 1364 ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
1365 be32_to_cpu(hostrcb->hcam.u.error.prc)); 1365 be32_to_cpu(hostrcb->hcam.u.error.prc));
diff --git a/include/linux/string.h b/include/linux/string.h
index 168dad11ae03..651839a2a755 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -63,7 +63,14 @@ extern char * strnchr(const char *, size_t, int);
63extern char * strrchr(const char *,int); 63extern char * strrchr(const char *,int);
64#endif 64#endif
65extern char * __must_check skip_spaces(const char *); 65extern char * __must_check skip_spaces(const char *);
66extern char * __must_check strstrip(char *); 66
67extern char *strim(char *);
68
69static inline __must_check char *strstrip(char *str)
70{
71 return strim(str);
72}
73
67#ifndef __HAVE_ARCH_STRSTR 74#ifndef __HAVE_ARCH_STRSTR
68extern char * strstr(const char *,const char *); 75extern char * strstr(const char *,const char *);
69#endif 76#endif
diff --git a/lib/string.c b/lib/string.c
index 765566a6a088..afce96af3afd 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -352,14 +352,14 @@ char *skip_spaces(const char *str)
352EXPORT_SYMBOL(skip_spaces); 352EXPORT_SYMBOL(skip_spaces);
353 353
354/** 354/**
355 * strstrip - Removes leading and trailing whitespace from @s. 355 * strim - Removes leading and trailing whitespace from @s.
356 * @s: The string to be stripped. 356 * @s: The string to be stripped.
357 * 357 *
358 * Note that the first trailing whitespace is replaced with a %NUL-terminator 358 * Note that the first trailing whitespace is replaced with a %NUL-terminator
359 * in the given string @s. Returns a pointer to the first non-whitespace 359 * in the given string @s. Returns a pointer to the first non-whitespace
360 * character in @s. 360 * character in @s.
361 */ 361 */
362char *strstrip(char *s) 362char *strim(char *s)
363{ 363{
364 size_t size; 364 size_t size;
365 char *end; 365 char *end;
@@ -376,7 +376,7 @@ char *strstrip(char *s)
376 376
377 return s; 377 return s;
378} 378}
379EXPORT_SYMBOL(strstrip); 379EXPORT_SYMBOL(strim);
380 380
381#ifndef __HAVE_ARCH_STRLEN 381#ifndef __HAVE_ARCH_STRLEN
382/** 382/**