opt: Initialize all Client Pointers to NULL

This commit is contained in:
DreamMaoMao 2025-10-06 14:11:36 +08:00
parent a765641f4c
commit 1eb5904aa6
8 changed files with 51 additions and 52 deletions

View file

@ -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) {

View file

@ -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;