summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-11-09 14:21:46 +0100
committerJim Meyering <meyering@redhat.com>2009-11-09 22:34:16 +0100
commit627f89351d06e43564b47ea42cabaa522284c2a1 (patch)
tree088ef0ed9661ac5f76e61373c899bfe2edce9d0b
parent29842da1379ece83eae98ee786b475ae161f1687 (diff)
downloadlibguestfs-627f89351d06e43564b47ea42cabaa522284c2a1.tar.gz
libguestfs-627f89351d06e43564b47ea42cabaa522284c2a1.tar.xz
libguestfs-627f89351d06e43564b47ea42cabaa522284c2a1.zip
change strncmp(...) != 0 to STRNEQLEN(...)
git grep -l 'strncmp *([^=]*!= *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *!= *0/STRNEQLEN$1/g'
-rw-r--r--daemon/daemon.h2
-rw-r--r--daemon/guestfsd.c2
-rw-r--r--examples/to-xml.c2
-rw-r--r--src/generator.ml2
4 files changed, 4 insertions, 4 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 3f4c4807..1cdb4800 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 d16826f0..61a62368 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 6d0a1dfb..f48d1ca7 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 ("<vm-image dev=\"%s\"/>\n", dev);
return;
}
diff --git a/src/generator.ml b/src/generator.ml
index 3a25c570..aff63567 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"