]> arthur.barton.de Git - bup.git/commitdiff
Disable -Wtautological-compare for INTEGER_TO_PY() calls for clang.
authorRob Browning <rlb@defaultvalue.org>
Tue, 18 Mar 2014 16:19:41 +0000 (11:19 -0500)
committerRob Browning <rlb@defaultvalue.org>
Tue, 18 Mar 2014 16:19:44 +0000 (11:19 -0500)
Without this, INTEGER_TO_PY() produces clang errrors like this on some
platforms:

  _helpers.c:1019:41: error: comparison of unsigned expression >= 0 is always true
  [-Werror,-Wtautological-compare]
                           (((st->st_uid) >= 0) ? PyLong_FromUnsignedLongLong(st->st_uid) :
  PyLong_FromLongLong(st->st_uid)),
                             ~~~~~~~~~~~~ ^  ~

Thanks to Greg Troxel <gdt@lexort.com> for the report.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
lib/bup/_helpers.c

index 311663c774e1f008dce4884da0e6161e6928f19c..d8b19b55c8d00dfb3be3a94a77a8e3f38798e54a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 OS:=$(shell uname | sed 's/[-_].*//')
-CFLAGS := -Wall -O2 -Werror $(PYINCLUDE) $(CFLAGS)
+CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS)
 SOEXT:=.so
 
 ifeq ($(OS),CYGWIN)
index 6e93e35275bed693d372cb0f4f2c0a2d718bd38e..2af13bb27d595e17aa5786cf18b96e0a2f049d10 100644 (file)
@@ -46,6 +46,8 @@
 
 static int istty2 = 0;
 
+// At the moment any code that calls INTGER_TO_PY() will have to
+// disable -Wtautological-compare for clang.  See below.
 
 #define INTEGER_TO_PY(x) \
     (((x) >= 0) ? PyLong_FromUnsignedLongLong(x) : PyLong_FromLongLong(x))
@@ -1065,6 +1067,9 @@ static PyObject *bup_lutimes(PyObject *self, PyObject *args)
 #endif
 
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare" // For INTEGER_TO_PY().
+
 static PyObject *stat_struct_to_py(const struct stat *st,
                                    const char *filename,
                                    int fd)
@@ -1090,6 +1095,7 @@ static PyObject *stat_struct_to_py(const struct stat *st,
                          (long) BUP_STAT_CTIME_NS(st));
 }
 
+#pragma clang diagnostic pop  // ignored "-Wtautological-compare"
 
 static PyObject *bup_stat(PyObject *self, PyObject *args)
 {
@@ -1217,6 +1223,8 @@ PyMODINIT_FUNC init_helpers(void)
         return;
 
 #ifdef HAVE_UTIMENSAT
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare" // For INTEGER_TO_PY().
     {
         PyObject *value;
         value = INTEGER_TO_PY(AT_FDCWD);
@@ -1229,6 +1237,7 @@ PyMODINIT_FUNC init_helpers(void)
         PyObject_SetAttrString(m, "UTIME_NOW", value);
         Py_DECREF(value);
     }
+#pragma clang diagnostic pop  // ignored "-Wtautological-compare"
 #endif
 
     e = getenv("BUP_FORCE_TTY");