From cc7984f4235c04eef31a856992d0c3b67488e5d7 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 10:46:36 +0200 Subject: [PATCH 1/4] _chunker.c: fix warnings on macOS macOS does not have POSIX_FADV_DONTNEED, thus some variables are not needed. --- src/borg/_chunker.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/borg/_chunker.c b/src/borg/_chunker.c index 75599c5b1..dd141e87b 100644 --- a/src/borg/_chunker.c +++ b/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 From d00304607829781ec8a49ca7cfc2758d8143429c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 10:50:38 +0200 Subject: [PATCH 2/4] hashindex.pyx: fix signedness warning --- src/borg/hashindex.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/hashindex.pyx b/src/borg/hashindex.pyx index 3df89f365..586ec4493 100644 --- a/src/borg/hashindex.pyx +++ b/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 From a7d4dd2ba62da32f0b86a24b4255da1c3bf24647 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 11:20:23 +0200 Subject: [PATCH 3/4] unpack.h: fix compiler warnings, improve error handling --- src/borg/cache_sync/unpack.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/borg/cache_sync/unpack.h b/src/borg/cache_sync/unpack.h index a04e81147..a67207725 100644 --- a/src/borg/cache_sync/unpack.h +++ b/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; } From 0e0b33b5ffabe6b3f5d2036e5677eed3320e6e89 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 11:55:03 +0200 Subject: [PATCH 4/4] cache_sync directory: add a dummy __init__.py to get rid of setuptools warning --- src/borg/cache_sync/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/borg/cache_sync/__init__.py diff --git a/src/borg/cache_sync/__init__.py b/src/borg/cache_sync/__init__.py new file mode 100644 index 000000000..cb2d1a50f --- /dev/null +++ b/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. +"""