]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/_helpers.c
get: adjust for python 3 and test there
[bup.git] / lib / bup / _helpers.c
index 97e4e833d2ea6c44194085343203c0ae6b549092..312ecd4528a1376c7e9ced35e7fe33336b633628 100644 (file)
@@ -129,13 +129,6 @@ static uint64_t htonll(uint64_t value)
 #endif
 
 
-#ifdef __clang__
-#define INTEGRAL_ASSIGNMENT_FITS(dest, src)                             \
-    ({                                                                  \
-        *(dest) = (src);                                                \
-        *(dest) == (src) && (*(dest) < 1) == ((src) < 1);               \
-    })
-#else
 // Disabling sign-compare here should be fine since we're explicitly
 // checking for a sign mismatch, i.e. if the signs don't match, then
 // it doesn't matter what the value comparison says.
@@ -145,10 +138,10 @@ static uint64_t htonll(uint64_t value)
         _Pragma("GCC diagnostic push");                                 \
         _Pragma("GCC diagnostic ignored \"-Wsign-compare\"");           \
         *(dest) = (src);                                                \
-        *(dest) == (src) && (*(dest) < 1) == ((src) < 1);               \
+        int result = *(dest) == (src) && (*(dest) < 1) == ((src) < 1);  \
         _Pragma("GCC diagnostic pop");                                  \
+        result;                                                         \
     })
-#endif
 
 
 // At the moment any code that calls INTEGER_TO_PY() will have to
@@ -497,7 +490,7 @@ static PyObject *bup_write_sparsely(PyObject *self, PyObject *args)
     unsigned char *buf = NULL;
     Py_ssize_t sbuf_len;
     PyObject *py_min_sparse_len, *py_prev_sparse_len;
-    if (!PyArg_ParseTuple(args, "it#OO",
+    if (!PyArg_ParseTuple(args, "i" rbuf_argf "OO",
                           &fd, &buf, &sbuf_len,
                           &py_min_sparse_len, &py_prev_sparse_len))
        return NULL;
@@ -615,7 +608,7 @@ static PyObject *bitmatch(PyObject *self, PyObject *args)
     Py_ssize_t byte;
     int bit;
 
-    if (!PyArg_ParseTuple(args, "t#t#", &buf1, &len1, &buf2, &len2))
+    if (!PyArg_ParseTuple(args, rbuf_argf rbuf_argf, &buf1, &len1, &buf2, &len2))
        return NULL;
     
     bit = 0;
@@ -1171,7 +1164,7 @@ static PyObject *random_sha(PyObject *self, PyObject *args)
     memset(shabuf, 0, sizeof(shabuf));
     for (i=0; i < 20/4; i++)
        shabuf[i] = random();
-    return Py_BuildValue("s#", shabuf, 20);
+    return Py_BuildValue(rbuf_argf, shabuf, 20);
 }
 
 
@@ -1286,7 +1279,7 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args)
     PyObject *py_attr;
     int fd;
 
-    if (!PyArg_ParseTuple(args, "sO", &path, &py_attr))
+    if (!PyArg_ParseTuple(args, cstr_argf "O", &path, &py_attr))
         return NULL;
 
     if (!bup_uint_from_py(&attr, py_attr, "attr"))