diff options
author | Jim Meyering <meyering@redhat.com> | 2009-11-09 14:26:21 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-11-09 22:34:16 +0100 |
commit | 3e70b34eed5a48640e20fbf6dcba774aaace1f3c (patch) | |
tree | 5bb681d85d8ff394f562b095e70c36d4ac5f7b5d | |
parent | 627f89351d06e43564b47ea42cabaa522284c2a1 (diff) | |
download | libguestfs-3e70b34eed5a48640e20fbf6dcba774aaace1f3c.tar.gz libguestfs-3e70b34eed5a48640e20fbf6dcba774aaace1f3c.tar.xz libguestfs-3e70b34eed5a48640e20fbf6dcba774aaace1f3c.zip |
change strncmp() == 0 to STREQLEN()
git grep -l 'strncmp *([^=]*== *0'|xargs \
perl -pi -e 's/\bstrncmp( *\(.*?\)) *== *0\b/STREQLEN$1/g'
-rw-r--r-- | daemon/daemon.h | 2 | ||||
-rw-r--r-- | daemon/devsparts.c | 10 | ||||
-rw-r--r-- | daemon/ext2.c | 2 | ||||
-rw-r--r-- | daemon/file.c | 2 | ||||
-rw-r--r-- | daemon/guestfsd.c | 2 | ||||
-rw-r--r-- | daemon/mount.c | 2 | ||||
-rw-r--r-- | daemon/upload.c | 4 | ||||
-rw-r--r-- | examples/to-xml.c | 8 | ||||
-rw-r--r-- | fish/destpaths.c | 2 | ||||
-rw-r--r-- | fish/edit.c | 2 | ||||
-rw-r--r-- | fish/tilde.c | 2 | ||||
-rw-r--r-- | hivex/hivex.c | 2 | ||||
-rw-r--r-- | test-tool/test-tool.c | 2 |
13 files changed, 21 insertions, 21 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h index 1cdb4800..ac684792 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -184,7 +184,7 @@ extern void reply (xdrproc_t xdrp, char *ret); */ #define REQUIRE_ROOT_OR_RESOLVE_DEVICE(path,fail_stmt) \ do { \ - if (strncmp ((path), "/dev/", 5) == 0) \ + if (STREQLEN ((path), "/dev/", 5)) \ RESOLVE_DEVICE ((path), fail_stmt); \ else { \ NEED_ROOT (fail_stmt); \ diff --git a/daemon/devsparts.c b/daemon/devsparts.c index 76852cca..60e7aa8c 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -53,10 +53,10 @@ foreach_block_device (block_dev_func_t func) struct dirent *d = readdir(dir); if(NULL == d) break; - if (strncmp (d->d_name, "sd", 2) == 0 || - strncmp (d->d_name, "hd", 2) == 0 || - strncmp (d->d_name, "vd", 2) == 0 || - strncmp (d->d_name, "sr", 2) == 0) { + if (STREQLEN (d->d_name, "sd", 2) || + STREQLEN (d->d_name, "hd", 2) || + STREQLEN (d->d_name, "vd", 2) || + STREQLEN (d->d_name, "sr", 2)) { char dev_path[256]; snprintf (dev_path, sizeof dev_path, "/dev/%s", d->d_name); @@ -153,7 +153,7 @@ add_partitions(const char *device, errno = 0; struct dirent *d; while ((d = readdir (dir)) != NULL) { - if (strncmp (d->d_name, device, strlen (device)) == 0) { + if (STREQLEN (d->d_name, device, strlen (device))) { char part[256]; snprintf (part, sizeof part, "/dev/%s", d->d_name); diff --git a/daemon/ext2.c b/daemon/ext2.c index 0021a065..14cbb3c9 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -48,7 +48,7 @@ do_tune2fs_l (const char *device) p = out; /* Discard the first line if it contains "tune2fs ...". */ - if (strncmp (p, "tune2fs ", 8) == 0) { + if (STREQLEN (p, "tune2fs ", 8)) { p = strchr (p, '\n'); if (p) p++; else { diff --git a/daemon/file.c b/daemon/file.c index 7854adef..62de1168 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -430,7 +430,7 @@ do_file (const char *path) char *buf; int len; - if (strncmp (path, "/dev/", 5) == 0) + if (STREQLEN (path, "/dev/", 5)) buf = (char *) path; else { buf = sysroot_path (path); diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 61a62368..5789feda 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -226,7 +226,7 @@ main (int argc, char *argv[]) /* Connect to vmchannel. */ int sock = -1; - if (strncmp (vmchannel, "tcp:", 4) == 0) { + if (STREQLEN (vmchannel, "tcp:", 4)) { /* Resolve the hostname. */ struct addrinfo *res, *rr; struct addrinfo hints; diff --git a/daemon/mount.c b/daemon/mount.c index 463e789f..5a27cea1 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -112,7 +112,7 @@ do_umount (const char *pathordevice) char *buf; int is_dev; - is_dev = strncmp (pathordevice, "/dev/", 5) == 0; + is_dev = STREQLEN (pathordevice, "/dev/", 5); buf = is_dev ? strdup (pathordevice) : sysroot_path (pathordevice); if (buf == NULL) { diff --git a/daemon/upload.c b/daemon/upload.c index da86bd65..7b2ccea5 100644 --- a/daemon/upload.c +++ b/daemon/upload.c @@ -40,7 +40,7 @@ do_upload (const char *filename) { int err, fd, r, is_dev; - is_dev = strncmp (filename, "/dev/", 5) == 0; + is_dev = STREQLEN (filename, "/dev/", 5); if (!is_dev) { if (!root_mounted || filename[0] != '/') { cancel_receive (); @@ -93,7 +93,7 @@ do_download (const char *filename) int fd, r, is_dev; char buf[GUESTFS_MAX_CHUNK_SIZE]; - is_dev = strncmp (filename, "/dev/", 5) == 0; + is_dev = STREQLEN (filename, "/dev/", 5); if (!is_dev) CHROOT_IN; fd = open (filename, O_RDONLY); diff --git a/examples/to-xml.c b/examples/to-xml.c index f48d1ca7..43176195 100644 --- a/examples/to-xml.c +++ b/examples/to-xml.c @@ -87,8 +87,8 @@ main (int argc, char *argv[]) int len = strlen (vgs[i]); int j; for (j = 0; lvs[j] != NULL; ++j) { - if (strncmp (lvs[j], "/dev/", 5) == 0 && - strncmp (&lvs[j][5], vgs[i], len) == 0 && + if (STREQLEN (lvs[j], "/dev/", 5) && + STREQLEN (&lvs[j][5], vgs[i], len) && lvs[j][len+5] == '/') { int64_t size; CALL (size = guestfs_blockdev_getsize64 (g, lvs[j]), -1); @@ -125,7 +125,7 @@ display_partition (guestfs_h *g, const char *dev) printf ("<windows/>\n"); else if (strstr (what, "boot sector") != NULL) display_partitions (g, dev); - else if (strncmp (what, "LVM2", 4) == 0) + else if (STREQLEN (what, "LVM2", 4)) printf ("<physvol/>\n"); else if (strstr (what, "ext2 filesystem data") != NULL) display_ext234 (g, dev, "ext2"); @@ -162,7 +162,7 @@ display_partitions (guestfs_h *g, const char *dev) len = strlen (dev); for (i = 0; parts[i] != NULL; ++i) { /* Only display partition if it's in the device. */ - if (strncmp (parts[i], dev, len) == 0) { + if (STREQLEN (parts[i], dev, len)) { int64_t size; CALL (size = guestfs_blockdev_getsize64 (g, parts[i]), -1); printf ("<partition dev=\"%s\" size=\"%" PRIi64 "\">\n", parts[i], size); diff --git a/fish/destpaths.c b/fish/destpaths.c index 1e42ae80..9a3da82b 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -133,7 +133,7 @@ complete_dest_paths_generator (const char *text, int state) } while (0) /* Is it a device? */ - if (len < 5 || strncmp (text, "/dev/", 5) == 0) { + if (len < 5 || STREQLEN (text, "/dev/", 5)) { /* Get a list of everything that can possibly begin with /dev/ */ strs = guestfs_list_devices (g); APPEND_STRS_AND_FREE; diff --git a/fish/edit.c b/fish/edit.c index d30b3cad..3fc41fb1 100644 --- a/fish/edit.c +++ b/fish/edit.c @@ -149,7 +149,7 @@ do_edit (const char *cmd, int argc, char *argv[]) unlink (filename); /* Changed? */ - if (strlen (content) == size && strncmp (content, content_new, size) == 0) { + if (strlen (content) == size && STREQLEN (content, content_new, size)) { free (content); free (content_new); return 0; diff --git a/fish/tilde.c b/fish/tilde.c index 1c52d3ed..64b5b399 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -110,7 +110,7 @@ find_home_for_username (const char *username, size_t ulen) setpwent (); while ((pw = getpwent ()) != NULL) { if (strlen (pw->pw_name) == ulen && - strncmp (username, pw->pw_name, ulen) == 0) + STREQLEN (username, pw->pw_name, ulen)) return pw->pw_dir; } diff --git a/hivex/hivex.c b/hivex/hivex.c index 8ea2c2b4..4b0deebc 100644 --- a/hivex/hivex.c +++ b/hivex/hivex.c @@ -143,7 +143,7 @@ struct ntreg_hbin_block { } __attribute__((__packed__)); #define BLOCK_ID_EQ(h,offs,eqid) \ - (strncmp (((struct ntreg_hbin_block *)((h)->addr + (offs)))->id, (eqid), 2) == 0) + (STREQLEN (((struct ntreg_hbin_block *)((h)->addr + (offs)))->id, (eqid), 2)) static size_t block_len (hive_h *h, size_t blkoff, int *used) diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index c1a3de7c..8a80f66d 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -145,7 +145,7 @@ main (int argc, char *argv[]) /* Print out any environment variables which may relate to this test. */ for (i = 0; environ[i] != NULL; ++i) - if (strncmp (environ[i], "LIBGUESTFS_", 11) == 0) + if (STREQLEN (environ[i], "LIBGUESTFS_", 11)) printf ("%s\n", environ[i]); /* Create the handle and configure it. */ |