[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/25] syntax-check: fix violations and re-enable sc_prohibit_str
From: |
Gary V. Vaughan |
Subject: |
[PATCH 16/25] syntax-check: fix violations and re-enable sc_prohibit_strcmp. |
Date: |
Tue, 15 Nov 2011 19:53:54 +0700 |
* cfg.mk (local-checks-to-fix): Remove sc_prohibit_strcmp
from list of disabled checks.
(exclude_file_name_regexp--sc_prohibit_strcmp): Ignore
violations in libtool.texi and any demo C files.
* libltdl/libltdl/lt__private.h (strneq, streq): Renamed from
this...
(STRNEQ, STREQ): ..to this. Adjust all callers.
* tests/slist.at: Add STREQ definition. Change all !strcmp calls
to STREQ.
* libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): Add
and use STREQ definition.
Signed-off-by: Gary V. Vaughan <address@hidden>
---
build-aux/ltmain.m4sh | 10 ++++++----
cfg.mk | 3 ++-
libltdl/libgnu/.gitignore | 2 --
libltdl/libltdl/lt__private.h | 4 ++--
libltdl/loaders/preopen.c | 10 +++++-----
libltdl/lt_dlloader.c | 2 +-
libltdl/ltdl.c | 16 ++++++++--------
tests/slist.at | 18 ++++++++++--------
8 files changed, 34 insertions(+), 31 deletions(-)
delete mode 100644 libltdl/libgnu/.gitignore
diff --git a/build-aux/ltmain.m4sh b/build-aux/ltmain.m4sh
index 57e4d06..128d552 100644
--- a/build-aux/ltmain.m4sh
+++ b/build-aux/ltmain.m4sh
@@ -3424,6 +3424,8 @@ EOF
#include <fcntl.h>
#include <sys/stat.h>
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
/* declarations of non-ANSI functions */
#if defined(__MINGW32__)
# ifdef __STRICT_ANSI__
@@ -3615,7 +3617,7 @@ main (int argc, char *argv[])
newargc=0;
for (i = 1; i < argc; i++)
{
- if (strcmp (argv[i], dumpscript_opt) == 0)
+ if (STREQ (argv[i], dumpscript_opt))
{
EOF
case "$host" in
@@ -3629,12 +3631,12 @@ EOF
lt_dump_script (stdout);
return 0;
}
- if (strcmp (argv[i], debug_opt) == 0)
+ if (STREQ (argv[i], debug_opt))
{
lt_debug = 1;
continue;
}
- if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+ if (STREQ (argv[i], ltwrapper_option_prefix))
{
/* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
namespace, but it is not one of the ones we know about and
@@ -4037,7 +4039,7 @@ strendzap (char *str, const char *pat)
if (patlen <= len)
{
str += len - patlen;
- if (strcmp (str, pat) == 0)
+ if (STREQ (str, pat))
*str = '\0';
}
return str;
diff --git a/cfg.mk b/cfg.mk
index d4ddf9c..f804693 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -40,7 +40,6 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX = ^mail/
local-checks-to-fix = \
sc_prohibit_always-defined_macros \
sc_prohibit_always_true_header_tests \
- sc_prohibit_strcmp \
sc_prohibit_test_minus_ao \
sc_prohibit_undesirable_word_seq \
sc_require_config_h \
@@ -64,3 +63,5 @@ local-checks-to-skip = \
# List syntax-check exempted files.
exclude_file_name_regexp--sc_error_message_uppercase = \
^$(_build-aux)/cvsu$$
+exclude_file_name_regexp--sc_prohibit_strcmp = \
+ ^(doc/libtool.texi|tests/.*demo/.*\.c)$$
diff --git a/libltdl/libgnu/.gitignore b/libltdl/libgnu/.gitignore
deleted file mode 100644
index d9f5394..0000000
--- a/libltdl/libgnu/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/Makefile.am
-/dummy.c
diff --git a/libltdl/libltdl/lt__private.h b/libltdl/libltdl/lt__private.h
index f4c4a3d..3b2609b 100644
--- a/libltdl/libltdl/lt__private.h
+++ b/libltdl/libltdl/lt__private.h
@@ -94,8 +94,8 @@ LT_SCOPE void lt__alloc_die_callback (void);
/* For readability: */
-#define strneq(s1, s2) (strcmp((s1), (s2)) != 0)
-#define streq(s1, s2) (!strcmp((s1), (s2)))
+#define STRNEQ(s1, s2) (strcmp((s1), (s2)) != 0)
+#define STREQ(s1, s2) (strcmp((s1), (s2)) == 0)
diff --git a/libltdl/loaders/preopen.c b/libltdl/loaders/preopen.c
index 48ad51c..7e8bf31 100644
--- a/libltdl/loaders/preopen.c
+++ b/libltdl/loaders/preopen.c
@@ -168,7 +168,7 @@ vm_open (lt_user_data LT__UNUSED loader_data, const char
*filename,
const lt_dlsymlist *symbol;
for (symbol= lists->symlist; symbol->name; ++symbol)
{
- if (!symbol->address && streq (symbol->name, filename))
+ if (!symbol->address && STREQ (symbol->name, filename))
{
/* If the next symbol's name and address is 0, it means
the module just contains the originator and no symbols.
@@ -214,7 +214,7 @@ vm_sym (lt_user_data LT__UNUSED loader_data, lt_module
module, const char *name)
while (symbol->name)
{
- if (streq (symbol->name, name))
+ if (STREQ (symbol->name, name))
{
return symbol->address;
}
@@ -335,8 +335,8 @@ lt_dlpreload_open (const char *originator,
lt_dlpreload_callback_func *func)
for (list = preloaded_symlists; list; list = list->next)
{
/* ...that was preloaded by the requesting ORIGINATOR... */
- if ((originator && streq (list->symlist->name, originator))
- || (!originator && streq (list->symlist->name, "@PROGRAM@")))
+ if ((originator && STREQ (list->symlist->name, originator))
+ || (!originator && STREQ (list->symlist->name, "@PROGRAM@")))
{
const lt_dlsymlist *symbol;
unsigned int idx = 0;
@@ -348,7 +348,7 @@ lt_dlpreload_open (const char *originator,
lt_dlpreload_callback_func *func)
while ((symbol = &list->symlist[++idx])->name != 0)
{
if ((symbol->address == 0)
- && (strneq (symbol->name, "@PROGRAM@")))
+ && (STRNEQ (symbol->name, "@PROGRAM@")))
{
lt_dlhandle handle = lt_dlopen (symbol->name);
if (handle == 0)
diff --git a/libltdl/lt_dlloader.c b/libltdl/lt_dlloader.c
index 2c99a22..699a504 100644
--- a/libltdl/lt_dlloader.c
+++ b/libltdl/lt_dlloader.c
@@ -52,7 +52,7 @@ loader_callback (SList *item, void *userdata)
assert (vtable);
- return streq (vtable->name, name) ? (void *) item : NULL;
+ return STREQ (vtable->name, name) ? (void *) item : NULL;
}
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index c11baae..9de6af6 100644
--- a/libltdl/ltdl.c
+++ b/libltdl/ltdl.c
@@ -385,7 +385,7 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename,
{
if ((handle->info.filename == filename) /* dlopen self: 0 == 0 */
|| (handle->info.filename && filename
- && streq (handle->info.filename, filename)))
+ && STREQ (handle->info.filename, filename)))
{
break;
}
@@ -1108,11 +1108,11 @@ parse_dotla_file(FILE *file, char **dlname, char
**libdir, char **deplibs,
{
errors += trim (deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]);
}
- else if (streq (line, "installed=yes\n"))
+ else if (STREQ (line, "installed=yes\n"))
{
*installed = 1;
}
- else if (streq (line, "installed=no\n"))
+ else if (STREQ (line, "installed=no\n"))
{
*installed = 0;
}
@@ -1335,7 +1335,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename,
const char *ext,
}
/* Check whether we are opening a libtool module (.la extension). */
- if (ext && streq (ext, archive_ext))
+ if (ext && STREQ (ext, archive_ext))
{
/* this seems to be a libtool module */
FILE * file = 0;
@@ -1555,12 +1555,12 @@ has_library_ext (const char *filename)
ext = strrchr (filename, '.');
- if (ext && ((streq (ext, archive_ext))
+ if (ext && ((STREQ (ext, archive_ext))
#if defined(LT_MODULE_EXT)
- || (streq (ext, shlib_ext))
+ || (STREQ (ext, shlib_ext))
#endif
#if defined(LT_SHARED_EXT)
- || (streq (ext, shared_ext))
+ || (STREQ (ext, shared_ext))
#endif
))
{
@@ -2446,7 +2446,7 @@ lt_dlhandle_fetch (lt_dlinterface_id iface, const char
*module_name)
while ((handle = lt_dlhandle_iterate (iface, handle)))
{
lt_dlhandle cur = handle;
- if (cur && cur->info.name && streq (cur->info.name, module_name))
+ if (cur && cur->info.name && STREQ (cur->info.name, module_name))
break;
}
diff --git a/tests/slist.at b/tests/slist.at
index 741410c..68907e6 100644
--- a/tests/slist.at
+++ b/tests/slist.at
@@ -31,9 +31,11 @@ AT_DATA([test-slist.c], [[
#include <stdio.h>
#include "slist.h"
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
void *find_string (SList *item, void *data)
{
- if (data != NULL && !strcmp ((const char *) item->userdata, (const char
*)data))
+ if (data != NULL && STREQ ((const char *) item->userdata, (const char
*)data))
return item;
else
return NULL;
@@ -83,10 +85,10 @@ int main ()
assert (slist_find (list, find_string, (void *) "foo10") == NULL);
item = (SList *) slist_find (list, find_string, (void *) "foo1");
assert (item != NULL);
- assert (!strcmp ((const char *) item->userdata, "foo1"));
+ assert (STREQ ((const char *) item->userdata, "foo1"));
item = slist_nth (list, 10);
- assert (item != NULL && !strcmp ((const char *) item->userdata, "foo0"));
+ assert (item != NULL && STREQ ((const char *) item->userdata, "foo0"));
puts ("list as inserted:");
slist_foreach (list, print_item, NULL);
@@ -95,13 +97,13 @@ int main ()
slist_foreach (list, print_item, NULL);
item = slist_nth (list, 1);
- assert (item != NULL && !strcmp ((const char *) item->userdata, "foo0"));
+ assert (item != NULL && STREQ ((const char *) item->userdata, "foo0"));
assert (10 == slist_length (list));
/* slist_tail is the second item, not the last one */
item = slist_tail (list);
- assert (item != NULL && !strcmp ((const char *) item->userdata, "foo1"));
+ assert (item != NULL && STREQ ((const char *) item->userdata, "foo1"));
assert (slist_tail (slist_nth (list, 10)) == NULL);
@@ -131,19 +133,19 @@ int main ()
list_save = list;
item = slist_remove (&list, find_string, (void *) "foo5");
assert (list_save == list);
- assert (item != NULL && !strcmp (data = (char *) slist_unbox (item),
"foo5"));
+ assert (item != NULL && STREQ (data = (char *) slist_unbox (item), "foo5"));
free (data);
list_save = list;
item = slist_remove (&list, find_string, (void *) "foo9");
assert (list_save == list);
- assert (item != NULL && !strcmp (data = (char *) slist_unbox (item),
"foo9"));
+ assert (item != NULL && STREQ (data = (char *) slist_unbox (item), "foo9"));
free (data);
list_save = list;
item = slist_remove (&list, find_string, (void *) "foo0");
assert (list_save != list);
- assert (item != NULL && !strcmp (data = (char *) slist_unbox (item),
"foo0"));
+ assert (item != NULL && STREQ (data = (char *) slist_unbox (item), "foo0"));
free (data);
list_save = list;
--
1.7.7.3
Cheers,
--
Gary V. Vaughan (gary AT gnu DOT org)
- Re: [PATCH 09/25] syntax-check: fix violations and re-enable sc_makefile_at_at_check., (continued)
[PATCH 11/25] syntax-check: fix violations and re-enable sc_prohibit_doubled_word., Gary V. Vaughan, 2011/11/15
[PATCH 12/25] syntax-check: fix violations and re-enable sc_prohibit_empty_lines_at_EOF., Gary V. Vaughan, 2011/11/15
[PATCH 13/25] syntax-check: fix violations and re-enable sc_prohibit_have_config_h., Gary V. Vaughan, 2011/11/15
[PATCH 14/25] syntax-check: fix violations and re-enable sc_prohibit_magic_number_exit., Gary V. Vaughan, 2011/11/15
[PATCH 15/25] syntax-check: fix violations and re-enable sc_prohibit_stddef_without_use., Gary V. Vaughan, 2011/11/15
[PATCH 17/25] syntax-check: fix violations and re-enable sc_probibit_test_minus_ao., Gary V. Vaughan, 2011/11/15
[PATCH 16/25] syntax-check: fix violations and re-enable sc_prohibit_strcmp.,
Gary V. Vaughan <=
[PATCH 18/25] syntax-check: fix violations and re-enable sc_prohibit_undesirable_word_seq., Gary V. Vaughan, 2011/11/15
[PATCH 20/25] syntax-check: fix violations and re-enable sc_useless_cpp_parens., Gary V. Vaughan, 2011/11/15
[PATCH 19/25] syntax-check: fix violations and re-enable sc_space_tab., Gary V. Vaughan, 2011/11/15
[PATCH 22/25] syntax-check: enable sc_bindtextdomain., Gary V. Vaughan, 2011/11/15
[PATCH 23/25] syntax-check: enable sc_program_name., Gary V. Vaughan, 2011/11/15