Hello community,

here is the log from the commit of package raft for openSUSE:Leap:15.2 checked 
in at 2020-05-14 06:51:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/raft (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.raft.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "raft"

Thu May 14 06:51:52 2020 rev:3 rq:805387 version:0.9.19

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/raft/raft.changes      2020-05-01 
15:07:12.126551993 +0200
+++ /work/SRC/openSUSE:Leap:15.2/.raft.new.2738/raft.changes    2020-05-14 
06:51:54.259757596 +0200
@@ -1,0 +2,7 @@
+Wed May 13 07:38:07 UTC 2020 - Andreas Stieger <[email protected]>
+
+- raft 0.9.19:
+  * New raft_aligned_free() API
+  * Fix coverity findings/ and compiler warnings
+
+-------------------------------------------------------------------

Old:
----
  raft-0.9.18.tar.gz

New:
----
  raft-0.9.19.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ raft.spec ++++++
--- /var/tmp/diff_new_pack.g1EHmm/_old  2020-05-14 06:51:54.551758225 +0200
+++ /var/tmp/diff_new_pack.g1EHmm/_new  2020-05-14 06:51:54.555758234 +0200
@@ -18,7 +18,7 @@
 
 %bcond_without libuv
 Name:           raft
-Version:        0.9.18
+Version:        0.9.19
 Release:        0
 Summary:        Fully asynchronous C implementation of the Raft consensus 
protocol
 License:        LGPL-3.0-only WITH linking-exception-lgpl-3.0

++++++ raft-0.9.18.tar.gz -> raft-0.9.19.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/.dir-locals.el 
new/raft-0.9.19/.dir-locals.el
--- old/raft-0.9.18/.dir-locals.el      2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/.dir-locals.el      2020-05-12 16:34:21.000000000 +0200
@@ -1,4 +1,4 @@
 ((nil . ((fill-column . 80)))
- (c-mode . ((flycheck-clang-definitions . ("HAVE_LINUX_IO_URING_H" 
"_GNU_SOURCE"))
+ (c-mode . ((flycheck-clang-definitions . ("HAVE_LINUX_AIO_ABI_H" 
"HAVE_LINUX_IO_URING_H" "_GNU_SOURCE"))
            (flycheck-clang-args . ("-Wpedantic" "-Wall" "-Wextra"))
            (flycheck-gcc-definitions . ("HAVE_LINUX_IO_URING_H" 
"_GNU_SOURCE")))))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/.travis.yml new/raft-0.9.19/.travis.yml
--- old/raft-0.9.18/.travis.yml 2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/.travis.yml 2020-05-12 16:34:21.000000000 +0200
@@ -39,7 +39,7 @@
   - autoreconf -i
   - ./configure --enable-example --enable-debug --enable-code-coverage 
--enable-sanitize
   - amalgamate.py --config=amalgamation.json --source=$(pwd)
-  - $CC raft.c -c -D_GNU_SOURCE -Wall -Wextra -Wpedantic -fpic
+  - $CC raft.c -c -D_GNU_SOURCE -DHAVE_LINUX_AIO_ABI_H -Wall -Wextra 
-Wpedantic -fpic
   - ./test/lib/fs.sh setup
   - make check CFLAGS=-O0 $(./test/lib/fs.sh detect) || (cat ./test-suite.log 
&& false)
   - if [ $TRAVIS_COMPILER = gcc ]; then make code-coverage-capture; fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/configure.ac new/raft-0.9.19/configure.ac
--- old/raft-0.9.18/configure.ac        2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/configure.ac        2020-05-12 16:34:21.000000000 +0200
@@ -1,5 +1,5 @@
 AC_PREREQ(2.60)
-AC_INIT([raft], [0.9.18])
+AC_INIT([raft], [0.9.19])
 AC_LANG([C])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([ac])
@@ -45,7 +45,7 @@
 AX_CODE_COVERAGE
 
 # Checks for header files.
-AC_CHECK_HEADERS([stdlib.h string.h stdio.h assert.h unistd.h 
linux/io_uring.h])
+AC_CHECK_HEADERS([stdlib.h string.h stdio.h assert.h unistd.h linux/io_uring.h 
linux/aio_abi.h])
 
 # Check if zfs >= 0.8.0 is available (for direct I/O support).
 AC_CHECK_PROG(have_zfs, zfs, yes)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/example/server.c 
new/raft-0.9.19/example/server.c
--- old/raft-0.9.18/example/server.c    2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/example/server.c    2020-05-12 16:34:21.000000000 +0200
@@ -69,7 +69,7 @@
 
 static int FsmInit(struct raft_fsm *fsm)
 {
-    struct Fsm *f = raft_malloc(sizeof *fsm);
+    struct Fsm *f = raft_malloc(sizeof *f);
     if (f == NULL) {
         return RAFT_NOMEM;
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/include/raft.h 
new/raft-0.9.19/include/raft.h
--- old/raft-0.9.18/include/raft.h      2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/include/raft.h      2020-05-12 16:34:21.000000000 +0200
@@ -947,6 +947,7 @@
     void *(*calloc)(void *data, size_t nmemb, size_t size);
     void *(*realloc)(void *data, void *ptr, size_t size);
     void *(*aligned_alloc)(void *data, size_t alignment, size_t size);
+    void (*aligned_free)(void *data, size_t alignment, void *ptr);
 };
 
 RAFT_API void *raft_malloc(size_t size);
@@ -954,6 +955,7 @@
 RAFT_API void *raft_calloc(size_t nmemb, size_t size);
 RAFT_API void *raft_realloc(void *ptr, size_t size);
 RAFT_API void *raft_aligned_alloc(size_t alignment, size_t size);
+RAFT_API void raft_aligned_free(size_t alignment, void *ptr);
 
 /**
  * Use a custom dynamic memory allocator.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/err.h new/raft-0.9.19/src/err.h
--- old/raft-0.9.18/src/err.h   2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/err.h   2020-05-12 16:34:21.000000000 +0200
@@ -41,12 +41,12 @@
 void errMsgWrap(char *e, const char *format);
 
 /* Transfer an error message from an object to another, wrapping it. */
-#define ErrMsgTransfer(ERRMSG1, ERRMSG2, FORMAT)     \
-    strncpy(ERRMSG2, ERRMSG1, RAFT_ERRMSG_BUF_SIZE); \
+#define ErrMsgTransfer(ERRMSG1, ERRMSG2, FORMAT)    \
+    memcpy(ERRMSG2, ERRMSG1, RAFT_ERRMSG_BUF_SIZE); \
     ErrMsgWrapf(ERRMSG2, FORMAT)
 
 #define ErrMsgTransferf(ERRMSG1, ERRMSG2, FORMAT, ...) \
-    strncpy(ERRMSG2, ERRMSG1, RAFT_ERRMSG_BUF_SIZE);   \
+    memcpy(ERRMSG2, ERRMSG1, RAFT_ERRMSG_BUF_SIZE);    \
     ErrMsgWrapf(ERRMSG2, FORMAT, __VA_ARGS__)
 
 /* Use the static error message for the error with the given code. */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/heap.c new/raft-0.9.19/src/heap.c
--- old/raft-0.9.18/src/heap.c  2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/heap.c  2020-05-12 16:34:21.000000000 +0200
@@ -34,13 +34,20 @@
     return aligned_alloc(alignment, size);
 }
 
+static void defaultAlignedFree(void *data, size_t alignment, void *ptr)
+{
+    (void)alignment;
+    defaultFree(data, ptr);
+}
+
 static struct raft_heap defaultHeap = {
-    NULL,               /* data */
-    defaultMalloc,      /* malloc */
-    defaultFree,        /* free */
-    defaultCalloc,      /* calloc */
-    defaultRealloc,     /* realloc */
-    defaultAlignedAlloc /* aligned_alloc */
+    NULL,                /* data */
+    defaultMalloc,       /* malloc */
+    defaultFree,         /* free */
+    defaultCalloc,       /* calloc */
+    defaultRealloc,      /* realloc */
+    defaultAlignedAlloc, /* aligned_alloc */
+    defaultAlignedFree   /* aligned_free */
 };
 
 static struct raft_heap *currentHeap = &defaultHeap;
@@ -93,6 +100,11 @@
     return currentHeap->aligned_alloc(currentHeap->data, alignment, size);
 }
 
+void raft_aligned_free(size_t alignment, void *ptr)
+{
+    currentHeap->aligned_free(currentHeap->data, alignment, ptr);
+}
+
 void raft_heap_set(struct raft_heap *heap)
 {
     currentHeap = heap;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/log.c new/raft-0.9.19/src/log.c
--- old/raft-0.9.18/src/log.c   2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/log.c   2020-05-12 16:34:21.000000000 +0200
@@ -267,11 +267,14 @@
 
     /* Lookup the slot associated with the given term/index, which must have
      * been previously inserted. */
-    for (slot = &l->refs[key]; slot != NULL; slot = slot->next) {
+    slot = &l->refs[key];
+    while (1) {
+        assert(slot != NULL);
         assert(slot->index == index);
         if (slot->term == term) {
             break;
         }
+        slot = slot->next;
     }
     assert(slot != NULL);
 
@@ -297,14 +300,16 @@
 
     /* Lookup the slot associated with the given term/index, keeping track of
      * its previous slot in the bucket list. */
-    for (slot = &l->refs[key]; slot != NULL; slot = slot->next) {
+    slot = &l->refs[key];
+    while (1) {
+        assert(slot != NULL);
         assert(slot->index == index);
         if (slot->term == term) {
             break;
         }
         prev_slot = slot;
+        slot = slot->next;
     }
-    assert(slot != NULL);
 
     slot->count--;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/replication.c 
new/raft-0.9.19/src/replication.c
--- old/raft-0.9.18/src/replication.c   2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/replication.c   2020-05-12 16:34:21.000000000 +0200
@@ -1488,6 +1488,9 @@
                 applyChange(r, index);
                 rv = 0;
                 break;
+            default:
+                rv = 0; /* For coverity. This case can't be taken. */
+                break;
         }
 
         if (rv != 0) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/syscall.c 
new/raft-0.9.19/src/syscall.c
--- old/raft-0.9.18/src/syscall.c       2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/syscall.c       2020-05-12 16:34:21.000000000 +0200
@@ -1,8 +1,11 @@
 #include "syscall.h"
 
+#if HAVE_LINUX_AIO_ABI_H || HAVE_LINUX_IO_URING_H
 #include <sys/syscall.h>
 #include <unistd.h>
+#endif
 
+#if HAVE_LINUX_AIO_ABI_H
 int io_setup(unsigned nr_events, aio_context_t *ctx_idp)
 {
     return (int)syscall(__NR_io_setup, nr_events, ctx_idp);
@@ -26,6 +29,7 @@
 {
     return (int)syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, 
timeout);
 }
+#endif
 
 #if HAVE_LINUX_IO_URING_H
 int io_uring_register(int fd,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/syscall.h 
new/raft-0.9.19/src/syscall.h
--- old/raft-0.9.18/src/syscall.h       2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/syscall.h       2020-05-12 16:34:21.000000000 +0200
@@ -3,13 +3,17 @@
 #ifndef SYSCALL_H_
 #define SYSCALL_H_
 
+#if HAVE_LINUX_AIO_ABI_H
 #include <linux/aio_abi.h>
 #include <signal.h>
 #include <time.h>
+#endif
+
 #if HAVE_LINUX_IO_URING_H
 #include <linux/io_uring.h>
 #endif
 
+#if HAVE_LINUX_AIO_ABI_H
 /* AIO */
 int io_setup(unsigned nr_events, aio_context_t *ctx_idp);
 
@@ -22,6 +26,7 @@
                  long nr,
                  struct io_event *events,
                  struct timespec *timeout);
+#endif
 
 #if HAVE_LINUX_IO_URING_H
 /* uring */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/uv_fs.c new/raft-0.9.19/src/uv_fs.c
--- old/raft-0.9.18/src/uv_fs.c 2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/uv_fs.c 2020-05-12 16:34:21.000000000 +0200
@@ -607,7 +607,7 @@
         }
         memset(buf, 0, *size);
         rv = (int)write(fd, buf, *size);
-        raft_free(buf);
+        raft_aligned_free(*size, buf);
         if (rv > 0) {
             /* Since we fallocate'ed the file, we should never fail because of
              * lack of disk space, and all bytes should have been written. */
@@ -679,7 +679,7 @@
     rv = UvOsIoSubmit(ctx, 1, &iocbs);
     if (rv != 0) {
         /* UNTESTED: in practice this should fail only with ENOMEM */
-        raft_free(buf);
+        raft_aligned_free(size, buf);
         UvOsIoDestroy(ctx);
         /* On ZFS 0.8 this is not properly supported yet. Also, when running on
          * older kernels a binary compiled on a kernel with RWF_NOWAIT support,
@@ -697,7 +697,7 @@
     assert(n_events == 1);
 
     /* Release the write buffer. */
-    raft_free(buf);
+    raft_aligned_free(size, buf);
 
     /* Release the KAIO context handle. */
     rv = UvOsIoDestroy(ctx);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/uv_os.c new/raft-0.9.19/src/uv_os.c
--- old/raft-0.9.18/src/uv_os.c 2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/uv_os.c 2020-05-12 16:34:21.000000000 +0200
@@ -37,6 +37,36 @@
     return uv_fs_close(NULL, &req, fd, NULL);
 }
 
+/* Emulate fallocate(). Mostly taken from glibc's implementation. */
+static int uvOsFallocateEmulation(int fd, off_t offset, off_t len)
+{
+    unsigned increment;
+    struct statfs f;
+    int rv;
+
+    rv = fstatfs(fd, &f);
+    if (rv != 0) {
+        return errno;
+    }
+
+    if (f.f_bsize == 0) {
+        increment = 512;
+    } else if (f.f_bsize < 4096) {
+        increment = f.f_bsize;
+    } else {
+        increment = 4096;
+    }
+
+    for (offset += (len - 1) % increment; len > 0; offset += increment) {
+        len -= increment;
+        rv = pwrite(fd, "", 1, offset);
+        if (rv != 1)
+            return errno;
+    }
+
+    return 0;
+}
+
 int UvOsFallocate(uv_file fd, off_t offset, off_t len)
 {
     int rv;
@@ -47,7 +77,16 @@
          *   posix_fallocate() returns zero on success, or an error number on
          *   failure.  Note that errno is not set.
          */
-        return -rv;
+        if (rv != EOPNOTSUPP) {
+            return -rv;
+        }
+        /* This might be a libc implementation (e.g. musl) that doesn't
+         * implement a transparent fallback if fallocate() is not supported
+         * by the underlying file system. */
+        rv = uvOsFallocateEmulation(fd, offset, len);
+        if (rv != 0) {
+            return -EOPNOTSUPP;
+        }
     }
     return 0;
 }
@@ -64,7 +103,8 @@
     return uv_fs_fsync(NULL, &req, fd, NULL);
 }
 
-int UvOsFdatasync(uv_file fd) {
+int UvOsFdatasync(uv_file fd)
+{
     struct uv_fs_s req;
     return uv_fs_fdatasync(NULL, &req, fd, NULL);
 }
@@ -166,7 +206,7 @@
     int rv;
     /* At the moment only UV_FS_O_NONBLOCK is supported */
     assert(flags == UV_FS_O_NONBLOCK);
-    flags = EFD_NONBLOCK|EFD_CLOEXEC;
+    flags = EFD_NONBLOCK | EFD_CLOEXEC;
     rv = eventfd(initval, flags);
     if (rv == -1) {
         return -errno;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/src/uv_segment.c 
new/raft-0.9.19/src/uv_segment.c
--- old/raft-0.9.18/src/uv_segment.c    2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/src/uv_segment.c    2020-05-12 16:34:21.000000000 +0200
@@ -497,6 +497,7 @@
                  * segment. */
                 tracef("remove zeroed open segment %s", info->filename);
                 remove = true;
+                close(fd);
                 goto done;
             }
         }
@@ -589,7 +590,7 @@
         if (rv != 0) {
             tracef("finalize %s: %s", info->filename, errmsg);
             rv = RAFT_IOERR;
-            goto err_after_open;
+            goto err;
         }
 
         info->is_open = false;
@@ -643,7 +644,7 @@
     if (b->arena.base != NULL) {
         assert(b->arena.len >= b->block_size);
         memcpy(base, b->arena.base, b->arena.len);
-        raft_free(b->arena.base);
+        raft_aligned_free(b->block_size, b->arena.base);
     }
 
     b->arena.base = base;
@@ -663,7 +664,7 @@
 void uvSegmentBufferClose(struct uvSegmentBuffer *b)
 {
     if (b->arena.base != NULL) {
-        raft_free(b->arena.base);
+        raft_aligned_free(b->block_size, b->arena.base);
     }
 }
 
@@ -1009,7 +1010,7 @@
         goto out_after_buffer_init;
     }
 
-    uvSegmentBufferAppend(&buf, entries, m);
+    rv = uvSegmentBufferAppend(&buf, entries, m);
     if (rv != 0) {
         goto out_after_buffer_init;
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/raft-0.9.18/test/lib/heap.c 
new/raft-0.9.19/test/lib/heap.c
--- old/raft-0.9.18/test/lib/heap.c     2020-04-16 09:15:51.000000000 +0200
+++ new/raft-0.9.19/test/lib/heap.c     2020-05-12 16:34:21.000000000 +0200
@@ -8,12 +8,14 @@
 struct heap
 {
     int n;                   /* Number of outstanding allocations. */
+    size_t alignment;        /* Value of last aligned alloc */
     struct test_fault fault; /* Fault trigger. */
 };
 
 static void heapInit(struct heap *h)
 {
     h->n = 0;
+    h->alignment = 0;
     test_fault_init(&h->fault);
 }
 
@@ -83,9 +85,18 @@
     p = aligned_alloc(alignment, size);
     munit_assert_ptr_not_null(p);
 
+    h->alignment = alignment;
+
     return p;
 }
 
+static void heapAlignedFree(void *data, size_t alignment, void *ptr)
+{
+    struct heap *h = data;
+    munit_assert_int(alignment, ==, h->alignment);
+    heapFree(data, ptr);
+}
+
 static int getIntParam(const MunitParameter params[], const char *name)
 {
     const char *value = munit_parameters_get(params, name);
@@ -110,6 +121,7 @@
     h->calloc = heapCalloc;
     h->realloc = heapRealloc;
     h->aligned_alloc = heapAlignedAlloc;
+    h->aligned_free = heapAlignedFree;
 
     raft_heap_set(h);
     test_fault_pause(&heap->fault);
@@ -119,7 +131,7 @@
 {
     struct heap *heap = h->data;
     if (heap->n != 0) {
-      //munit_errorf("memory leak: %d outstanding allocations", heap->n);
+        // munit_errorf("memory leak: %d outstanding allocations", heap->n);
     }
     free(heap);
     raft_heap_set_default();


Reply via email to