linux-um archives
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: Theodore Tso <tytso@mit.edu>
Cc: "Pavel Roskin" <proski@gnu.org>,
	"Stefan Haberland" <stefan.haberland@de.ibm.com>,
	"Jan Kara" <jack@suse.cz>,
	linux-cachefs@redhat.com, "Mike Snitzer" <snitzer@redhat.com>,
	"Neil Brown" <neilb@suse.de>,
	"Frederic Weisbecker" <fweisbec@gmail.com>,
	"Jens Axboe" <jens.axboe@oracle.com>,
	"Heiko Carstens" <heiko.carstens@de.ibm.com>,
	"Steve Dickson" <steved@redhat.com>,
	"James E . J . Bottomley" <jejb@parisc-linux.org>,
	"David Howells" <dhowells@redhat.com>,
	ibm-acpi-devel@lists.sourceforge.net, dm-devel@redhat.com,
	"H . Peter Anvin" <hpa@zytor.com>,
	"Daire Byrne" <Daire.Byrne@framestore.com>,
	"Alasdair G Kergon" <agk@redhat.com>,
	"Greg Banks" <gnb@melbourne.sgi.com>,
	"Stefan Weinhuber" <wein@de.ibm.com>,
	"Eric Sandeen" <sandeen@redhat.com>,
	"Adam Belay" <abelay@mit.edu>, "Helge Deller" <deller@gmx.de>,
	x86@kernel.org, "James Morris" <jmorris@namei.org>,
	"Takashi Iwai" <tiwai@suse.de>,
	"André Goddard Rosa" <andre.goddard@gmail.com>,
	"Alan Cox" <alan@lxorguk.ukuu.org.uk>,
	"WANG Cong" <wangcong@zeuux.org>,
	"Roman Hoog Antink" <rha@open.ch>,
	linux-ext4@vger.kernel.org,
	"Alexey Dobriyan" <adobriyan@gmail.com>,
	"Andrea Righi" <righi.andrea@gmail.com>,
	alsa-devel@alsa-project.org, "Len Brown" <len.brown@intel.com>,
	"Samuel Ortiz" <samuel@sortiz.org>,
	coreteam@netfilter.org,
	user-mode-linux-devel@lists.sourceforge.net,
	linux-s390@vger.kernel.org,
	"Trond Myklebust" <Trond.Myklebust@netapp.com>,
	"Jeff Dike" <jdike@addtoit.com>,
	"Rusty Russell" <rusty@rustcorp.com.au>,
	"Henrique de Moraes Holschuh" <ibm-acpi@hmh.eng.br>,
	"Sitsofe Wheeler" <sitsofe@yahoo.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	linux-raid@vger.kernel.org,
	"Martin Schwidefsky" <schwidefsky@de.ibm.com>,
	"Andreas Dilger" <adilger@sun.com>,
	"Pekka Enberg" <penberg@cs.helsinki.fi>,
	"Mikulas Patocka" <mpatocka@redhat.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	user-mode-linux-user@lists.sourceforge.net,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Michael Holzheu" <holzheu@linux.vnet.ibm.com>,
	"Arjan van de Ven" <arjan@linux.intel.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Jan Engelhardt" <jengelh@medozas.de>,
	"Bjorn Helgaas" <bjorn.helgaas@hp.com>,
	"Andre Noll" <maan@systemlinux.org>,
	netfilter-devel@vger.kernel.org, linux-parisc@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	netdev@vger.kernel.org, "Jason Baron" <jbaron@redhat.com>,
	"Greg Kroah-Hartman" <gregkh@suse.de>,
	"Roel Kluin" <roel.kluin@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Stoyan Gaydarov" <stoyboyker@gmail.com>,
	"Patrick McHardy" <kaber@trash.net>,
	"Kyle McMartin" <kyle@mcmartin.ca>,
	"Christof Schmitt" <christof.schmitt@de.ibm.com>,
	netfilter@vger.kernel.org, "Richard Purdie" <rpurdie@rpsys.net>,
	"Joe Perches" <joe@perches.com>,
	linux390@de.ibm.com, "Andrew Morton" <akpm@linux-foundation.org>,
	"Andrey Borzenkov" <arvidjaar@mail.ru>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [uml-devel] [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)	[thread overview]
