From 145de371c97d9cf72dcc1c99e3f9eba7b0a48fba Mon Sep 17 00:00:00 2001 From: Chris Down Date: Mon, 15 Apr 2024 00:49:50 +0100 Subject: [PATCH] make: Use -Wno-maybe-uninitialized This has way too many false positives and is beholden to a lot of compiler heuristics, and is affected by -fexception and -flto. Closes #215. --- Makefile | 1 + src/clipmenu.c | 3 +-- src/clipserve.c | 3 +-- src/util.h | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5667ff2..75363e9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CFLAGS := -std=gnu11 -O2 -Wall -Wextra -Wshadow -Wpointer-arith \ -Wcast-align -Wmissing-prototypes -Wstrict-overflow -Wformat=2 \ -Wwrite-strings -Warray-bounds -Wstrict-prototypes \ + -Wno-maybe-uninitialized \ -Werror $(CFLAGS) CPPFLAGS += -I/usr/X11R6/include -L/usr/X11R6/lib LDLIBS += -lX11 -lXfixes diff --git a/src/clipmenu.c b/src/clipmenu.c index 2d05c0e..434f3ca 100644 --- a/src/clipmenu.c +++ b/src/clipmenu.c @@ -136,7 +136,6 @@ static int _nonnull_ interact_with_dmenu(struct config *cfg, int *input_pipe, int forced_ret = 0; if (str_to_uint64(sel_idx_str, &sel_idx) < 0 || sel_idx == 0 || sel_idx > cur_clips) { - *out_hash = HASH_INVALID; forced_ret = EXIT_FAILURE; } else { *out_hash = idx_to_hash[sel_idx - 1]; @@ -180,7 +179,7 @@ int main(int argc, char *argv[]) { uint64_t hash; int dmenu_exit_code = prompt_user_for_hash(&cfg, &hash); - if (dmenu_exit_code == EXIT_SUCCESS && hash != HASH_INVALID) { + if (dmenu_exit_code == EXIT_SUCCESS) { run_clipserve(hash); } diff --git a/src/clipserve.c b/src/clipserve.c index b6f86c8..ded04cc 100644 --- a/src/clipserve.c +++ b/src/clipserve.c @@ -95,11 +95,10 @@ static void _nonnull_ serve_clipboard(uint64_t hash, } int main(int argc, char *argv[]) { - uint64_t hash = HASH_INVALID; - die_on(argc != 2, "Usage: clipserve [hash]\n"); _drop_(config_free) struct config cfg = setup("clipserve"); + uint64_t hash; expect(str_to_uint64(argv[1], &hash) == 0); _drop_(close) int content_dir_fd = open(get_cache_dir(&cfg), O_RDONLY); diff --git a/src/util.h b/src/util.h index d45e7b9..10101aa 100644 --- a/src/util.h +++ b/src/util.h @@ -23,7 +23,6 @@ #endif #define UINT64_MAX_STRLEN 20 // (1 << 64) - 1 is 20 digits wide -#define HASH_INVALID UINT64_MAX #define streq(a, b) (strcmp((a), (b)) == 0) #define strceq(a, b) (strcasecmp((a), (b)) == 0)