瀏覽代碼

Merge pull request #6934 from ThomasWaldmann/fix-warnings-master

Fix warnings (master)
TW 2 年之前
父節點
當前提交
99c72c5f75
共有 4 個文件被更改,包括 36 次插入6 次删除
  1. 6 4
      src/borg/_chunker.c
  2. 23 0
      src/borg/cache_sync/__init__.py
  3. 5 0
      src/borg/cache_sync/unpack.h
  4. 2 2
      src/borg/hashindex.pyx

+ 6 - 4
src/borg/_chunker.c

@@ -154,8 +154,6 @@ static int
 chunker_fill(Chunker *c)
 {
     ssize_t n;
-    off_t offset, length;
-    int overshoot;
     PyObject *data;
     PyThreadState *thread_state;
 
@@ -169,7 +167,10 @@ chunker_fill(Chunker *c)
     if(c->fh >= 0) {
         thread_state = PyEval_SaveThread();
 
-        offset = c->bytes_read;
+        #if ( ( _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L ) && defined(POSIX_FADV_DONTNEED) )
+        off_t offset = c->bytes_read;
+        #endif
+
         // if we have a os-level file descriptor, use os-level API
         n = read(c->fh, c->data + c->position + c->remaining, n);
         if(n > 0) {
@@ -186,8 +187,8 @@ chunker_fill(Chunker *c)
             PyErr_SetFromErrno(PyExc_OSError);
             return 0;
         }
-        length = c->bytes_read - offset;
         #if ( ( _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L ) && defined(POSIX_FADV_DONTNEED) )
+        off_t length = c->bytes_read - offset;
 
         // Only do it once per run.
         if (pagemask == 0)
@@ -200,6 +201,7 @@ chunker_fill(Chunker *c)
         // for the OS or other processes.
         // We rollback the initial offset back to the start of the page,
         // to avoid it not being truncated as a partial page request.
+        int overshoot;
         if (length > 0) {
             // All Linux kernels (at least up to and including 4.6(.0)) have a bug where
             // they truncate last partial page of POSIX_FADV_DONTNEED request, so we need

+ 23 - 0
src/borg/cache_sync/__init__.py

@@ -0,0 +1,23 @@
+"""
+dummy package init file to suppress this weird setuptools warning:
+
+$ pip install -v .  # note: does not happen with -ve .
+
+############################
+# Package would be ignored #
+############################
+Python recognizes 'borg.cache_sync' as an importable package,
+but it is not listed in the `packages` configuration of setuptools.
+
+'borg.cache_sync' has been automatically added to the distribution only
+because it may contain data files, but this behavior is likely to change
+in future versions of setuptools (and therefore is considered deprecated).
+
+Please make sure that 'borg.cache_sync' is included as a package by using
+the `packages` configuration field or the proper discovery methods
+(for example by using `find_namespace_packages(...)`/`find_namespace:`
+instead of `find_packages(...)`/`find:`).
+
+You can read more about "package discovery" and "data files" on setuptools
+documentation page.
+"""

+ 5 - 0
src/borg/cache_sync/unpack.h

@@ -388,6 +388,11 @@ static inline int unpack_callback_raw(unpack_user* u, const char* b, const char*
             u->expect = expect_map_item_end;
         }
         break;
+    default:
+        if(u->inside_chunks) {
+            SET_LAST_ERROR("Unexpected raw in chunks structure");
+            return -1;
+        }
     }
     return 0;
 }

+ 2 - 2
src/borg/hashindex.pyx

@@ -278,8 +278,8 @@ cdef class NSKeyIterator:
     cdef const unsigned char *key
     cdef int key_size
     cdef int exhausted
-    cdef int flag_mask
-    cdef int flag_value
+    cdef unsigned int flag_mask
+    cdef unsigned int flag_value
 
     def __cinit__(self, key_size, mask, value):
         self.key = NULL