main (int argc, char *argv[])
{
if (argc > 1) {
- if (strcmp (argv[1], "1") == 0) {
+ if (STREQ (argv[1], "1")) {
printf ("Result1");
- } else if (strcmp (argv[1], "2") == 0) {
+ } else if (STREQ (argv[1], "2")) {
printf ("Result2\n");
- } else if (strcmp (argv[1], "3") == 0) {
+ } else if (STREQ (argv[1], "3")) {
printf ("\nResult3");
- } else if (strcmp (argv[1], "4") == 0) {
+ } else if (STREQ (argv[1], "4")) {
printf ("\nResult4\n");
- } else if (strcmp (argv[1], "5") == 0) {
+ } else if (STREQ (argv[1], "5")) {
printf ("\nResult5\n\n");
- } else if (strcmp (argv[1], "6") == 0) {
+ } else if (STREQ (argv[1], "6")) {
printf ("\n\nResult6\n\n");
- } else if (strcmp (argv[1], "7") == 0) {
+ } else if (STREQ (argv[1], "7")) {
/* nothing */
- } else if (strcmp (argv[1], "8") == 0) {
+ } else if (STREQ (argv[1], "8")) {
printf ("\n");
- } else if (strcmp (argv[1], "9") == 0) {
+ } else if (STREQ (argv[1], "9")) {
printf ("\n\n");
- } else if (strcmp (argv[1], "10") == 0) {
+ } else if (STREQ (argv[1], "10")) {
printf ("Result10-1\nResult10-2\n");
- } else if (strcmp (argv[1], "11") == 0) {
+ } else if (STREQ (argv[1], "11")) {
printf ("Result11-1\nResult11-2");
} else {
fprintf (stderr, "unknown parameter: %s\n", argv[1]);
}
while ((d = readdir (dir)) != NULL) {
- if (strcmp (d->d_name, ".") == 0 || strcmp (d->d_name, "..") == 0)
+ if (STREQ (d->d_name, ".") || STREQ (d->d_name, ".."))
continue;
snprintf (fname, sizeof fname, "/proc/self/fd/%s", d->d_name);
int r;
char *buf, *err;
- if (strcmp (path, "/") == 0) {
+ if (STREQ (path, "/")) {
reply_with_error ("rm -rf: cannot remove root directory");
return -1;
}
free (out);
return NULL;
}
- if (strcmp (colon, "<none>") == 0 ||
- strcmp (colon, "<not available>") == 0 ||
- strcmp (colon, "(none)") == 0) {
+ if (STREQ (colon, "<none>") ||
+ STREQ (colon, "<not available>") ||
+ STREQ (colon, "(none)")) {
if (add_string (&ret, &size, &alloc, "") == -1) {
free (out);
return NULL;
FILE *fp;
char line[256];
- if (strcmp (method, "gzip") == 0 || strcmp (method, "compress") == 0)
+ if (STREQ (method, "gzip") || STREQ (method, "compress"))
zcat = "zcat";
- else if (strcmp (method, "bzip2") == 0)
+ else if (STREQ (method, "bzip2"))
zcat = "bzcat";
else {
reply_with_error ("zfile: unknown method");
int size = 0, alloc = 0;
char *p, *pend;
- if (strcmp (str, "") == 0)
+ if (STREQ (str, ""))
goto empty_list;
p = str;
}
while ((d = readdir (dir)) != NULL) {
- if (strcmp (d->d_name, ".") == 0 || strcmp (d->d_name, "..") == 0)
+ if (STREQ (d->d_name, ".") || STREQ (d->d_name, ".."))
continue;
if (add_string (&r, &size, &alloc, d->d_name) == -1) {
* to every block and does bad block detection, neither of which
* are useful behaviour for virtual devices.
*/
- if (strcmp (fstype, "ntfs") == 0)
+ if (STREQ (fstype, "ntfs"))
argv[i++] = "-Q";
/* mkfs.reiserfs produces annoying interactive prompts unless you
* tell it to be quiet.
*/
- if (strcmp (fstype, "reiserfs") == 0)
+ if (STREQ (fstype, "reiserfs"))
argv[i++] = "-f";
/* Same for JFS. */
- if (strcmp (fstype, "jfs") == 0)
+ if (STREQ (fstype, "jfs"))
argv[i++] = "-f";
/* For GFS, GFS2, assume a single node. */
- if (strcmp (fstype, "gfs") == 0 || strcmp (fstype, "gfs2") == 0) {
+ if (STREQ (fstype, "gfs") || STREQ (fstype, "gfs2")) {
argv[i++] = "-p";
argv[i++] = "lock_nolock";
/* The man page says this is default, but it doesn't seem to be: */
ABS_PATH (mountpoint, return -1);
- is_root = strcmp (mountpoint, "/") == 0;
+ is_root = STREQ (mountpoint, "/");
if (!root_mounted && !is_root) {
reply_with_error ("mount: you must mount something on / first");
fprintf (stderr, " %zu: special attrval = %s\n",
k, entry[0].attrval.attrval_val);
for (i = 1; k+i < ret->guestfs_int_xattr_list_len; ++i) {
- if (strcmp (entry[i].attrname, "") == 0)
+ if (STREQ (entry[i].attrname, ""))
break;
fprintf (stderr, " name %s, value length %d\n",
entry[i].attrname, entry[i].attrval.attrval_len);
CALL (what = guestfs_file (g, dev), NULL);
- if (strcmp (what, "x86 boot sector") == 0)
+ if (STREQ (what, "x86 boot sector"))
/* This is what 'file' program shows for Windows/NTFS partitions. */
printf ("<windows/>\n");
else if (strstr (what, "boot sector") != NULL)
/* Just pick out a few important fields to display. There
* is much more that could be displayed here.
*/
- if (strcmp (sbfields[i], "Filesystem UUID") == 0)
+ if (STREQ (sbfields[i], "Filesystem UUID"))
printf ("<uuid>%s</uuid>\n", sbfields[i+1]);
- else if (strcmp (sbfields[i], "Block size") == 0)
+ else if (STREQ (sbfields[i], "Block size"))
printf ("<blocksize>%s</blocksize>\n", sbfields[i+1]);
free (sbfields[i]);
if (strcmp (dirents->val[i].name, ".") != 0 &&
strcmp (dirents->val[i].name, "..") != 0) {
- if (strcmp (dir, "/") == 0)
+ if (STREQ (dir, "/"))
err = asprintf (&p, "/%s", dirents->val[i].name);
else
err = asprintf (&p, "%s/%s", dir, dirents->val[i].name);
switch (c) {
case 0: /* options which are long only */
- if (strcmp (long_options[option_index].name, "listen") == 0)
+ if (STREQ (long_options[option_index].name, "listen"))
remote_control_listen = 1;
- else if (strcmp (long_options[option_index].name, "remote") == 0) {
+ else if (STREQ (long_options[option_index].name, "remote")) {
if (optarg) {
if (sscanf (optarg, "%d", &remote_control) != 1) {
fprintf (stderr, _("%s: --listen=PID: PID was not a number: %s\n"),
exit (1);
}
}
- } else if (strcmp (long_options[option_index].name, "selinux") == 0) {
+ } else if (STREQ (long_options[option_index].name, "selinux")) {
guestfs_set_selinux (g, 1);
} else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
if (optind >= argc) return;
cmd = argv[optind++];
- if (strcmp (cmd, ":") == 0) {
+ if (STREQ (cmd, ":")) {
fprintf (stderr, _("%s: empty command on command line\n"), program_name);
exit (1);
}
{
struct lsc_entry const *a = x;
struct lsc_entry const *b = y;
- return strcmp (a->pathname, b->pathname) == 0;
+ return STREQ (a->pathname, b->pathname);
}
static void
free (entry);
return -1;
}
- if (strcmp (path, "/") == 0)
+ if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
free (entry);
return -1;
}
- if (strcmp (path, "/") == 0)
+ if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
free (entry);
return -1;
}
- if (strcmp (path, "/") == 0)
+ if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
size_t i;
int r = -ENOATTR;
for (i = 0; i < xattrs->len; ++i) {
- if (strcmp (xattrs->val[i].attrname, name) == 0) {
+ if (STREQ (xattrs->val[i].attrname, name)) {
size_t sz = xattrs->val[i].attrval_len;
if (sz > size)
sz = size;
switch (c) {
case 0: /* options which are long only */
- if (strcmp (long_options[option_index].name, "dir-cache-timeout") == 0)
+ if (STREQ (long_options[option_index].name, "dir-cache-timeout"))
dir_cache_timeout = atoi (optarg);
- else if (strcmp (long_options[option_index].name, "fuse-help") == 0)
+ else if (STREQ (long_options[option_index].name, "fuse-help"))
fuse_help ();
- else if (strcmp (long_options[option_index].name, "selinux") == 0)
+ else if (STREQ (long_options[option_index].name, "selinux"))
guestfs_set_selinux (g, 1);
- else if (strcmp (long_options[option_index].name, "trace") == 0) {
+ else if (STREQ (long_options[option_index].name, "trace")) {
ADD_FUSE_ARG ("-f");
guestfs_set_trace (g, 1);
guestfs_set_recovery_proc (g, 1);
h->msglvl = flags & HIVEX_OPEN_MSGLVL_MASK;
const char *debug = getenv ("HIVEX_DEBUG");
- if (debug && strcmp (debug, "1") == 0)
+ if (debug && STREQ (debug, "1"))
h->msglvl = 2;
if (h->msglvl >= 2)
if (str)
return strstr (str, \"%s\") == NULL;
str = getenv (\"SKIP_%s\");
- if (str && strcmp (str, \"1\") == 0) return 1;
+ if (str && STREQ (str, \"1\")) return 1;
str = getenv (\"SKIP_TEST_%s\");
- if (str && strcmp (str, \"1\") == 0) return 1;
+ if (str && STREQ (str, \"1\")) return 1;
return 0;
}
pr " sscanf (val, \"%%\" SCNi64, &r);\n";
pr " return r;\n"
| RBool _ ->
- pr " return strcmp (val, \"true\") == 0;\n"
+ pr " return STREQ (val, \"true\");\n"
| RConstString _
| RConstOptString _ ->
(* Can't return the input string here. Return a static
g->recovery_proc = 1;
str = getenv ("LIBGUESTFS_DEBUG");
- g->verbose = str != NULL && strcmp (str, "1") == 0;
+ g->verbose = str != NULL && STREQ (str, "1");
str = getenv ("LIBGUESTFS_TRACE");
- g->trace = str != NULL && strcmp (str, "1") == 0;
+ g->trace = str != NULL && STREQ (str, "1");
str = getenv ("LIBGUESTFS_PATH");
g->path = str != NULL ? strdup (str) : strdup (GUESTFS_DEFAULT_PATH);
/* A bit fascist, but the user will probably break the extra
* parameters that we add if they try to set any of these.
*/
- if (strcmp (qemu_param, "-kernel") == 0 ||
- strcmp (qemu_param, "-initrd") == 0 ||
- strcmp (qemu_param, "-nographic") == 0 ||
- strcmp (qemu_param, "-serial") == 0 ||
- strcmp (qemu_param, "-full-screen") == 0 ||
- strcmp (qemu_param, "-std-vga") == 0 ||
- strcmp (qemu_param, "-vnc") == 0) {
+ if (STREQ (qemu_param, "-kernel") ||
+ STREQ (qemu_param, "-initrd") ||
+ STREQ (qemu_param, "-nographic") ||
+ STREQ (qemu_param, "-serial") ||
+ STREQ (qemu_param, "-full-screen") ||
+ STREQ (qemu_param, "-std-vga") ||
+ STREQ (qemu_param, "-vnc")) {
error (g, _("guestfs_config: parameter '%s' isn't allowed"), qemu_param);
return -1;
}
switch (c) {
case 0: /* options which are long only */
- if (strcmp (long_options[option_index].name, "helper") == 0)
+ if (STREQ (long_options[option_index].name, "helper"))
helper = optarg;
- else if (strcmp (long_options[option_index].name, "qemu") == 0)
+ else if (STREQ (long_options[option_index].name, "qemu"))
set_qemu (optarg, 0);
- else if (strcmp (long_options[option_index].name, "qemudir") == 0)
+ else if (STREQ (long_options[option_index].name, "qemudir"))
set_qemu (optarg, 1);
else {
fprintf (stderr,