})
-// At the moment any code that calls INTEGER_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))
-
+#define INTEGER_TO_PY(x) \
+ ({ \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
+ _Pragma("clang diagnostic push"); \
+ _Pragma("clang diagnostic ignored \"-Wtautological-compare\""); \
+ PyObject *result = ((x) >= 0) ? PyLong_FromUnsignedLongLong(x) : PyLong_FromLongLong(x); \
+ _Pragma("clang diagnostic pop"); \
+ _Pragma("GCC diagnostic pop"); \
+ result; \
+ })
#if PY_MAJOR_VERSION < 3
PyObject *part;
unsigned int total = 0;
uint32_t count;
- int i, j, ofs64_count;
+ int i;
uint32_t *fan_ptr, *crc_ptr, *ofs_ptr;
uint64_t *ofs64_ptr;
struct sha *sha_ptr;
ofs64_ptr = (uint64_t *)&ofs_ptr[total];
count = 0;
- ofs64_count = 0;
+ uint32_t ofs64_count = 0;
for (i = 0; i < FAN_ENTRIES; ++i)
{
- Py_ssize_t plen;
part = PyList_GET_ITEM(idx, i);
PyList_Sort(part);
- plen = PyList_GET_SIZE(part);
- if (plen > UINT32_MAX || UINT32_MAX - count < plen) {
+ uint32_t plen;
+ if (!INTEGRAL_ASSIGNMENT_FITS(&plen, PyList_GET_SIZE(part))
+ || UINT32_MAX - count < plen) {
PyErr_Format(PyExc_OverflowError, "too many objects in index part");
goto clean_and_return;
}
- count += (uint32_t) plen;
+ count += plen;
*fan_ptr++ = htonl(count);
+ uint32_t j;
for (j = 0; j < plen; ++j)
{
unsigned char *sha = NULL;
#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)
(long) BUP_STAT_CTIME_NS(st));
}
-#pragma clang diagnostic pop // ignored "-Wtautological-compare"
static PyObject *bup_stat(PyObject *self, PyObject *args)
{
}
char *e;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wtautological-compare" // For INTEGER_TO_PY().
{
PyObject *value;
value = INTEGER_TO_PY(INT_MAX);
Py_DECREF(value);
}
#endif
-#pragma clang diagnostic pop // ignored "-Wtautological-compare"
e = getenv("BUP_FORCE_TTY");
get_state(m)->istty2 = isatty(2) || (atoi(e ? e : "0") & 2);