From 627f89351d06e43564b47ea42cabaa522284c2a1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 9 Nov 2009 14:21:46 +0100 Subject: [PATCH] change strncmp(...) != 0 to STRNEQLEN(...) git grep -l 'strncmp *([^=]*!= *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *!= *0/STRNEQLEN$1/g' --- daemon/daemon.h | 2 +- daemon/guestfsd.c | 2 +- examples/to-xml.c | 2 +- src/generator.ml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 3f4c480..1cdb480 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -164,7 +164,7 @@ extern void reply (xdrproc_t xdrp, char *ret); */ #define RESOLVE_DEVICE(path,fail_stmt) \ do { \ - if (strncmp ((path), "/dev/", 5) != 0) { \ + if (STRNEQLEN ((path), "/dev/", 5)) { \ reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \ fail_stmt; \ } \ diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index d16826f..61a6236 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -945,7 +945,7 @@ device_name_translation (char *device, const char *func) } /* If the name begins with "/dev/sd" then try the alternatives. */ - if (strncmp (device, "/dev/sd", 7) != 0) + if (STRNEQLEN (device, "/dev/sd", 7)) goto error; device[5] = 'h'; /* /dev/hd (old IDE driver) */ diff --git a/examples/to-xml.c b/examples/to-xml.c index 6d0a1df..f48d1ca 100644 --- a/examples/to-xml.c +++ b/examples/to-xml.c @@ -149,7 +149,7 @@ display_partitions (guestfs_h *g, const char *dev) * That's a limitation of sorts of the Linux kernel. (Actually, * we could do this if we add the kpartx program to libguestfs). */ - if (strncmp (dev, "/dev/sd", 7) != 0 || isdigit (dev[strlen(dev)-1])) { + if (STRNEQLEN (dev, "/dev/sd", 7) || isdigit (dev[strlen(dev)-1])) { printf ("\n", dev); return; } diff --git a/src/generator.ml b/src/generator.ml index 3a25c57..aff6356 100644 --- a/src/generator.ml +++ b/src/generator.ml @@ -6146,7 +6146,7 @@ and generate_one_test_body name i test_name init test = pr " fprintf (stderr, \"%s: returned size of buffer wrong, expected %d but got %%zu\\n\", size);\n" test_name len; pr " return -1;\n"; pr " }\n"; - pr " if (strncmp (r, expected, size) != 0) {\n"; + pr " if (STRNEQLEN (r, expected, size)) {\n"; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name; pr " return -1;\n"; pr " }\n" -- 1.8.3.1