mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	James Bottomley <James.Bottomley@suse.de>,
	linux-scsi@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] strstrip incorrectly marked __must_check
Date: Wed, 4 Nov 2009 04:58:50 +0900	[thread overview]
Message-ID: <2f11576a0911031158r7fabb96fx8073bb4e86f4981e@mail.gmail.com> (raw)
In-Reply-To: <20091103191233.0c3ba736@lxorguk.ukuu.org.uk>

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

2009/11/4 Alan Cox <alan@lxorguk.ukuu.org.uk>:
>> static inline void strsrip_tail(char *str)
>> {
>>       char *x __used;
>>       x = strstrip(str);
>> }
>
> Bikeshed time but its cleaner to do
>
> static inline __must_check void strstrip(char *str)
> {
>        return strim(str);
> }
>
> and make strim() the old strstrip function without the check requirement

Okey...

[quick hack and compile check]

done :)
sorry for attached file. I'm under poor mail environment now.

[-- Attachment #2: 0001-lib-Introduce-strim.patch --]
[-- Type: application/octet-stream, Size: 3088 bytes --]

From 94a86424a882d52fcd11039d11fbd0363a31472f Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Date: Wed, 4 Nov 2009 04:47:23 +0900
Subject: [PATCH] lib: Introduce strim

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 wish to keep the whitespace at the beginning.

Thus, we need to keep with and without checked whitespace trim function. This patch
makes strim new function and ipr.c use it.

Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 drivers/scsi/ipr.c     |    4 ++--
 include/linux/string.h |    9 ++++++++-
 lib/string.c           |    6 +++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index d40d5c7..6602fc4 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,
 
 	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));
diff --git a/include/linux/string.h b/include/linux/string.h
index b850886..17a375e 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -62,7 +62,14 @@ extern char * strnchr(const char *, size_t, int);
 #ifndef __HAVE_ARCH_STRRCHR
 extern char * strrchr(const char *,int);
 #endif
-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
diff --git a/lib/string.c b/lib/string.c
index b19b87a..28211c6 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -330,14 +330,14 @@ EXPORT_SYMBOL(strnchr);
 #endif
 
 /**
- * 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;
@@ -357,7 +357,7 @@ char *strstrip(char *s)
 
 	return s;
 }
-EXPORT_SYMBOL(strstrip);
+EXPORT_SYMBOL(strim);
 
 #ifndef __HAVE_ARCH_STRLEN
 /**
-- 
1.6.2.5


  reply	other threads:[~2009-11-03 19:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-03 18:38 James Bottomley
2009-11-03 18:59 ` Andrew Morton
2009-11-03 19:04   ` Matthew Wilcox
2009-11-03 19:06     ` KOSAKI Motohiro
2009-11-03 19:10     ` Alan Cox
2009-11-03 19:11     ` James Bottomley
2009-11-03 19:10   ` James Bottomley
2009-11-03 19:12   ` Alan Cox
2009-11-03 19:58     ` KOSAKI Motohiro [this message]
2009-11-23 13:04       ` Michael Holzheu
2009-11-24  8:55         ` KOSAKI Motohiro
2009-11-24  9:09           ` Michael Holzheu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f11576a0911031158r7fabb96fx8073bb4e86f4981e@mail.gmail.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®