bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] ensure that return value of uinttostr et al are not ignored


From: Jim Meyering
Subject: [PATCH] ensure that return value of uinttostr et al are not ignored
Date: Sun, 10 Aug 2008 17:16:25 +0200

FYI, if we'd had this sooner, it would have kept
a minor bug out of GNU sort.  I've just pushed this:

>From 493e1981bcdc746dbcd622a17ac65acdedf5762e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 10 Aug 2008 16:40:12 +0200
Subject: [PATCH] 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.
---
 ChangeLog      |    7 +++++++
 lib/inttostr.h |   25 +++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8d92122..91f1106 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-10  Jim Meyering  <address@hidden>
+
+       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  <address@hidden>

        * lib/lock.c (glthread_recursive_lock_init_multithreaded)
diff --git a/lib/inttostr.h b/lib/inttostr.h
index aa5820f..a103caf 100644
--- a/lib/inttostr.h
+++ b/lib/inttostr.h
@@ -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__;
--
1.6.0.rc2.24.g3cd61




reply via email to

[Prev in Thread] Current Thread [Next in Thread]