1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-14 05:57:40 +03:00

Merge pull request #15733 from benjarobin/fix_warn_ndebug

Allow to build without any warning with NDEBUG defined + Bugfix
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-05-07 09:47:19 +02:00 committed by GitHub
commit 354722dde4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 37 deletions

View File

@ -335,15 +335,6 @@ basic_disabled_warnings = [
'-Wno-unused-result', '-Wno-unused-result',
'-Wno-format-signedness', '-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 = [ possible_cc_flags = [
'-Werror=undef', '-Werror=undef',

View File

@ -2889,7 +2889,7 @@ int config_parse_syscall_filter(
void *userdata) { void *userdata) {
ExecContext *c = data; ExecContext *c = data;
const Unit *u = userdata; _unused_ const Unit *u = userdata;
bool invert = false; bool invert = false;
const char *p; const char *p;
int r; int r;

View File

@ -172,8 +172,8 @@ static int import_fs(int argc, char *argv[], void *userdata) {
progress.limit = (RateLimit) { 200*USEC_PER_MSEC, 1 }; progress.limit = (RateLimit) { 200*USEC_PER_MSEC, 1 };
/* Hook into SIGINT/SIGTERM, so that we can cancel things then */ /* Hook into SIGINT/SIGTERM, so that we can cancel things then */
assert(sigaction(SIGINT, &sa, &old_sigint_sa) >= 0); assert_se(sigaction(SIGINT, &sa, &old_sigint_sa) >= 0);
assert(sigaction(SIGTERM, &sa, &old_sigterm_sa) >= 0); assert_se(sigaction(SIGTERM, &sa, &old_sigterm_sa) >= 0);
r = btrfs_subvol_snapshot_fd_full( r = btrfs_subvol_snapshot_fd_full(
fd, fd,

View 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) { static gcry_mpi_t mpi_import(const void *buf, size_t buflen) {
gcry_mpi_t h; gcry_mpi_t h;
unsigned len; _unused_ unsigned len;
assert_se(gcry_mpi_scan(&h, GCRYMPI_FMT_USG, buf, buflen, NULL) == 0); assert_se(gcry_mpi_scan(&h, GCRYMPI_FMT_USG, buf, buflen, NULL) == 0);
len = (gcry_mpi_get_nbits(h) + 7) / 8; len = (gcry_mpi_get_nbits(h) + 7) / 8;

View File

@ -2567,7 +2567,7 @@ static int method_can_reboot_parameter(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Manager *m = userdata; _unused_ Manager *m = userdata;
int r; int r;
assert(message); assert(message);
@ -2699,7 +2699,7 @@ static int method_can_reboot_to_firmware_setup(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Manager *m = userdata; _unused_ Manager *m = userdata;
int r; int r;
assert(message); assert(message);
@ -2888,7 +2888,7 @@ static int method_can_reboot_to_boot_loader_menu(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Manager *m = userdata; _unused_ Manager *m = userdata;
int r; int r;
assert(message); assert(message);
@ -3079,7 +3079,7 @@ static int method_can_reboot_to_boot_loader_entry(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Manager *m = userdata; _unused_ Manager *m = userdata;
int r; int r;
assert(message); assert(message);

View 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) { static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
Manager *m = userdata; _unused_ Manager *m = userdata;
const char *name; const char *name;
int r; 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) { 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_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_hashmap_free_ Hashmap *images = NULL; _cleanup_hashmap_free_ Hashmap *images = NULL;
Manager *m = userdata; _unused_ Manager *m = userdata;
Image *image; Image *image;
Iterator i; Iterator i;
int r; int r;

View 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) { 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; const sd_bus_error *e;
assert(m); 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) { 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; const sd_bus_error *e;
assert(m); assert(m);

View File

@ -1722,7 +1722,7 @@ static int context_dump_partition_bar(Context *context, const char *node) {
bool z = false; bool z = false;
size_t c, j = 0; 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 */ c -= 2; /* We do not use the leftmost and rightmost character cell */
bar = new0(Partition*, c); bar = new0(Partition*, c);

View File

@ -15,7 +15,6 @@
int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) { int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) {
struct statfs sfs; struct statfs sfs;
int r;
assert(fd >= 0); assert(fd >= 0);
@ -54,8 +53,7 @@ int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) {
sz -= sz % sfs.f_bsize; sz -= sz % sfs.f_bsize;
r = snprintf(args.name, sizeof(args.name), "%" PRIu64, sz); xsprintf(args.name, "%" PRIu64, sz);
assert((size_t) r < sizeof(args.name));
if (ioctl(fd, BTRFS_IOC_RESIZE, &args) < 0) if (ioctl(fd, BTRFS_IOC_RESIZE, &args) < 0)
return -errno; return -errno;

View File

@ -99,13 +99,13 @@ static void test_bool_assign(void) {
g = cp; /* cast from pointer */ g = cp; /* cast from pointer */
h = NULL; /* cast from pointer */ h = NULL; /* cast from pointer */
assert(b); assert_se(b);
assert(c); assert_se(c);
assert(d); assert_se(d);
assert(e); assert_se(e);
assert(!f); assert_se(!f);
assert(g); assert_se(g);
assert(!h); assert_se(!h);
} }
static int cleanup_counter = 0; static int cleanup_counter = 0;

View File

@ -233,17 +233,17 @@ static void assert_equal_fd(int fd1, int fd2) {
ssize_t x, y; ssize_t x, y;
x = read(fd1, a, sizeof(a)); x = read(fd1, a, sizeof(a));
assert(x >= 0); assert_se(x >= 0);
y = read(fd2, b, sizeof(b)); y = read(fd2, b, sizeof(b));
assert(y >= 0); assert_se(y >= 0);
assert(x == y); assert_se(x == y);
if (x == 0) if (x == 0)
break; break;
assert(memcmp(a, b, x) == 0); assert_se(memcmp(a, b, x) == 0);
} }
} }

View File

@ -433,7 +433,7 @@ static void assert_similar(usec_t a, usec_t b) {
else else
d = b - a; d = b - a;
assert(d < 10*USEC_PER_SEC); assert_se(d < 10*USEC_PER_SEC);
} }
static void test_usec_shift_clock(void) { static void test_usec_shift_clock(void) {