public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances
@ 2012-03-18  3:36 Dave Reisner
  2012-03-18  3:36 ` [PATCH 2/5] tunelp: remove old, now unneeded header Dave Reisner
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Dave Reisner @ 2012-03-18  3:36 UTC (permalink / raw)
  To: util-linux; +Cc: Dave Reisner

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;
     }
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;
 		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=$?
 
-- 
1.7.9.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-03-20 10:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances Davidlohr Bueso
2012-03-20  8:50 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox