From a65914f3384a8c1f6f8c2facb8c3ca28a88d4009 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sat, 21 Apr 2018 02:28:31 +0300 Subject: [PATCH] Fix missing prototypes i3 will now compile with no warnings when -Wmissing-prototypes is used. --- .travis.yml | 2 +- i3bar/src/child.c | 14 +++++++------- i3bar/src/ipc.c | 20 ++++++++++---------- i3bar/src/main.c | 6 +++--- i3bar/src/xcb.c | 26 +++++++++++++------------- src/commands.c | 4 ++-- src/handlers.c | 4 ++-- src/sighandler.c | 2 +- src/util.c | 2 +- src/workspace.c | 2 +- testcases/inject_randr1.5.c | 2 +- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7897a5dc..8098035c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ install: script: - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-safe-wrappers.sh - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-formatting.sh - - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${BASENAME} /bin/sh -c 'autoreconf -fi && mkdir -p build && cd build && (../configure || (cat config.log; false)) && make -j CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Wstrict-prototypes -Werror"' + - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${BASENAME} /bin/sh -c 'autoreconf -fi && mkdir -p build && cd build && (../configure || (cat config.log; false)) && make -j CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Werror"' - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-spelling.pl - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${BASENAME} ./travis/run-tests.sh - ./travis/skip-pkg.sh || docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/debian-build.sh deb/debian-amd64/DIST diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 1cd7d512a..bb5ceaff0 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -133,7 +133,7 @@ __attribute__((format(printf, 1, 2))) static void set_statusline_error(const cha * Stop and free() the stdin- and SIGCHLD-watchers * */ -void cleanup(void) { +static void cleanup(void) { if (stdin_io != NULL) { ev_io_stop(main_loop, stdin_io); FREE(stdin_io); @@ -400,7 +400,7 @@ static bool read_json_input(unsigned char *input, int length) { * in statusline * */ -void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { +static void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { int rec; unsigned char *buffer = get_buffer(watcher, &rec); if (buffer == NULL) @@ -420,7 +420,7 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { * whether this is JSON or plain text * */ -void stdin_io_first_line_cb(struct ev_loop *loop, ev_io *watcher, int revents) { +static void stdin_io_first_line_cb(struct ev_loop *loop, ev_io *watcher, int revents) { int rec; unsigned char *buffer = get_buffer(watcher, &rec); if (buffer == NULL) @@ -457,7 +457,7 @@ void stdin_io_first_line_cb(struct ev_loop *loop, ev_io *watcher, int revents) { * anymore * */ -void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) { +static void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) { int exit_status = WEXITSTATUS(watcher->rstatus); ELOG("Child (pid: %d) unexpectedly exited with status %d\n", @@ -477,7 +477,7 @@ void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) { draw_bars(false); } -void child_write_output(void) { +static void child_write_output(void) { if (child.click_events) { const unsigned char *output; size_t size; @@ -580,7 +580,7 @@ void start_child(char *command) { atexit(kill_child_at_exit); } -void child_click_events_initialize(void) { +static void child_click_events_initialize(void) { if (!child.click_events_init) { yajl_gen_array_open(gen); child_write_output(); @@ -588,7 +588,7 @@ void child_click_events_initialize(void) { } } -void child_click_events_key(const char *key) { +static void child_click_events_key(const char *key) { yajl_gen_string(gen, (const unsigned char *)key, strlen(key)); } diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index 9a7fb21eb..df5a12cfc 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -34,7 +34,7 @@ typedef void (*handler_t)(char *); * Since i3 does not give us much feedback on commands, we do not much * */ -void got_command_reply(char *reply) { +static void got_command_reply(char *reply) { /* TODO: Error handling for command replies */ } @@ -42,7 +42,7 @@ void got_command_reply(char *reply) { * Called, when we get a reply with workspaces data * */ -void got_workspace_reply(char *reply) { +static void got_workspace_reply(char *reply) { DLOG("Got workspace data!\n"); parse_workspaces_json(reply); draw_bars(false); @@ -53,7 +53,7 @@ void got_workspace_reply(char *reply) { * Since i3 does not give us much feedback on commands, we do not much * */ -void got_subscribe_reply(char *reply) { +static void got_subscribe_reply(char *reply) { DLOG("Got subscribe reply: %s\n", reply); /* TODO: Error handling for subscribe commands */ } @@ -62,7 +62,7 @@ void got_subscribe_reply(char *reply) { * Called, when we get a reply with outputs data * */ -void got_output_reply(char *reply) { +static void got_output_reply(char *reply) { DLOG("Clearing old output configuration...\n"); free_outputs(); @@ -87,7 +87,7 @@ void got_output_reply(char *reply) { * Called when we get the configuration for our bar instance * */ -void got_bar_config(char *reply) { +static void got_bar_config(char *reply) { DLOG("Received bar config \"%s\"\n", reply); /* We initiate the main function by requesting infos about the outputs and * workspaces. Everything else (creating the bars, showing the right workspace- @@ -132,7 +132,7 @@ handler_t reply_handlers[] = { * Called, when a workspace event arrives (i.e. the user changed the workspace) * */ -void got_workspace_event(char *event) { +static void got_workspace_event(char *event) { DLOG("Got workspace event!\n"); i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL); } @@ -141,7 +141,7 @@ void got_workspace_event(char *event) { * Called, when an output event arrives (i.e. the screen configuration changed) * */ -void got_output_event(char *event) { +static void got_output_event(char *event) { DLOG("Got output event!\n"); i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL); if (!config.disable_ws) { @@ -153,7 +153,7 @@ void got_output_event(char *event) { * Called, when a mode event arrives (i3 changed binding mode). * */ -void got_mode_event(char *event) { +static void got_mode_event(char *event) { DLOG("Got mode event!\n"); parse_mode_json(event); draw_bars(false); @@ -163,7 +163,7 @@ void got_mode_event(char *event) { * Called, when a barconfig_update event arrives (i.e. i3 changed the bar hidden_state or mode) * */ -void got_bar_config_update(char *event) { +static void got_bar_config_update(char *event) { /* check whether this affect this bar instance by checking the bar_id */ char *expected_id; sasprintf(&expected_id, "\"id\":\"%s\"", config.bar_id); @@ -213,7 +213,7 @@ handler_t event_handlers[] = { * Called, when we get a message from i3 * */ -void got_data(struct ev_loop *loop, ev_io *watcher, int events) { +static void got_data(struct ev_loop *loop, ev_io *watcher, int events) { DLOG("Got data!\n"); int fd = watcher->fd; diff --git a/i3bar/src/main.c b/i3bar/src/main.c index f90bb3129..a818dd971 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -44,7 +44,7 @@ void debuglog(char *fmt, ...) { * Glob path, i.e. expand ~ * */ -char *expand_path(char *path) { +static char *expand_path(char *path) { static glob_t globbuf; if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) { ELOG("glob() failed\n"); @@ -55,7 +55,7 @@ char *expand_path(char *path) { return result; } -void print_usage(char *elf_name) { +static void print_usage(char *elf_name) { printf("Usage: %s -b bar_id [-s sock_path] [-h] [-v]\n", elf_name); printf("\n"); printf("-b, --bar_id \tBar ID for which to get the configuration\n"); @@ -76,7 +76,7 @@ void print_usage(char *elf_name) { * in main() with that * */ -void sig_cb(struct ev_loop *loop, ev_signal *watcher, int revents) { +static void sig_cb(struct ev_loop *loop, ev_signal *watcher, int revents) { switch (watcher->signum) { case SIGTERM: DLOG("Got a SIGTERM, stopping\n"); diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 66d2fca6c..66003425a 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -146,13 +146,13 @@ int _xcb_request_failed(xcb_void_cookie_t cookie, char *err_msg, int line) { return 0; } -uint32_t get_sep_offset(struct status_block *block) { +static uint32_t get_sep_offset(struct status_block *block) { if (!block->no_separator && block->sep_block_width > 0) return block->sep_block_width / 2 + block->sep_block_width % 2; return 0; } -int get_tray_width(struct tc_head *trayclients) { +static int get_tray_width(struct tc_head *trayclients) { trayclient *trayclient; int tray_width = 0; TAILQ_FOREACH_REVERSE(trayclient, trayclients, tc_head, tailq) { @@ -193,7 +193,7 @@ static void draw_separator(i3_output *output, uint32_t x, struct status_block *b } } -uint32_t predict_statusline_length(bool use_short_text) { +static uint32_t predict_statusline_length(bool use_short_text) { uint32_t width = 0; struct status_block *block; @@ -245,7 +245,7 @@ uint32_t predict_statusline_length(bool use_short_text) { /* * Redraws the statusline to the output's statusline_buffer */ -void draw_statusline(i3_output *output, uint32_t clip_left, bool use_focus_colors, bool use_short_text) { +static void draw_statusline(i3_output *output, uint32_t clip_left, bool use_focus_colors, bool use_short_text) { struct status_block *block; color_t bar_color = (use_focus_colors ? colors.focus_bar_bg : colors.bar_bg); @@ -330,7 +330,7 @@ void draw_statusline(i3_output *output, uint32_t clip_left, bool use_focus_color * Hides all bars (unmaps them) * */ -void hide_bars(void) { +static void hide_bars(void) { if ((config.hide_on_modifier == M_DOCK) || (config.hidden_state == S_SHOW && config.hide_on_modifier == M_HIDE)) { return; } @@ -349,7 +349,7 @@ void hide_bars(void) { * Unhides all bars (maps them) * */ -void unhide_bars(void) { +static void unhide_bars(void) { if (config.hide_on_modifier != M_HIDE) { return; } @@ -457,7 +457,7 @@ static bool execute_custom_command(xcb_keycode_t input_code, bool event_is_relea * wheel was used and change the workspace appropriately * */ -void handle_button(xcb_button_press_event_t *event) { +static void handle_button(xcb_button_press_event_t *event) { /* Determine, which bar was clicked */ i3_output *walk; xcb_window_t bar = event->event; @@ -1080,7 +1080,7 @@ static void handle_resize_request(xcb_resize_request_event_t *event) { * events from X11, handle them, then flush our outgoing queue. * */ -void xcb_prep_cb(struct ev_loop *loop, ev_prepare *watcher, int revents) { +static void xcb_prep_cb(struct ev_loop *loop, ev_prepare *watcher, int revents) { xcb_generic_event_t *event; if (xcb_connection_has_error(xcb_connection)) { @@ -1177,7 +1177,7 @@ void xcb_prep_cb(struct ev_loop *loop, ev_prepare *watcher, int revents) { * are triggered * */ -void xcb_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { +static void xcb_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { } /* @@ -1248,7 +1248,7 @@ char *init_xcb_early(void) { * in xcb. * */ -void register_xkb_keyevents(void) { +static void register_xkb_keyevents(void) { const xcb_query_extension_reply_t *extreply; extreply = xcb_get_extension_data(conn, &xcb_xkb_id); if (!extreply->present) { @@ -1272,7 +1272,7 @@ void register_xkb_keyevents(void) { * Deregister from xkb keyevents. * */ -void deregister_xkb_keyevents(void) { +static void deregister_xkb_keyevents(void) { xcb_xkb_select_events(conn, XCB_XKB_ID_USE_CORE_KBD, 0, @@ -1338,7 +1338,7 @@ static void send_tray_clientmessage(void) { * atom. Afterwards, tray clients will send ClientMessages to our window. * */ -void init_tray(void) { +static void init_tray(void) { DLOG("Initializing system tray functionality\n"); /* request the tray manager atom for the X11 display we are running on */ char atomname[strlen("_NET_SYSTEM_TRAY_S") + 11]; @@ -1567,7 +1567,7 @@ void destroy_window(i3_output *output) { /* Strut partial tells i3 where to reserve space for i3bar. This is determined * by the `position` bar config directive. */ -xcb_void_cookie_t config_strut_partial(i3_output *output) { +static xcb_void_cookie_t config_strut_partial(i3_output *output) { /* A local struct to save the strut_partial property */ struct { uint32_t left; diff --git a/src/commands.c b/src/commands.c index 70f3bf185..45ce1a3c6 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2034,7 +2034,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) { * Implementation of 'bar mode dock|hide|invisible|toggle []' * */ -bool cmd_bar_mode(const char *bar_mode, const char *bar_id) { +static bool cmd_bar_mode(const char *bar_mode, const char *bar_id) { int mode = M_DOCK; bool toggle = false; if (strcmp(bar_mode, "dock") == 0) @@ -2079,7 +2079,7 @@ bool cmd_bar_mode(const char *bar_mode, const char *bar_id) { * Implementation of 'bar hidden_state hide|show|toggle []' * */ -bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id) { +static bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id) { int hidden_state = S_SHOW; bool toggle = false; if (strcmp(bar_hidden_state, "hide") == 0) diff --git a/src/handlers.c b/src/handlers.c index c76f1935d..238cf26f5 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -949,8 +949,8 @@ static void handle_client_message(xcb_client_message_event_t *event) { } } -bool handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, - xcb_atom_t atom, xcb_get_property_reply_t *reply) { +static bool handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, + xcb_atom_t atom, xcb_get_property_reply_t *reply) { Con *con; if ((con = con_by_window_id(window)) == NULL || con->window == NULL) return false; diff --git a/src/sighandler.c b/src/sighandler.c index a5115aa4a..e49c30ba6 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -299,7 +299,7 @@ static void sighandler_handle_key_press(xcb_key_press_event_t *event) { } } -void handle_signal(int sig, siginfo_t *info, void *data) { +static void handle_signal(int sig, siginfo_t *info, void *data) { DLOG("i3 crashed. SIG: %d\n", sig); struct sigaction action; diff --git a/src/util.c b/src/util.c index 594d2bb6d..85f359c0f 100644 --- a/src/util.c +++ b/src/util.c @@ -217,7 +217,7 @@ static char **add_argument(char **original, char *opt_char, char *opt_arg, char #define y(x, ...) yajl_gen_##x(gen, ##__VA_ARGS__) #define ystr(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str)) -char *store_restart_layout(void) { +static char *store_restart_layout(void) { setlocale(LC_NUMERIC, "C"); yajl_gen gen = yajl_gen_alloc(NULL); diff --git a/src/workspace.c b/src/workspace.c index 5f5c8d4f3..0cd72cf80 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -308,7 +308,7 @@ bool workspace_is_visible(Con *ws) { * XXX: we need to clean up all this recursive walking code. * */ -Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) { +static Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) { Con *current; TAILQ_FOREACH(current, &(con->nodes_head), nodes) { diff --git a/testcases/inject_randr1.5.c b/testcases/inject_randr1.5.c index 5506d67e7..520b02131 100644 --- a/testcases/inject_randr1.5.c +++ b/testcases/inject_randr1.5.c @@ -34,7 +34,7 @@ static void read_server_x11_packet_cb(EV_P_ ev_io *w, int revents); static char *sun_path = NULL; -void cleanup_socket(void) { +static void cleanup_socket(void) { if (sun_path != NULL) { unlink(sun_path); free(sun_path);