From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Subject: Re: [PATCH v4 12/12] tree-wide: convert open calls to remove spaces to skip_spaces() lib function Date: Sun, 8 Nov 2009 21:23:07 +0100 (CET) Message-ID: References: <7d5883637aa976b54e944998f635d47a41618a75.1257602781.git.andre.goddard@gmail.com> <20091108184722.GA1647@mit.edu> Reply-To: Linux filesystem caching discussion list Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: <20091108184722.GA1647@mit.edu> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cachefs-bounces@redhat.com Errors-To: linux-cachefs-bounces@redhat.com To: Theodore Tso Cc: Pavel Roskin , Stefan Haberland , Jan Kara , linux-cachefs@redhat.com, Mike Snitzer , Neil Brown , Frederic Weisbecker , Jens Axboe , Heiko Carstens , "James E . J . Bottomley" , ibm-acpi-devel@lists.sourceforge.net, dm-devel@redhat.com, "H . Peter Anvin" , Daire Byrne , Alasdair G Kergon , Greg Banks , Stefan Weinhuber , Eric Sandeen , Adam Belay , Helge Deller , x86@kernel.org, James Morris , Takashi Iwai , =?iso-8859-1?Q?Andr=E9?= Goddard Rosa , Alan Cox List-Id: linux-raid.ids > > Also, while at it, if we see (*str && isspace(*str)), we can be sure to > > remove the first condition (*str) as the second one (isspace(*str)) also > > evaluates to 0 whenever *str == 0, making it redundant. In other words, > > "a char equals zero is never a space". I tried the following semantic patch (http://coccinelle.lip6.fr), and got the results below. @@ expression str; @@ ( // ignore skip_spaces cases while (*str && isspace(*str)) { \(str++;\|++str;\) } | - *str && isspace(*str) ) I haven't checked the results in any way, however. julia diff -u -p a/drivers/leds/led-class.c b/drivers/leds/led-class.c --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -50,7 +50,7 @@ static ssize_t led_brightness_store(stru unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { diff -u -p a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c @@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { @@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struc unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { diff -u -p a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct de int power = simple_strtoul(buf, &endp, 0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; @@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct int contrast = simple_strtoul(buf, &endp, 0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; diff -u -p a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c --- a/drivers/video/display/display-sysfs.c +++ b/drivers/video/display/display-sysfs.c @@ -67,7 +67,7 @@ static ssize_t display_store_contrast(st contrast = simple_strtoul(buf, &endp, 0); size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) diff -u -p a/drivers/video/output.c b/drivers/video/output.c --- a/drivers/video/output.c +++ b/drivers/video/output.c @@ -50,7 +50,7 @@ static ssize_t video_output_store_state( int request_state = simple_strtoul(buf,&endp,0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 8 Nov 2009 21:23:07 +0100 (CET) From: Julia Lawall In-Reply-To: <20091108184722.GA1647@mit.edu> Message-ID: References: <7d5883637aa976b54e944998f635d47a41618a75.1257602781.git.andre.goddard@gmail.com> <20091108184722.GA1647@mit.edu> MIME-Version: 1.0 Subject: Re: [uml-devel] [PATCH v4 12/12] tree-wide: convert open calls to remove spaces to skip_spaces() lib function List-Id: The user-mode Linux development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: user-mode-linux-devel-bounces@lists.sourceforge.net To: Theodore Tso Cc: Pavel Roskin , Stefan Haberland , Jan Kara , linux-cachefs@redhat.com, Mike Snitzer , Neil Brown , Frederic Weisbecker , Jens Axboe , Heiko Carstens , Steve Dickson , "James E . J . Bottomley" , David Howells , ibm-acpi-devel@lists.sourceforge.net, dm-devel@redhat.com, "H . Peter Anvin" , Daire Byrne , Alasdair G Kergon , Greg Banks , Stefan Weinhuber , Eric Sandeen , Adam Belay , Helge Deller , x86@kernel.org, James Morris , Takashi Iwai , =?iso-8859-1?Q?Andr=E9?= Goddard Rosa , Alan Cox , WANG Cong , Roman Hoog Antink , linux-ext4@vger.kernel.org, Alexey Dobriyan , Andrea Righi , alsa-devel@alsa-project.org, Len Brown , Samuel Ortiz , coreteam@netfilter.org, user-mode-linux-devel@lists.sourceforge.net, linux-s390@vger.kernel.org, Trond Myklebust , Jeff Dike , Rusty Russell , Henrique de Moraes Holschuh , Sitsofe Wheeler , Steven Rostedt , linux-raid@vger.kernel.org, Martin Schwidefsky , Andreas Dilger , Pekka Enberg , Mikulas Patocka , Al Viro , user-mode-linux-user@lists.sourceforge.net, Jaroslav Kysela , Thomas Gleixner , Michael Holzheu , Arjan van de Ven , Ingo Molnar , Jan Engelhardt , Bjorn Helgaas , Andre Noll , netfilter-devel@vger.kernel.org, linux-parisc@vger.kernel.org, "Martin K . Petersen" , netdev@vger.kernel.org, Jason Baron , Greg Kroah-Hartman , Roel Kluin , linux-kernel@vger.kernel.org, Stoyan Gaydarov , Patrick McHardy , Kyle McMartin , Christof Schmitt , netfilter@vger.kernel.org, Richard Purdie , Joe Perches , linux390@de.ibm.com, Andrew Morton , Andrey Borzenkov , "David S . Miller" > > Also, while at it, if we see (*str && isspace(*str)), we can be sure to > > remove the first condition (*str) as the second one (isspace(*str)) also > > evaluates to 0 whenever *str == 0, making it redundant. In other words, > > "a char equals zero is never a space". I tried the following semantic patch (http://coccinelle.lip6.fr), and got the results below. @@ expression str; @@ ( // ignore skip_spaces cases while (*str && isspace(*str)) { \(str++;\|++str;\) } | - *str && isspace(*str) ) I haven't checked the results in any way, however. julia diff -u -p a/drivers/leds/led-class.c b/drivers/leds/led-class.c --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -50,7 +50,7 @@ static ssize_t led_brightness_store(stru unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { diff -u -p a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c @@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { @@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struc unsigned long state = simple_strtoul(buf, &after, 10); size_t count = after - buf; - if (*after && isspace(*after)) + if (isspace(*after)) count++; if (count == size) { diff -u -p a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct de int power = simple_strtoul(buf, &endp, 0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; @@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct int contrast = simple_strtoul(buf, &endp, 0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; diff -u -p a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c --- a/drivers/video/display/display-sysfs.c +++ b/drivers/video/display/display-sysfs.c @@ -67,7 +67,7 @@ static ssize_t display_store_contrast(st contrast = simple_strtoul(buf, &endp, 0); size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) diff -u -p a/drivers/video/output.c b/drivers/video/output.c --- a/drivers/video/output.c +++ b/drivers/video/output.c @@ -50,7 +50,7 @@ static ssize_t video_output_store_state( int request_state = simple_strtoul(buf,&endp,0); size_t size = endp - buf; - if (*endp && isspace(*endp)) + if (isspace(*endp)) size++; if (size != count) return -EINVAL; ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel