diff --git a/src/config/parse_config.h b/src/config/parse_config.h index fef246a..9ad0680 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -2858,7 +2858,7 @@ void reapply_monitor_rules(void) { } void reapply_border(void) { - Client *c; + Client *c = NULL; // reset border width when config change wl_list_for_each(c, &clients, link) { diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index f8269c4..e1ebbaf 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -75,7 +75,7 @@ void exchange_client(const Arg *arg) { void exchange_stack_client(const Arg *arg) { Client *c = selmon->sel; - Client *tc; + Client *tc = NULL; if (!c || c->isfloating || c->isfullscreen || c->ismaxmizescreen) return; if (arg->i == NEXT) { @@ -88,7 +88,7 @@ void exchange_stack_client(const Arg *arg) { } void focusdir(const Arg *arg) { - Client *c; + Client *c = NULL; c = direction_select(arg); if (c) { focusclient(c, 1); @@ -149,7 +149,7 @@ void toggle_trackpad_enable(const Arg *arg) { } void focusmon(const Arg *arg) { - Client *c, *old_selmon_sel; + Client *c = NULL, *old_selmon_sel = NULL; Monitor *m = NULL; if (arg->i != UNDIR) { @@ -295,7 +295,7 @@ setmfact(const Arg *arg) { } void killclient(const Arg *arg) { - Client *c; + Client *c = NULL; c = selmon->sel; if (c) { pending_kill_client(c); @@ -333,7 +333,7 @@ moveresize(const Arg *arg) { } void movewin(const Arg *arg) { - Client *c; + Client *c = NULL; c = selmon->sel; if (!c || c->isfullscreen) return; @@ -375,7 +375,7 @@ quit(const Arg *arg) { } void resizewin(const Arg *arg) { - Client *c; + Client *c = NULL; c = selmon->sel; if (!c || c->isfullscreen) return; @@ -412,7 +412,7 @@ void resizewin(const Arg *arg) { } void restore_minimized(const Arg *arg) { - Client *c; + Client *c = NULL; if (selmon && selmon->isoverview) return; @@ -469,7 +469,7 @@ void set_proportion(const Arg *arg) { } void smartmovewin(const Arg *arg) { - Client *c, *tc; + Client *c = NULL, *tc = NULL; int nx, ny; int buttom, top, left, right, tar; c = selmon->sel; @@ -569,7 +569,7 @@ void smartmovewin(const Arg *arg) { } void smartresizewin(const Arg *arg) { - Client *c, *tc; + Client *c = NULL, *tc = NULL; int nw, nh; int buttom, top, left, right, tar; c = selmon->sel; @@ -638,7 +638,7 @@ void smartresizewin(const Arg *arg) { } void centerwin(const Arg *arg) { - Client *c; + Client *c = NULL; c = selmon->sel; if (!c || c->isfullscreen) @@ -718,7 +718,7 @@ void spawn(const Arg *arg) { void spawn_on_empty(const Arg *arg) { bool is_empty = true; - Client *c; + Client *c = NULL; wl_list_for_each(c, &clients, link) { if (arg->ui & c->tags && c->mon == selmon) { @@ -997,8 +997,8 @@ void tagmon(const Arg *arg) { } void tagsilent(const Arg *arg) { - Client *fc; - Client *target_client; + Client *fc = NULL; + Client *target_client = NULL; if (!selmon || !selmon->sel) return; @@ -1053,7 +1053,7 @@ void toggle_render_border(const Arg *arg) { arrange(selmon, false); } void toggle_scratchpad(const Arg *arg) { - Client *c; + Client *c = NULL; bool hit = false; Client *tmp = NULL; @@ -1312,7 +1312,7 @@ void comboview(const Arg *arg) { } void zoom(const Arg *arg) { - Client *c, *sel = focustop(selmon); + Client *c = NULL, *sel = focustop(selmon); if (!sel || !selmon || !selmon->pertag->ltidxs[selmon->pertag->curtag]->arrange || diff --git a/src/ext-protocol/dwl-ipc.h b/src/ext-protocol/dwl-ipc.h index 941f879..e29ac3b 100644 --- a/src/ext-protocol/dwl-ipc.h +++ b/src/ext-protocol/dwl-ipc.h @@ -109,7 +109,7 @@ void dwl_ipc_output_printstatus(Monitor *monitor) { void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) { Monitor *monitor = ipc_output->mon; - Client *c, *focused; + Client *c = NULL, *focused = NULL; struct wlr_keyboard *keyboard; xkb_layout_index_t current; int tagmask, state, numclients, focused_client, tag; @@ -208,7 +208,7 @@ void dwl_ipc_output_set_client_tags(struct wl_client *client, unsigned int xor_tags) { DwlIpcOutput *ipc_output; Monitor *monitor; - Client *selected_client; + Client *selected_client = NULL; unsigned int newtags = 0; ipc_output = wl_resource_get_user_data(resource); diff --git a/src/fetch/client.h b/src/fetch/client.h index 79d0bf0..961aac3 100644 --- a/src/fetch/client.h +++ b/src/fetch/client.h @@ -18,7 +18,7 @@ bool check_hit_no_border(Client *c) { return hit_no_border; } Client *termforwin(Client *w) { - Client *c; + Client *c = NULL; if (!w->pid || w->isterm || w->noswallow) return NULL; @@ -143,7 +143,7 @@ Client *center_tiled_select(Monitor *m) { } Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, bool align) { - Client *c; + Client *c = NULL; Client **tempClients = NULL; // 初始化为 NULL int last = -1; @@ -324,9 +324,8 @@ Client *direction_select(const Arg *arg) { /* We probably should change the name of this, it sounds like * will focus the topmost client of this mon, when actually will * only return that client */ -Client * // 0.5 -focustop(Monitor *m) { - Client *c; +Client *focustop(Monitor *m) { + Client *c = NULL; wl_list_for_each(c, &fstack, flink) { if (c->iskilling || c->isunglobal) continue; diff --git a/src/fetch/monitor.h b/src/fetch/monitor.h index 2a79b29..630d084 100644 --- a/src/fetch/monitor.h +++ b/src/fetch/monitor.h @@ -28,7 +28,7 @@ bool is_scroller_layout(Monitor *m) { } unsigned int get_tag_status(unsigned int tag, Monitor *m) { - Client *c; + Client *c = NULL; unsigned int status = 0; wl_list_for_each(c, &clients, link) { if (c->mon == m && c->tags & 1 << (tag - 1) & TAGMASK) { diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index e211140..241d58f 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -1,6 +1,6 @@ void fibonacci(Monitor *mon, int s) { unsigned int i = 0, n = 0, nx, ny, nw, nh; - Client *c; + Client *c = NULL; unsigned int cur_gappih = enablegaps ? mon->gappih : 0; unsigned int cur_gappiv = enablegaps ? mon->gappiv : 0; unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0; @@ -88,7 +88,7 @@ void fibonacci(Monitor *mon, int s) { unsigned int right_gap = 0; unsigned int bottom_gap = 0; - Client *nc; + Client *nc = NULL; wl_list_for_each(nc, &clients, link) { if (!VISIBLEON(nc, mon) || !ISTILED(nc)) @@ -129,7 +129,7 @@ void grid(Monitor *m) { unsigned int cx, cy, cw, ch; unsigned int dx; unsigned int cols, rows, overcols; - Client *c; + Client *c = NULL; n = 0; n = m->isoverview ? m->visible_clients : m->visible_tiling_clients; @@ -246,7 +246,7 @@ void grid(Monitor *m) { void deck(Monitor *m) { unsigned int mw, my; int i, n = 0; - Client *c; + Client *c = NULL; unsigned int cur_gappih = enablegaps ? m->gappih : 0; unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; @@ -304,7 +304,7 @@ void deck(Monitor *m) { void scroller(Monitor *m) { unsigned int i, n, j; - Client *c, *root_client = NULL; + Client *c = NULL, *root_client = NULL; Client **tempClients = NULL; // 初始化为 NULL struct wlr_box target_geom; int focus_client_index = 0; @@ -434,7 +434,7 @@ void scroller(Monitor *m) { void center_tile(Monitor *m) { unsigned int i, n = 0, h, mw, mx, my, oty, ety, tw; - Client *c; + Client *c = NULL; n = m->visible_tiling_clients; if (n == 0) @@ -575,7 +575,7 @@ void center_tile(Monitor *m) { void tile(Monitor *m) { unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty; - Client *c; + Client *c = NULL; n = m->visible_tiling_clients; @@ -631,7 +631,7 @@ void tile(Monitor *m) { void // 17 monocle(Monitor *m) { - Client *c; + Client *c = NULL; struct wlr_box geom; wl_list_for_each(c, &clients, link) { diff --git a/src/layout/vertical.h b/src/layout/vertical.h index c6d7226..ba788c2 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -1,6 +1,6 @@ void vertical_fibonacci(Monitor *mon, int s) { unsigned int i = 0, n = 0, nx, ny, nw, nh; - Client *c; + Client *c = NULL; unsigned int cur_gappih = enablegaps ? mon->gappih : 0; unsigned int cur_gappiv = enablegaps ? mon->gappiv : 0; unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0; @@ -88,7 +88,7 @@ void vertical_fibonacci(Monitor *mon, int s) { unsigned int right_gap = 0; unsigned int bottom_gap = 0; - Client *nc; + Client *nc = NULL; wl_list_for_each(nc, &clients, link) { if (!VISIBLEON(nc, mon) || !ISTILED(nc)) @@ -128,7 +128,7 @@ void vertical_grid(Monitor *m) { unsigned int cx, cy, cw, ch; unsigned int dy; unsigned int rows, cols, overrows; - Client *c; + Client *c = NULL; n = m->isoverview ? m->visible_clients : m->visible_tiling_clients; @@ -242,7 +242,7 @@ void vertical_grid(Monitor *m) { void vertical_deck(Monitor *m) { unsigned int mh, mx; int i, n = 0; - Client *c; + Client *c = NULL; unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; @@ -294,7 +294,7 @@ void vertical_deck(Monitor *m) { void vertical_scroller(Monitor *m) { unsigned int i, n, j; - Client *c, *root_client = NULL; + Client *c = NULL, *root_client = NULL; Client **tempClients = NULL; struct wlr_box target_geom; int focus_client_index = 0; @@ -421,7 +421,7 @@ void vertical_scroller(Monitor *m) { void vertical_tile(Monitor *m) { unsigned int i, n = 0, w, r, ie = enablegaps, mh, mx, tx; - Client *c; + Client *c = NULL; n = m->visible_tiling_clients; diff --git a/src/mango.c b/src/mango.c index 3162f8e..3e92546 100644 --- a/src/mango.c +++ b/src/mango.c @@ -1227,7 +1227,7 @@ void applyrules(Client *c) { unsigned int i, newtags = 0; const ConfigWinRule *r; Monitor *mon = selmon, *m; - Client *fc; + Client *fc = NULL; bool hit_rule_pos = false; c->isfloating = client_is_float_type(c); @@ -1360,7 +1360,7 @@ void applyrules(Client *c) { void // 17 arrange(Monitor *m, bool want_animation) { - Client *c; + Client *c = NULL; if (!m) return; @@ -1446,7 +1446,7 @@ void apply_window_snap(Client *c) { cw = c->geom.width - 2 * cbw; ch = c->geom.height - 2 * cbw; - Client *tc; + Client *tc = NULL; if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling) return; @@ -1817,10 +1817,10 @@ buttonpress(struct wl_listener *listener, void *data) { struct wlr_pointer_button_event *event = data; struct wlr_keyboard *hard_keyboard, *keyboard; unsigned int hard_mods, mods; - Client *c; - LayerSurface *l; + Client *c = NULL; + LayerSurface *l = NULL; struct wlr_surface *surface; - Client *tmpc; + Client *tmpc = NULL; int ji; const MouseBinding *m; struct wlr_surface *old_pointer_focus_surface = @@ -2075,7 +2075,7 @@ void cleanupmon(struct wl_listener *listener, void *data) { void closemon(Monitor *m) { /* update selmon if needed and * move closed monitor's clients to the focused one */ - Client *c; + Client *c = NULL; int i = 0, nmons = wl_list_length(&mons); if (!nmons) { selmon = NULL; @@ -3537,7 +3537,7 @@ void // old fix to 0.5 mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ Client *p = NULL; - Client *at_client; + Client *at_client = NULL; Client *c = wl_container_of(listener, c, map); /* Create scene tree for this client and its border */ c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); @@ -4071,7 +4071,7 @@ void client_set_opacity(Client *c, double opacity) { void rendermon(struct wl_listener *listener, void *data) { Monitor *m = wl_container_of(listener, m, frame); - Client *c, *tmp; + Client *c = NULL, *tmp = NULL; struct wlr_output_state pending = {0}; LayerSurface *l, *tmpl; int i; @@ -4321,7 +4321,7 @@ void setcursor(struct wl_listener *listener, void *data) { void // 0.5 setfloating(Client *c, int floating) { - Client *fc; + Client *fc = NULL; int hit; struct wlr_box target_box, backup_box; c->isfloating = floating; @@ -4988,7 +4988,7 @@ void startdrag(struct wl_listener *listener, void *data) { } void tag_client(const Arg *arg, Client *target_client) { - Client *fc; + Client *fc = NULL; if (target_client && arg->ui & TAGMASK) { target_client->tags = arg->ui & TAGMASK; @@ -5109,7 +5109,7 @@ int hidecursor(void *data) { // 显示所有tag 或 跳转到聚焦窗口的tag void toggleoverview(const Arg *arg) { - Client *c; + Client *c = NULL; if (selmon->isoverview && ov_tab_mode && arg->i != -1 && selmon->sel) { focusstack(&(Arg){.i = 1}); @@ -5287,7 +5287,7 @@ void updatemons(struct wl_listener *listener, void *data) { */ struct wlr_output_configuration_v1 *config = wlr_output_configuration_v1_create(); - Client *c; + Client *c = NULL; struct wlr_output_configuration_head_v1 *config_head; Monitor *m; int mon_pos_offsetx, mon_pos_offsety, oldx, oldy; @@ -5633,7 +5633,7 @@ void configurex11(struct wl_listener *listener, void *data) { void createnotifyx11(struct wl_listener *listener, void *data) { struct wlr_xwayland_surface *xsurface = data; - Client *c; + Client *c = NULL; /* Allocate a Client for this surface */ c = xsurface->data = ecalloc(1, sizeof(*c));