From: Andrew Morton on 3 Nov 2009 14:00 On Tue, 03 Nov 2009 12:38:08 -0600 James Bottomley <James.Bottomley(a)suse.de> wrote: > strstrip strips whitespace from the beginning and end of a string. I > agree you have to take the returned pointer if you want to strip from > the beginning. However, if you wish to keep the whitespace at the > beginning and only wish strstrip to remove it from the end, then it's > entirely legitimate to discard the returned pointer. > > This is what we have in drivers/scsi/ipr.c and the patch to make > strstrip __must_check is now causing SCSI spurious warnings in that > code. > Would prefer to keep the warning and to patch ipr.c, please. We found I think three call sites which were incorrectly ignoring the strstrip() return value and it's reasonable to fear that others will make the same mistake in the future. And maybe ipr.c _should_ be patched. Right now it's assuming that the string coming back from the device has no leading whitespace. Why trim any possible trailing whitespace but not trim any possible leading whitespace? Or.. /* * Comment goes here */ static inline void strsrip_tail(char *str) { char *x __used; x = strstrip(str); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: KOSAKI Motohiro on 3 Nov 2009 14:10 2009/11/4 Matthew Wilcox <matthew(a)wil.cx>: > > �static inline void strsrip_tail(char *str) > �{ > - � � � char *x __used; > - � � � x = strstrip(str); > + � � � char *x = strstrip(str); > + � � � BUG_ON(x != str); > �} Looks reasonable to me :) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Matthew Wilcox on 3 Nov 2009 14:10 static inline void strsrip_tail(char *str) { - char *x __used; - x = strstrip(str); + char *x = strstrip(str); + BUG_ON(x != str); } -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Alan Cox on 3 Nov 2009 14:10 On Tue, 3 Nov 2009 12:04:20 -0700 Matthew Wilcox <matthew(a)wil.cx> wrote: > > static inline void strsrip_tail(char *str) > { > - char *x __used; > - x = strstrip(str); > + char *x = strstrip(str); > + BUG_ON(x != str); That breaks it. It was fine before you did that but now it blows up if there are leading spaces. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Alan Cox on 3 Nov 2009 14:20 > 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 Alan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Next
|
Last
Pages: 1 2 Prev: tun: export underlying socket Next: oom-killer: check last total_vm expansion |