1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Use null check convention in windows.c

This commit is contained in:
James Booth 2015-05-04 23:12:55 +01:00
parent c19a05ca09
commit a71d1dab6a

View File

@ -84,7 +84,7 @@ wins_get_chat(const char * const barejid)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_CHAT) { if (window->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)window; ProfChatWin *chatwin = (ProfChatWin*)window;
@ -106,7 +106,7 @@ wins_get_muc_conf(const char * const roomjid)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_MUC_CONFIG) { if (window->type == WIN_MUC_CONFIG) {
ProfMucConfWin *confwin = (ProfMucConfWin*)window; ProfMucConfWin *confwin = (ProfMucConfWin*)window;
@ -128,7 +128,7 @@ wins_get_muc(const char * const roomjid)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_MUC) { if (window->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
@ -150,7 +150,7 @@ wins_get_private(const char * const fulljid)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_PRIVATE) { if (window->type == WIN_PRIVATE) {
ProfPrivateWin *privatewin = (ProfPrivateWin*)window; ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
@ -169,7 +169,7 @@ wins_get_private(const char * const fulljid)
ProfWin * ProfWin *
wins_get_current(void) wins_get_current(void)
{ {
if (windows != NULL) { if (windows) {
return g_hash_table_lookup(windows, GINT_TO_POINTER(current)); return g_hash_table_lookup(windows, GINT_TO_POINTER(current));
} else { } else {
return NULL; return NULL;
@ -286,7 +286,7 @@ wins_get_next(void)
GList *curr = keys; GList *curr = keys;
// find our place in the list // find our place in the list
while (curr != NULL) { while (curr) {
if (current == GPOINTER_TO_INT(curr->data)) { if (current == GPOINTER_TO_INT(curr->data)) {
break; break;
} }
@ -295,7 +295,7 @@ wins_get_next(void)
// if there is a next window return it // if there is a next window return it
curr = g_list_next(curr); curr = g_list_next(curr);
if (curr != NULL) { if (curr) {
int next = GPOINTER_TO_INT(curr->data); int next = GPOINTER_TO_INT(curr->data);
g_list_free(keys); g_list_free(keys);
return wins_get_by_num(next); return wins_get_by_num(next);
@ -315,7 +315,7 @@ wins_get_previous(void)
GList *curr = keys; GList *curr = keys;
// find our place in the list // find our place in the list
while (curr != NULL) { while (curr) {
if (current == GPOINTER_TO_INT(curr->data)) { if (current == GPOINTER_TO_INT(curr->data)) {
break; break;
} }
@ -324,7 +324,7 @@ wins_get_previous(void)
// if there is a previous window return it // if there is a previous window return it
curr = g_list_previous(curr); curr = g_list_previous(curr);
if (curr != NULL) { if (curr) {
int previous = GPOINTER_TO_INT(curr->data); int previous = GPOINTER_TO_INT(curr->data);
g_list_free(keys); g_list_free(keys);
return wins_get_by_num(previous); return wins_get_by_num(previous);
@ -342,7 +342,7 @@ wins_get_num(ProfWin *window)
GList *keys = g_hash_table_get_keys(windows); GList *keys = g_hash_table_get_keys(windows);
GList *curr = keys; GList *curr = keys;
while (curr != NULL) { while (curr) {
gconstpointer num_p = curr->data; gconstpointer num_p = curr->data;
ProfWin *curr_win = g_hash_table_lookup(windows, num_p); ProfWin *curr_win = g_hash_table_lookup(windows, num_p);
if (curr_win == window) { if (curr_win == window) {
@ -468,7 +468,7 @@ wins_get_total_unread(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
result += win_unread(window); result += win_unread(window);
curr = g_list_next(curr); curr = g_list_next(curr);
@ -484,7 +484,7 @@ wins_resize_all(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
int subwin_cols = 0; int subwin_cols = 0;
@ -564,7 +564,7 @@ wins_get_xmlconsole(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_XML) { if (window->type == WIN_XML) {
ProfXMLWin *xmlwin = (ProfXMLWin*)window; ProfXMLWin *xmlwin = (ProfXMLWin*)window;
@ -586,7 +586,7 @@ wins_get_chat_recipients(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type == WIN_CHAT) { if (window->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)window; ProfChatWin *chatwin = (ProfChatWin*)window;
@ -605,7 +605,7 @@ wins_get_prune_wins(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (win_unread(window) == 0 && if (win_unread(window) == 0 &&
window->type != WIN_MUC && window->type != WIN_MUC &&
@ -626,7 +626,7 @@ wins_lost_connection(void)
GList *values = g_hash_table_get_values(windows); GList *values = g_hash_table_get_values(windows);
GList *curr = values; GList *curr = values;
while (curr != NULL) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type != WIN_CONSOLE) { if (window->type != WIN_CONSOLE) {
win_print(window, '-', NULL, 0, THEME_ERROR, "", "Lost connection."); win_print(window, '-', NULL, 0, THEME_ERROR, "", "Lost connection.");
@ -719,7 +719,7 @@ wins_tidy(void)
int num = 1; int num = 1;
GList *curr = keys; GList *curr = keys;
while (curr != NULL) { while (curr) {
ProfWin *window = g_hash_table_lookup(windows, curr->data); ProfWin *window = g_hash_table_lookup(windows, curr->data);
if (num == 10) { if (num == 10) {
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window); g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
@ -761,7 +761,7 @@ wins_create_summary(void)
keys = g_list_sort(keys, cmp_win_num); keys = g_list_sort(keys, cmp_win_num);
GList *curr = keys; GList *curr = keys;
while (curr != NULL) { while (curr) {
ProfWin *window = g_hash_table_lookup(windows, curr->data); ProfWin *window = g_hash_table_lookup(windows, curr->data);
int ui_index = GPOINTER_TO_INT(curr->data); int ui_index = GPOINTER_TO_INT(curr->data);