Skip to content

Commit

Permalink
clipmenu: Please -fexceptions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cdown committed Apr 9, 2024
1 parent b2fccd3 commit 2e9dda1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/clipmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 2e9dda1

Please sign in to comment.