From 2e9dda1a1ae3221f9a0fede9db084d6ae2d0f063 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Tue, 9 Apr 2024 02:43:32 +0100 Subject: [PATCH] clipmenu: Please -fexceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling with -fexceptions (only) for some reason, the following can be seen: src/clipmenu.c: In function ‘main’: src/clipmenu.c:183:9: error: ‘hash’ may be used uninitialized [-Werror=maybe-uninitialized] 183 | run_clipserve(hash); | ^~~~~~~~~~~~~~~~~~~ src/clipmenu.c:179:14: note: ‘hash’ was declared here 179 | uint64_t hash; | ^~~~ ...but this seems off, we always initialise it if dmenu_exit_code is EXIT_SUCCESS, and no other static analyser has a problem with it. Anyway, this is enough. --- src/clipmenu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/clipmenu.c b/src/clipmenu.c index 434f3ca..7ea297e 100644 --- a/src/clipmenu.c +++ b/src/clipmenu.c @@ -16,6 +16,8 @@ static int dmenu_user_argc; static char **dmenu_user_argv; +#define HASH_INVALID UINT64_MAX + /** * Calculate the base 10 padding length for a number. */ @@ -136,6 +138,7 @@ 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]; @@ -179,7 +182,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) { + if (dmenu_exit_code == EXIT_SUCCESS && hash != HASH_INVALID) { run_clipserve(hash); }