public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@gnu.org>
To: Dave Reisner <d@falconindy.com>
Cc: util-linux@vger.kernel.org, Dave Reisner <dreisner@archlinux.org>
Subject: Re: [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances
Date: Sun, 18 Mar 2012 15:53:37 +0100	[thread overview]
Message-ID: <1332082417.2792.1.camel@offbook> (raw)
In-Reply-To: <1332041793-7919-1-git-send-email-dreisner@archlinux.org>

On Sat, 2012-03-17 at 23:36 -0400, Dave Reisner wrote:
> Using the -w flag with grep actually fought against us here, and hid
> some instances where xalloc functions weren't used. Discard it in favor
> of an explicit word boundary as a prefix to the function name, and
> extend our requirements on the trailing side of the pattern.
> 
> This also fixes the few new instances that were overlooked because of
> the regex's deficiency.
> 
> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
> ---
>  fdisk/sfdisk.c       |    2 +-
>  sys-utils/swapon.c   |    4 ++--
>  tools/checkxalloc.sh |    2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
> index 6267652..e766b04 100644
> --- a/fdisk/sfdisk.c
> +++ b/fdisk/sfdisk.c
> @@ -304,7 +304,7 @@ restore_sectors(char *dev) {
>  	error(_("partition restore file has wrong size - not restoring\n"));
>  	goto err;
>      }
> -    if (!(ss0 = (char *)malloc(statbuf.st_size))) {
> +    if (!(ss0 = xmalloc(statbuf.st_size))) {
>  	error(_("out of memory?\n"));
>  	goto err;
>      }

xmalloc and friends abort the program when allocation fail.

> diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
> index f17fad6..fe16169 100644
> --- a/sys-utils/swapon.c
> +++ b/sys-utils/swapon.c
> @@ -197,7 +197,7 @@ read_proc_swaps(void) {
>  			       *p = '\0';
>  		}
>  
> -		q = realloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
> +		q = xrealloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
>  		if (q == NULL)
>  			break;

same here. This would actually break functionality.

>  		swapFiles = q;
> @@ -640,7 +640,7 @@ swapon_all(void) {
>  		if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
>  			continue;
>  
> -		opts = strdup(fstab->mnt_opts);
> +		opts = xstrdup(fstab->mnt_opts);
>  
>  		for (opt = strtok(opts, ","); opt != NULL;
>  		     opt = strtok(NULL, ",")) {
> diff --git a/tools/checkxalloc.sh b/tools/checkxalloc.sh
> index 578340e..6634c82 100755
> --- a/tools/checkxalloc.sh
> +++ b/tools/checkxalloc.sh
> @@ -10,7 +10,7 @@ cd "$(git rev-parse --show-toplevel)" || {
>  }
>  
>  git grep -zl '#include "xalloc.h"' |
> -  xargs -0 grep -nwE '[^x](([cm]|re)alloc|strdup)\('
> +  xargs -0 grep -nE '\b(([cm]|re)alloc|strdup)[[:space:]]*\([^)]'
>  
>  result=$?
>  



  parent reply	other threads:[~2012-03-18 14:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-18  3:36 [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances Dave Reisner
2012-03-18  3:36 ` [PATCH 2/5] tunelp: remove old, now unneeded header Dave Reisner
2012-03-20  9:53   ` Karel Zak
2012-03-18  3:36 ` [PATCH 3/5] include/ttyutils.h: add include guards Dave Reisner
2012-03-20  9:53   ` Karel Zak
2012-03-18  3:36 ` [PATCH 4/5] findmnt: add FS size, avail, used, and use% columns Dave Reisner
2012-03-20  9:54   ` Karel Zak
2012-03-18  3:36 ` [PATCH 5/5] findmnt: add -D, --df option to imitate df(1) Dave Reisner
2012-03-20 10:09   ` Karel Zak
2012-03-18 14:53 ` Davidlohr Bueso [this message]
2012-03-20  8:50 ` [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances Karel Zak

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=1332082417.2792.1.camel@offbook \
    --to=dave@gnu.org \
    --cc=d@falconindy.com \
    --cc=dreisner@archlinux.org \
    --cc=util-linux@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