Message-ID: <Pine.LNX.4.64.0911082103000.8143@ask.diku.dk> (raw)
In-Reply-To: <20091108184722.GA1647@mit.edu>

> > 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


  reply	other threads:[~2009-11-08 20:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-07 15:16 [uml-devel] [PATCH v4 00/12] introduce skip_spaces(), reducing code size plus some clean-ups André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 01/12] vsprintf: factorize "(null)" string André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 02/12] vsprintf: pre-calculate final string length for later use André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 03/12] vsprintf: give it some care to please checkpatch.pl André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 04/12] vsprintf: use TOLOWER whenever possible André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 05/12] vsprintf: reduce code size by avoiding extra check André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 06/12] vsprintf: move local vars to block local vars and remove unneeded ones André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 07/12] vsprintf: factor out skip_space code in a separate function André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 08/12] vsprintf: reuse almost identical simple_strtoulX() functions André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 09/12] ctype: constify read-only _ctype string André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 10/12] string: factorize skip_spaces and export it to be generally available André Goddard Rosa
2009-11-08 16:50   ` Alan Cox
2009-11-07 15:16 ` [uml-devel] [PATCH v4 11/12] string: on strstrip(), first remove leading spaces before running over str André Goddard Rosa
2009-11-07 15:16 ` [uml-devel] [PATCH v4 12/12] tree-wide: convert open calls to remove spaces to skip_spaces() lib function André Goddard Rosa
2009-11-08 18:47   ` Theodore Tso
2009-11-08 20:23     ` Julia Lawall [this message]
2009-11-08 16:05 ` [uml-devel] [dm-devel] [PATCH v4 00/12] introduce skip_spaces(), reducing code size plus some clean-ups James Bottomley
2009-11-08 16:52   ` André Goddard Rosa

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=Pine.LNX.4.64.0911082103000.8143@ask.diku.dk \
    --to=julia@diku.dk \
    --cc=Daire.Byrne@framestore.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=abelay@mit.edu \
    --cc=adilger@sun.com \
    --cc=adobriyan@gmail.com \
    --cc=agk@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=andre.goddard@gmail.com \
    --cc=arjan@linux.intel.com \
    --cc=arvidjaar@mail.ru \
    --cc=bjorn.helgaas@hp.com \
    --cc=christof.schmitt@de.ibm.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=dhowells@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=gnb@melbourne.sgi.com \
    --cc=gregkh@suse.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ibm-acpi@hmh.eng.br \
    --cc=jack@suse.cz \
    --cc=jbaron@redhat.com \
    --cc=jdike@addtoit.com \
    --cc=jejb@parisc-linux.org \
    --cc=jengelh@medozas.de \
    --cc=jens.axboe@oracle.com \
    --cc=jmorris@namei.org \
    --cc=joe@perches.com \
    --cc=kaber@trash.net \
    --cc=kyle@mcmartin.ca \
    --cc=len.brown@intel.com \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux390@de.ibm.com \
    --cc=maan@systemlinux.org \
    --cc=martin.petersen@oracle.com \
    --cc=mingo@redhat.com \
    --cc=mpatocka@redhat.com \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=netfilter@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=perex@perex.cz \
    --cc=proski@gnu.org \
    --cc=rha@open.ch \
    --cc=righi.andrea@gmail.com \
    --cc=roel.kluin@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=rpurdie@rpsys.net \
    --cc=rusty@rustcorp.com.au \
    --cc=samuel@sortiz.org \
    --cc=sandeen@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=sitsofe@yahoo.com \
    --cc=snitzer@redhat.com \
    --cc=stefan.haberland@de.ibm.com \
    --cc=steved@redhat.com \
    --cc=stoyboyker@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tiwai@suse.de \
    --cc=tytso@mit.edu \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    --cc=user-mode-linux-user@lists.sourceforge.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wangcong@zeuux.org \
    --cc=wein@de.ibm.com \
    --cc=x86@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