Found by using gcc 4.7.0's -Wsuggest-attribute=pure. * src/m4.h (M4_GNUC_PURE): New macro. * src/m4.c (fault_handler): Mark pure. * src/builtin.c (find_builtin_by_addr, find_builtin_by_name): Likewise. * src/symtab.c (hash): Likewise.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- ChangeLog | 9 +++++++++ src/builtin.c | 4 ++-- src/m4.c | 2 +- src/m4.h | 1 + src/symtab.c | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d2400a..30b444b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-09-04 Eric Blake <ebl...@redhat.com> + + build: mark several pure functions + * src/m4.h (M4_GNUC_PURE): New macro. + * src/m4.c (fault_handler): Mark pure. + * src/builtin.c (find_builtin_by_addr, find_builtin_by_name): + Likewise. + * src/symtab.c (hash): Likewise. + 2012-09-01 Eric Blake <ebl...@redhat.com> build: silence gcc warning diff --git a/src/builtin.c b/src/builtin.c index d8c9bd5..5ff443e 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -173,7 +173,7 @@ static predefined const predefined_tab[] = | Find the builtin, which lives on ADDR. | `----------------------------------------*/ -const builtin * +const builtin * M4_GNUC_PURE find_builtin_by_addr (builtin_func *func) { const builtin *bp; @@ -191,7 +191,7 @@ find_builtin_by_addr (builtin_func *func) | placeholder builtin. | `----------------------------------------------------------*/ -const builtin * +const builtin * M4_GNUC_PURE find_builtin_by_name (const char *name) { const builtin *bp; diff --git a/src/m4.c b/src/m4.c index d4c2681..3666a65 100644 --- a/src/m4.c +++ b/src/m4.c @@ -140,7 +140,7 @@ static const char * volatile signal_message[NSIG]; must be aysnc-signal safe, since it is executed as a signal handler. If SIGNO is zero, this represents a stack overflow; in that case, we return to allow c_stack_action to handle things. */ -static void +static void M4_GNUC_PURE fault_handler (int signo) { if (signo) diff --git a/src/m4.h b/src/m4.h index a8d96ea..c23e448 100644 --- a/src/m4.h +++ b/src/m4.h @@ -118,6 +118,7 @@ typedef unsigned int bool_bitfield; #define M4_GNUC_PRINTF(fmt, arg) \ M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg))) #define M4_GNUC_NORETURN M4_GNUC_ATTRIBUTE ((__noreturn__)) +#define M4_GNUC_PURE M4_GNUC_ATTRIBUTE ((__pure__)) /* File: m4.c --- global definitions. */ diff --git a/src/symtab.c b/src/symtab.c index eeec2cf..ba2afe3 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -120,7 +120,7 @@ symtab_init (void) | Return a hashvalue for a string, from GNU-emacs. | `--------------------------------------------------*/ -static size_t +static size_t M4_GNUC_PURE hash (const char *s) { register size_t val = 0; -- 1.7.11.4 _______________________________________________ M4-patches mailing list M4-patches@gnu.org https://lists.gnu.org/mailman/listinfo/m4-patches