From 539bf7e8983c53c4cf79ffa64302bef1585bec31 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 9 Nov 2009 15:03:01 +0100 Subject: [PATCH] use STREQ, not strcmp: part 2 git grep -l 'strcmp *([^=]*!= *0'|xargs \ perl -pi -e 's/\bstrcmp( *\(.*?\)) *!= *0\b/STRNEQ$1/g' --- daemon/xattr.c | 2 +- fish/destpaths.c | 4 ++-- fish/fish.c | 2 +- fish/rc.c | 2 +- src/generator.ml | 16 ++++++++-------- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/daemon/xattr.c b/daemon/xattr.c index 926baf0..c218dea 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -403,7 +403,7 @@ do_lxattrlist (const char *path, char *const *names) fprintf (stderr, "lxattrlist: returning: [\n"); for (k = 0; k < ret->guestfs_int_xattr_list_len; ++k) { const guestfs_int_xattr *entry = &ret->guestfs_int_xattr_list_val[k]; - if (strcmp (entry[0].attrname, "") != 0) { + if (STRNEQ (entry[0].attrname, "")) { fprintf (stderr, "ERROR: expecting empty attrname at k = %zu\n", k); break; } diff --git a/fish/destpaths.c b/fish/destpaths.c index 02e9f22..87287aa 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -166,8 +166,8 @@ complete_dest_paths_generator (const char *text, int state) for (i = 0; i < dirents->len; ++i) { int err; - if (strcmp (dirents->val[i].name, ".") != 0 && - strcmp (dirents->val[i].name, "..") != 0) { + if (STRNEQ (dirents->val[i].name, ".") && + STRNEQ (dirents->val[i].name, "..")) { if (STREQ (dir, "/")) err = asprintf (&p, "/%s", dirents->val[i].name); else diff --git a/fish/fish.c b/fish/fish.c index 869366b..cd10296 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -762,7 +762,7 @@ cmdline (char *argv[], int optind, int argc) params = &argv[optind]; /* Search for end of command list or ":" ... */ - while (optind < argc && strcmp (argv[optind], ":") != 0) + while (optind < argc && STRNEQ (argv[optind], ":")) optind++; if (optind == argc) { diff --git a/fish/rc.c b/fish/rc.c index 182c4f4..a9eb578 100644 --- a/fish/rc.c +++ b/fish/rc.c @@ -250,7 +250,7 @@ rc_listen (void) goto error; } - if (strcmp (hello.vers, PACKAGE_VERSION) != 0) { + if (STRNEQ (hello.vers, PACKAGE_VERSION)) { fprintf (stderr, _("guestfish: protocol error: version mismatch, server version '%s' does not match client version '%s'. The two versions must match exactly.\n"), PACKAGE_VERSION, hello.vers); diff --git a/src/generator.ml b/src/generator.ml index 917fea9..3c1ff2b 100644 --- a/src/generator.ml +++ b/src/generator.ml @@ -6001,7 +6001,7 @@ and generate_one_test_body name i test_name init test = pr " const char *expected = \"%s\";\n" (c_quote expected); let seq, last = get_seq_last seq in let test () = - pr " if (strcmp (r, expected) != 0) {\n"; + pr " if (STRNEQ (r, expected)) {\n"; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name; pr " return -1;\n"; pr " }\n" @@ -6021,7 +6021,7 @@ and generate_one_test_body name i test_name init test = pr " }\n"; pr " {\n"; pr " const char *expected = \"%s\";\n" (c_quote str); - pr " if (strcmp (r[%d], expected) != 0) {\n" i; + pr " if (STRNEQ (r[%d], expected)) {\n" i; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i; pr " return -1;\n"; pr " }\n"; @@ -6050,7 +6050,7 @@ and generate_one_test_body name i test_name init test = pr " {\n"; pr " const char *expected = \"%s\";\n" (c_quote str); pr " r[%d][5] = 's';\n" i; - pr " if (strcmp (r[%d], expected) != 0) {\n" i; + pr " if (STRNEQ (r[%d], expected)) {\n" i; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i; pr " return -1;\n"; pr " }\n"; @@ -6174,7 +6174,7 @@ and generate_one_test_body name i test_name init test = pr " return -1;\n"; pr " }\n" | CompareWithString (field, expected) -> - pr " if (strcmp (r->%s, \"%s\") != 0) {\n" field expected; + pr " if (STRNEQ (r->%s, \"%s\")) {\n" field expected; pr " fprintf (stderr, \"%s: %s was \"%%s\", expected \"%s\"\\n\",\n" test_name field expected; pr " r->%s);\n" field; @@ -6188,7 +6188,7 @@ and generate_one_test_body name i test_name init test = pr " return -1;\n"; pr " }\n" | CompareFieldsStrEq (field1, field2) -> - pr " if (strcmp (r->%s, r->%s) != 0) {\n" field1 field2; + pr " if (STRNEQ (r->%s, r->%s)) {\n" field1 field2; pr " fprintf (stderr, \"%s: %s (\"%%s\") <> %s (\"%%s\")\\n\",\n" test_name field1 field2; pr " r->%s, r->%s);\n" field1 field2; @@ -6587,13 +6587,13 @@ and generate_fish_cmds () = pr " %s = resolve_win_path (argv[%d]);\n" name i; pr " if (%s == NULL) return -1;\n" name | OptString name -> - pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] : NULL;\n" + pr " %s = STRNEQ (argv[%d], \"\") ? argv[%d] : NULL;\n" name i i | FileIn name -> - pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] : \"/dev/stdin\";\n" + pr " %s = STRNEQ (argv[%d], \"-\") ? argv[%d] : \"/dev/stdin\";\n" name i i | FileOut name -> - pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] : \"/dev/stdout\";\n" + pr " %s = STRNEQ (argv[%d], \"-\") ? argv[%d] : \"/dev/stdout\";\n" name i i | StringList name | DeviceList name -> pr " %s = parse_string_list (argv[%d]);\n" name i; -- 1.8.3.1