]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #15733 from benjarobin/fix_warn_ndebug
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 May 2020 07:47:19 +0000 (09:47 +0200)
committerGitHub <noreply@github.com>
Thu, 7 May 2020 07:47:19 +0000 (09:47 +0200)
Allow to build without any warning with NDEBUG defined + Bugfix

12 files changed:
meson.build
src/core/load-fragment.c
src/import/import-fs.c
src/journal/fsprg.c
src/login/logind-dbus.c
src/machine/machined-dbus.c
src/network/networkd-manager.c
src/partition/repart.c
src/shared/resize-fs.c
src/test/test-alloc-util.c
src/test/test-fd-util.c
src/test/test-time-util.c

index bf353cd1f7284375951c8bb440bd89ded1c01ed5..a922f9a2f1c114daaa42cfb4db4e10a8cc27a374 100644 (file)
@@ -335,15 +335,6 @@ basic_disabled_warnings = [
         '-Wno-unused-result',
         '-Wno-format-signedness',
 ]
-if get_option('b_ndebug') == 'true'
-        # With asserts disabled with get a bunch of warnings about variables which
-        # are used only in the asserts. This is not useful at all, so let's just silence
-        # those warnings.
-        basic_disabled_warnings += [
-                '-Wno-unused-variable',
-                '-Wno-unused-but-set-variable',
-        ]
-endif
 
 possible_cc_flags = [
         '-Werror=undef',
index b16c62a5c7c62d2adb10623c0759cc6ef6159893..9c24bb780a492c1e12899d0befcb64064070f44b 100644 (file)
@@ -2889,7 +2889,7 @@ int config_parse_syscall_filter(
                 void *userdata) {
 
         ExecContext *c = data;
-        const Unit *u = userdata;
+        _unused_ const Unit *u = userdata;
         bool invert = false;
         const char *p;
         int r;
index 468303a6dce70773752467be2c3df405dbdb80d7..5e61049ced8fe06d6560c3dc5f4447b6de06d326 100644 (file)
@@ -172,8 +172,8 @@ static int import_fs(int argc, char *argv[], void *userdata) {
         progress.limit = (RateLimit) { 200*USEC_PER_MSEC, 1 };
 
         /* Hook into SIGINT/SIGTERM, so that we can cancel things then */
-        assert(sigaction(SIGINT, &sa, &old_sigint_sa) >= 0);
-        assert(sigaction(SIGTERM, &sa, &old_sigterm_sa) >= 0);
+        assert_se(sigaction(SIGINT, &sa, &old_sigint_sa) >= 0);
+        assert_se(sigaction(SIGTERM, &sa, &old_sigterm_sa) >= 0);
 
         r = btrfs_subvol_snapshot_fd_full(
                         fd,
index 1dda2149d46ffcd14fc260874bc23f58729c3171..0ef3df89df264a1040d770c293ac951c94df1c8d 100644 (file)
@@ -60,7 +60,7 @@ static void mpi_export(void *buf, size_t buflen, const gcry_mpi_t x) {
 
 static gcry_mpi_t mpi_import(const void *buf, size_t buflen) {
         gcry_mpi_t h;
-        unsigned len;
+        _unused_ unsigned len;
 
         assert_se(gcry_mpi_scan(&h, GCRYMPI_FMT_USG, buf, buflen, NULL) == 0);
         len = (gcry_mpi_get_nbits(h) + 7) / 8;
index 47fc53167e08325588aa7ff2b551eb1d509ac84f..20794451f5e702777b561d925fc093668383f536 100644 (file)
@@ -2567,7 +2567,7 @@ static int method_can_reboot_parameter(
                 void *userdata,
                 sd_bus_error *error) {
 
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         int r;
 
         assert(message);
@@ -2699,7 +2699,7 @@ static int method_can_reboot_to_firmware_setup(
                 void *userdata,
                 sd_bus_error *error) {
 
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         int r;
 
         assert(message);
@@ -2888,7 +2888,7 @@ static int method_can_reboot_to_boot_loader_menu(
                 void *userdata,
                 sd_bus_error *error) {
 
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         int r;
 
         assert(message);
@@ -3079,7 +3079,7 @@ static int method_can_reboot_to_boot_loader_entry(
                 void *userdata,
                 sd_bus_error *error) {
 
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         int r;
 
         assert(message);
index ceb3afadbdd06d7703de81830f21022a72159a35..865ce7baada60b694034b6fd200703d22e339c08 100644 (file)
@@ -112,7 +112,7 @@ static int method_get_machine(sd_bus_message *message, void *userdata, sd_bus_er
 
 static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_free_ char *p = NULL;
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         const char *name;
         int r;
 
@@ -471,7 +471,7 @@ static int method_get_machine_os_release(sd_bus_message *message, void *userdata
 static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
         _cleanup_hashmap_free_ Hashmap *images = NULL;
-        Manager *m = userdata;
+        _unused_ Manager *m = userdata;
         Image *image;
         Iterator i;
         int r;
index 3e9fb8c2179d2a76bb1f49b0da50e12237118476..f9b611e41949b2b9d6faea11d231492a9ed26dd9 100644 (file)
@@ -2233,7 +2233,7 @@ void manager_dirty(Manager *manager) {
 }
 
 static int set_hostname_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        Manager *manager = userdata;
+        _unused_ Manager *manager = userdata;
         const sd_bus_error *e;
 
         assert(m);
@@ -2279,7 +2279,7 @@ int manager_set_hostname(Manager *m, const char *hostname) {
 }
 
 static int set_timezone_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        Manager *manager = userdata;
+        _unused_ Manager *manager = userdata;
         const sd_bus_error *e;
 
         assert(m);
index bc9b12f167b688a7cc234f4efc678bf88d281fc0..82d60cd42b47c5712e48556a061c50077da10d9f 100644 (file)
@@ -1722,7 +1722,7 @@ static int context_dump_partition_bar(Context *context, const char *node) {
         bool z = false;
         size_t c, j = 0;
 
-        assert((c = columns()) >= 2);
+        assert_se((c = columns()) >= 2);
         c -= 2; /* We do not use the leftmost and rightmost character cell */
 
         bar = new0(Partition*, c);
index 5ed26a6c9237a8eededb428a62df047673fa12d6..24a17a2ffef8873aae63155a1ba43c0cd7a1a22f 100644 (file)
@@ -15,7 +15,6 @@
 
 int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) {
         struct statfs sfs;
-        int r;
 
         assert(fd >= 0);
 
@@ -54,8 +53,7 @@ int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) {
 
                 sz -= sz % sfs.f_bsize;
 
-                r = snprintf(args.name, sizeof(args.name), "%" PRIu64, sz);
-                assert((size_t) r < sizeof(args.name));
+                xsprintf(args.name, "%" PRIu64, sz);
 
                 if (ioctl(fd, BTRFS_IOC_RESIZE, &args) < 0)
                         return -errno;
index 758b753237903aa238b7226d8fa9251252271648..d85f705504403cdd9240e966adb17c8cce9e29b4 100644 (file)
@@ -99,13 +99,13 @@ static void test_bool_assign(void) {
         g = cp;    /* cast from pointer */
         h = NULL;  /* cast from pointer */
 
-        assert(b);
-        assert(c);
-        assert(d);
-        assert(e);
-        assert(!f);
-        assert(g);
-        assert(!h);
+        assert_se(b);
+        assert_se(c);
+        assert_se(d);
+        assert_se(e);
+        assert_se(!f);
+        assert_se(g);
+        assert_se(!h);
 }
 
 static int cleanup_counter = 0;
index 713795814dfab36b12a08e42e8cc89b63fea92e7..44c74987c58227f631fa40687c53bfc821162eda 100644 (file)
@@ -233,17 +233,17 @@ static void assert_equal_fd(int fd1, int fd2) {
                 ssize_t x, y;
 
                 x = read(fd1, a, sizeof(a));
-                assert(x >= 0);
+                assert_se(x >= 0);
 
                 y = read(fd2, b, sizeof(b));
-                assert(y >= 0);
+                assert_se(y >= 0);
 
-                assert(x == y);
+                assert_se(x == y);
 
                 if (x == 0)
                         break;
 
-                assert(memcmp(a, b, x) == 0);
+                assert_se(memcmp(a, b, x) == 0);
         }
 }
 
index a422cc8ddc63e5a4e1a5c5a686cf65e7b6400241..e3b1f6f8ca07c0fe29f2010c1d1313c670a81004 100644 (file)
@@ -433,7 +433,7 @@ static void assert_similar(usec_t a, usec_t b) {
         else
                 d = b - a;
 
-        assert(d < 10*USEC_PER_SEC);
+        assert_se(d < 10*USEC_PER_SEC);
 }
 
 static void test_usec_shift_clock(void) {