Mercurial > gnulib
changeset 10315:96771d88f037
ensure that return value of uinttostr et al are not ignored
* lib/inttostr.h (__GNUC_PREREQ): Define.
(__attribute_warn_unused_result__): Define.
(offtostr, imaxtostr, umaxtostr, uinttostr): Apply the attribute.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 10 Aug 2008 16:40:12 +0200 |
parents | 6475b70f98b8 |
children | d4e79f8dfb7f |
files | ChangeLog lib/inttostr.h |
diffstat | 2 files changed, 28 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Aug 07 11:27:02 2008 +0200 +++ b/ChangeLog Sun Aug 10 16:40:12 2008 +0200 @@ -1,3 +1,10 @@ +2008-08-10 Jim Meyering <meyering@redhat.com> + + ensure that return value of uinttostr et al are not ignored + * lib/inttostr.h (__GNUC_PREREQ): Define. + (__attribute_warn_unused_result__): Define. + (offtostr, imaxtostr, umaxtostr, uinttostr): Apply the attribute. + 2008-08-07 Paolo Bonzini <bonzini@gnu.org> * lib/lock.c (glthread_recursive_lock_init_multithreaded)
--- a/lib/inttostr.h Thu Aug 07 11:27:02 2008 +0200 +++ b/lib/inttostr.h Sun Aug 10 16:40:12 2008 +0200 @@ -23,7 +23,24 @@ #include "intprops.h" -char *offtostr (off_t, char *); -char *imaxtostr (intmax_t, char *); -char *umaxtostr (uintmax_t, char *); -char *uinttostr (unsigned int, char *); +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif + +#if __GNUC_PREREQ (3,4) +# undef __attribute_warn_unused_result__ +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +#else +# define __attribute_warn_unused_result__ /* empty */ +#endif + +char *offtostr (off_t, char *) __attribute_warn_unused_result__; +char *imaxtostr (intmax_t, char *) __attribute_warn_unused_result__; +char *umaxtostr (uintmax_t, char *) __attribute_warn_unused_result__; +char *uinttostr (unsigned int, char *) __attribute_warn_unused_result__;