On 07/10/2014 07:32 PM, Assaf Gordon wrote: > On 07/10/2014 01:58 PM, Pádraig Brady wrote: >> >> Oh I see now. That was more apparent from your initial patch: >> http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00038.html >> (which I didn't get due to recent GNU mailing list issues). >> >> I'll apply that. > > Regarding the patch I sent, > > I think the "pure" for "string_hash" is solid, > but perhaps extra review is needed for the "const" for > "gl_locale_name_default" to ensure the wrapping macros are correct.
Right. The tag should be on the declaration. I'm going with the attached. Tested with: new_flags='-Werror -Wsuggest-attribute=const -Wsuggest-attribute=pure' ./gnulib-tool --create-testdir --dir test.localename localename cd test.localename ./configure --quiet make AM_CFLAGS="$new_flags" -C gllib cheers, Pádraig.
>From 717e86b43641618787fa1387643a7e8cfa25d1fe Mon Sep 17 00:00:00 2001 From: Assaf Gordon <assafgor...@gmail.com> Date: Thu, 10 Jul 2014 19:42:02 +0100 Subject: [PATCH] localename: avoid -Wsuggest-attribute={const,pure} warnings * lib/localename.c (string_has): Tag internal function as pure. * lib/localename.h (gl_locale_name_default): Tag extern declaration as const when appropriate. --- ChangeLog | 7 +++++++ lib/localename.c | 2 +- lib/localename.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a70340a..401661a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-07-10 Assaf Gordon <assafgor...@gmail.com> + + localename: avoid -Wsuggest-attribute={const,pure} warnings + * lib/localename.c (string_has): Tag internal function as pure. + * lib/localename.h (gl_locale_name_default): Tag extern declaration + as const when appropriate. + 2014-07-09 Andrew D Warshall <warsh...@99main.com> mountlist: do not classify a bind-mounted dir entry as "dummy" diff --git a/lib/localename.c b/lib/localename.c index faf3f92..9b6f67c 100644 --- a/lib/localename.c +++ b/lib/localename.c @@ -2515,7 +2515,7 @@ gl_locale_name_from_win32_LCID (LCID lcid) /* A hash function for NUL-terminated char* strings using the method described by Bruno Haible. See http://www.haible.de/bruno/hashfunc.html. */ -static size_t +static size_t _GL_ATTRIBUTE_PURE string_hash (const void *x) { const char *s = (const char *) x; diff --git a/lib/localename.h b/lib/localename.h index c73dfa8..8a990a6 100644 --- a/lib/localename.h +++ b/lib/localename.h @@ -85,8 +85,11 @@ extern const char * gl_locale_name_environ (int category, const char *categoryna not require such a facility." The result must not be freed; it is statically allocated. */ -extern const char * gl_locale_name_default (void); - +extern const char * gl_locale_name_default (void) +#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined WINDOWS_NATIVE || defined __CYGWIN__) + _GL_ATTRIBUTE_CONST +#endif + ; #ifdef __cplusplus } -- 1.7.7.6