From 369e95c1df681537492ac4132fcc439a66dd7884 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 26 Aug 2010 01:34:13 +0000 Subject: Revert and re-apply badnull patch Revert previous patch generated by badnull.cocci script, and apply the new one. The main difference is that assert and assert-like functions are not touched anymore. SVN revision: 51650 --- src/actions.c | 2 +- src/buttons.c | 20 +++++++-------- src/command.c | 42 +++++++++++++++--------------- src/defaultfont.c | 8 +++--- src/draw.c | 2 +- src/e.c | 6 ++--- src/events.c | 8 +++--- src/font.c | 24 +++++++++--------- src/grkelot.c | 8 +++--- src/menus.c | 22 ++++++++-------- src/misc.c | 2 +- src/options.c | 50 ++++++++++++++++++------------------ src/options.h | 2 +- src/pixmap.c | 46 ++++++++++++++++----------------- src/screen.c | 36 +++++++++++++------------- src/script.c | 14 +++++----- src/scrollbar.c | 2 +- src/startup.c | 12 ++++----- src/term.c | 76 +++++++++++++++++++++++++++---------------------------- src/utmp.c | 12 ++++----- src/windows.c | 12 ++++----- 21 files changed, 202 insertions(+), 204 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index ca575ff..c7ce94b 100644 --- a/src/actions.c +++ b/src/actions.c @@ -228,7 +228,7 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_ action_t *action; - if (!action_list || (action = action_find_match(mod, button, keysym)) == NULL) { + if (!action_list || !(action = action_find_match(mod, button, keysym))) { action = (action_t *) MALLOC(sizeof(action_t)); action->next = action_list; action_list = action; diff --git a/src/buttons.c b/src/buttons.c index 3f1374c..1c42d5a 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -193,7 +193,7 @@ bbar_handle_enter_notify(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); - if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) { + if (!(bbar = find_bbar_by_window(ev->xany.window))) { return 0; } bbar_draw(bbar, IMAGE_STATE_SELECTED, 0); @@ -215,7 +215,7 @@ bbar_handle_leave_notify(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); - if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) { + if (!(bbar = find_bbar_by_window(ev->xany.window))) { return 0; } bbar_draw(bbar, IMAGE_STATE_NORMAL, 0); @@ -234,7 +234,7 @@ bbar_handle_button_press(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); - if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) { + if (!(bbar = find_bbar_by_window(ev->xany.window))) { D_EVENTS((" -> No buttonbar found for this window.\n")); return 0; } @@ -326,7 +326,7 @@ bbar_handle_button_release(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); - if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) { + if (!(bbar = find_bbar_by_window(ev->xany.window))) { D_EVENTS((" -> No buttonbar found for this window.\n")); return 0; } @@ -364,7 +364,7 @@ bbar_handle_motion_notify(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); - if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) { + if (!(bbar = find_bbar_by_window(ev->xany.window))) { return 0; } while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); @@ -392,7 +392,7 @@ bbar_handle_motion_notify(event_t *ev) unsigned char bbar_dispatch_event(event_t *ev) { - if (buttonbar->event_data.handlers[ev->type] != NULL) { + if (buttonbar->event_data.handlers[ev->type]) { return ((buttonbar->event_data.handlers[ev->type]) (ev)); } return (0); @@ -721,7 +721,7 @@ button_t *find_button_by_index(buttonbar_t *bbar, long idx) } else { b = bbar->buttons; } - for (i = 0; (b != NULL) && (i < idx); b = b->next, i++); + for (i = 0; (b) && (i < idx); b = b->next, i++); return ((i == idx) ? (b) : (NULL)); } @@ -816,19 +816,19 @@ button_set_action(button_t *button, action_type_t type, char *action) switch (type) { case ACTION_MENU: button->action.menu = find_menu_by_title(menu_list, action); - return ((button->action.menu == NULL) ? (0) : (1)); + return ((!button->action.menu) ? (0) : (1)); break; case ACTION_STRING: case ACTION_ECHO: button->action.string = (char *) MALLOC(strlen(action) + 2); strcpy(button->action.string, action); parse_escaped_string(button->action.string); - return ((button->action.string == NULL) ? (0) : (1)); + return ((!button->action.string) ? (0) : (1)); break; case ACTION_SCRIPT: button->action.script = (char *) MALLOC(strlen(action) + 2); strcpy(button->action.script, action); - return ((button->action.script == NULL) ? (0) : (1)); + return ((!button->action.script) ? (0) : (1)); break; default: break; diff --git a/src/command.c b/src/command.c index 65fc09f..0f7fdd3 100644 --- a/src/command.c +++ b/src/command.c @@ -1330,7 +1330,7 @@ sgi_get_pty(void) privileges(INVOKE); ptydev = ttydev = _getpty(&fd, O_RDWR | O_NDELAY, 0620, 0); privileges(REVERT); - return (ptydev == NULL ? -1 : fd); + return (!ptydev ? -1 : fd); } #endif @@ -1411,7 +1411,7 @@ posix_get_pty(void) return (-1); } else { ptydev = ttydev = ptsname(fd); - if (ttydev == NULL) { + if (!ttydev) { libast_print_error("ptsname(%d) failed: %s\n", fd, strerror(errno)); return (-1); } @@ -1509,7 +1509,7 @@ get_tty(void) #endif /* ultrix */ privileges(INVOKE); - if (ttydev == NULL) { + if (!ttydev) { libast_print_error("Slave tty device name is NULL. Failed to open slave pty.\n"); exit(EXIT_FAILURE); } else if ((fd = open(ttydev, O_RDWR)) < 0) { @@ -1908,7 +1908,7 @@ init_locale(void) locale = setlocale(LC_ALL, ""); XSetLocaleModifiers(""); TermWin.fontset = (XFontSet) 0; - if ((locale == NULL) || (!XSupportsLocale())) { + if ((!locale) || (!XSupportsLocale())) { libast_print_warning("Locale not supported; defaulting to portable \"C\" locale.\n"); locale = setlocale(LC_ALL, "C"); XSetLocaleModifiers(""); @@ -1956,7 +1956,7 @@ xim_send_spot(void) static XPoint oldSpot = { -1, -1 }; XVaNestedList preedit_attr; - if (xim_input_context == NULL) { + if (!xim_input_context) { return; } @@ -2045,8 +2045,8 @@ xim_real_init(void) *(end + 1) = '\0'; if (*s) { snprintf(buf, sizeof(buf), "@im=%s", s); - if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) - && ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) { + if (((p = XSetLocaleModifiers(buf))) && (*p) + && ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)))) { break; } } @@ -2057,20 +2057,20 @@ xim_real_init(void) } /* try with XMODIFIERS env. var. */ - if (xim_input_method == NULL && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) != NULL && *p) { + if (!xim_input_method && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) && *p) { xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL); } /* try with no modifiers base */ - if (xim_input_method == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) { + if (!xim_input_method && (p = XSetLocaleModifiers("@im=none")) && *p) { xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL); } - if (xim_input_method == NULL) { + if (!xim_input_method) { xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL); } - if (xim_input_method == NULL) { + if (!xim_input_method) { return -1; } #ifdef USE_X11R6_XIM @@ -2157,7 +2157,7 @@ xim_real_init(void) if (status_attr) { XFree(status_attr); } - if (xim_input_context == NULL) { + if (!xim_input_context) { libast_print_error("Failed to create input context\n"); XCloseIM(xim_input_method); return -1; @@ -2376,7 +2376,7 @@ run_command(char **argv) if (chdir(initial_dir)) { libast_print_warning("Unable to chdir to \"%s\" -- %s\n", initial_dir, strerror(errno)); } - if (argv != NULL) { + if (argv) { #if DEBUG >= DEBUG_CMD if (DEBUG_LEVEL >= DEBUG_CMD) { int i; @@ -2393,7 +2393,7 @@ run_command(char **argv) const char *argv0, *shell; - if ((shell = getenv("SHELL")) == NULL || *shell == '\0') + if (!(shell = getenv("SHELL")) || *shell == '\0') shell = "/bin/sh"; argv0 = my_basename(shell); @@ -3089,14 +3089,14 @@ escreen_init(char **argv) efuns = escreen_reg_funcs(); /* Create buttonbar for Escreen's use. */ - if ((bbar = bbar_create()) == NULL) { - if (buttonbar != NULL) { + if (!(bbar = bbar_create())) { + if (buttonbar) { bbar = buttonbar; } else { return -1; } } else { - if (buttonbar == NULL) { + if (!buttonbar) { buttonbar = bbar; } bbar_set_font(bbar, ((rs_es_font) ? (rs_es_font) : ("-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1"))); @@ -3105,7 +3105,7 @@ escreen_init(char **argv) } BITFIELD_SET(eterm_options, ETERM_OPTIONS_PAUSE); - if ((TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, bbar)) == NULL) { + if (!(TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, bbar))) { D_CMD(("ns_attach_by_URL(%s,%s) failed\n", rs_url, rs_hop)); return -1; } @@ -3284,7 +3284,7 @@ check_pixmap_change(int sig) last_update = now; old_handler = signal(SIGALRM, check_pixmap_change); alarm(rs_anim_delay); - if (rs_anim_pixmaps[image_idx] == NULL) { + if (!rs_anim_pixmaps[image_idx]) { image_idx = 0; } } @@ -3390,7 +3390,7 @@ cmd_getc(void) XNextEvent(Xdisplay, &ev); #ifdef USE_XIM - if (xim_input_context != NULL) { + if (xim_input_context) { if (!XFilterEvent(&ev, ev.xkey.window)) { event_dispatch(&ev); } @@ -3803,7 +3803,7 @@ v_writeBig(int f, char *d, int len) int written; int c = len; - if (v_bufstr == NULL && len > 0) { + if (!v_bufstr && len > 0) { v_buffer = MALLOC(len); v_bufstr = v_buffer; diff --git a/src/defaultfont.c b/src/defaultfont.c index 6200d89..2c45f19 100644 --- a/src/defaultfont.c +++ b/src/defaultfont.c @@ -178,10 +178,10 @@ eterm_default_font_locale(char ***fonts, char ***mfonts, char **mencoding, int * int j, k; locale = setlocale(LC_CTYPE, ""); - if (locale == NULL) - if ((locale = getenv("LC_ALL")) == NULL) - if ((locale = getenv("LC_CTYPE")) == NULL) - if ((locale = getenv("LANG")) == NULL) + if (!locale) + if (!(locale = getenv("LC_ALL"))) + if (!(locale = getenv("LC_CTYPE"))) + if (!(locale = getenv("LANG"))) locale = "C"; /* failsafe */ /* Obtain a "normalized" name of current encoding. diff --git a/src/draw.c b/src/draw.c index 355e246..85a22d0 100644 --- a/src/draw.c +++ b/src/draw.c @@ -168,7 +168,7 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up) real_depth = Xdepth; } ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap); - if (ximg == NULL) { + if (!ximg) { return; } /* Determine bitshift and bitmask values */ diff --git a/src/e.c b/src/e.c index e752fa4..6948e21 100644 --- a/src/e.c +++ b/src/e.c @@ -156,12 +156,12 @@ enl_ipc_send(char *str) unsigned short len; XEvent ev; - if (str == NULL) { + if (!str) { ASSERT(last_msg != NULL); str = last_msg; D_ENL(("Resending last message \"%s\" to Enlightenment.\n", str)); } else { - if (last_msg != NULL) { + if (last_msg) { FREE(last_msg); } last_msg = STRDUP(str); @@ -246,7 +246,7 @@ enl_ipc_get(const char *msg_data) } buff[12] = 0; blen = strlen(buff); - if (message != NULL) { + if (message) { len += blen; message = (char *) REALLOC(message, len + 1); strcat(message, buff); diff --git a/src/events.c b/src/events.c index aa10db5..43f255d 100644 --- a/src/events.c +++ b/src/events.c @@ -353,7 +353,7 @@ handle_client_message(event_t *ev) XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data); - if (data != NULL) { + if (data) { XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data)); selection_paste(XA_CUT_BUFFER0); XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime); @@ -493,7 +493,7 @@ handle_focus_in(event_t *ev) } bbar_draw_all(IMAGE_STATE_NORMAL, MODE_SOLID); #ifdef USE_XIM - if (xim_input_context != NULL) + if (xim_input_context) XSetICFocus(xim_input_context); #endif if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) { @@ -527,7 +527,7 @@ handle_focus_out(event_t *ev) } bbar_draw_all(IMAGE_STATE_DISABLED, MODE_SOLID); #ifdef USE_XIM - if (xim_input_context != NULL) + if (xim_input_context) XUnsetICFocus(xim_input_context); #endif } @@ -874,7 +874,7 @@ process_x_event(event_t *ev) #if 0 D_EVENTS(("process_x_event(ev [%8p] %s on window 0x%08x)\n", ev, event_type_to_name(ev->xany.type), ev->xany.window)); #endif - if (primary_data.handlers[ev->type] != NULL) { + if (primary_data.handlers[ev->type]) { return ((primary_data.handlers[ev->type]) (ev)); } return (0); diff --git a/src/font.c b/src/font.c index 55efbce..4051f64 100644 --- a/src/font.c +++ b/src/font.c @@ -179,7 +179,7 @@ font_cache_add(const char *name, unsigned char type, void *info) D_FONT((" -> Created new cachefont_t struct at %p: \"%s\", %d, %p\n", font, font->name, font->type, font->fontinfo.xfontinfo)); /* Actually add the struct to the end of our cache linked list. */ - if (font_cache == NULL) { + if (!font_cache) { font_cache = cur_font = font; font->next = NULL; D_FONT((" -> Stored as first font in cache. font_cache == cur_font == font == %p\n", font_cache)); @@ -202,7 +202,7 @@ font_cache_del(const void *info) D_FONT(("font_cache_del(%8p) called.\n", info)); - if (font_cache == NULL) { + if (!font_cache) { return; /* No fonts in the cache. Theoretically this should never happen, but... */ } @@ -376,7 +376,7 @@ load_font(const char *name, const char *fallback, unsigned char type) } /* Specify some sane fallbacks */ - if (name == NULL) { + if (!name) { if (fallback) { name = fallback; fallback = "fixed"; @@ -388,14 +388,14 @@ load_font(const char *name, const char *fallback, unsigned char type) fallback = "-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1"; #endif } - } else if (fallback == NULL) { + } else if (!fallback) { fallback = "fixed"; } D_FONT((" -> Using name == \"%s\" and fallback == \"%s\"\n", name, fallback)); /* Look for the font name in the cache. If it's there, add one to the reference count and return the existing fontinfo pointer to the caller. */ - if ((font = font_cache_find(name, type)) != NULL) { + if ((font = font_cache_find(name, type))) { font_cache_add_ref(font); D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt)); switch (type) { @@ -416,9 +416,9 @@ load_font(const char *name, const char *fallback, unsigned char type) /* No match in the cache, so we'll have to add it. */ if (type == FONT_TYPE_X) { - if ((xfont = XLoadQueryFont(Xdisplay, name)) == NULL) { + if (!(xfont = XLoadQueryFont(Xdisplay, name))) { libast_print_error("Unable to load font \"%s\". Falling back on \"%s\"\n", name, fallback); - if ((xfont = XLoadQueryFont(Xdisplay, fallback)) == NULL) { + if (!(xfont = XLoadQueryFont(Xdisplay, fallback))) { libast_fatal_error("Couldn't load the fallback font either. Giving up.\n"); } else { font_cache_add(fallback, type, (void *) xfont); @@ -461,7 +461,7 @@ change_font(int init, const char *fontname) if (init) { ASSERT(etfonts != NULL); - if ((def_font_idx >= font_cnt) || (etfonts[def_font_idx] == NULL)) { + if ((def_font_idx >= font_cnt) || (!etfonts[def_font_idx])) { def_font_idx = font_idx; } else { font_idx = def_font_idx; @@ -518,7 +518,7 @@ change_font(int init, const char *fontname) } /* If we get here with a non-NULL fontname, we have to load a new font. Rats. */ - if (fontname != NULL) { + if (fontname) { eterm_font_add(&etfonts, fontname, font_idx); } else if (font_idx == old_idx) { /* Sigh. What a waste of time, changing to the same font. */ @@ -539,7 +539,7 @@ change_font(int init, const char *fontname) } #ifndef NO_BOLDFONT - if (init && rs_boldFont != NULL) { + if (init && rs_boldFont) { /* If we're initializing, load the bold font too. */ boldFont = load_font(rs_boldFont, "-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1", FONT_TYPE_X); } @@ -636,7 +636,7 @@ change_font(int init, const char *fontname) /* Check the bold font size and make sure it matches the normal font */ #ifndef NO_BOLDFONT TermWin.boldFont = NULL; /* FIXME: Memory leak? Not that anyone uses bold fonts.... */ - if (boldFont != NULL) { + if (boldFont) { fw = boldFont->min_bounds.width; fh = boldFont->ascent + boldFont->descent + rs_line_space; @@ -825,7 +825,7 @@ parse_font_fx(char *line) } set_shadow_color_by_name(which, color); FREE(color); - if (line == NULL) { + if (!line) { break; } } diff --git a/src/grkelot.c b/src/grkelot.c index d8fed71..285dbfb 100644 --- a/src/grkelot.c +++ b/src/grkelot.c @@ -250,7 +250,7 @@ kstate_add_xlat(char *str) char *sval; int i; - if (str == NULL) + if (!str) return; /* add a new xlat table in state */ if (pStateNow->num_xlat == 0) { @@ -263,11 +263,11 @@ kstate_add_xlat(char *str) xlat->last = (u_int) atoi(strtok(NULL, ":")); i = 0; pval_tmp = CALLOC(MAX_VAL, sizeof(K_XLAT)); - while ((sval = strtok(NULL, ",")) != NULL) { + while ((sval = strtok(NULL, ","))) { pval_tmp[i++] = (u_int) (atoi(sval)); } xlat->pval = CALLOC(i, sizeof(K_XLAT)); - if (xlat->pval != NULL) + if (xlat->pval) memcpy(xlat->pval, pval_tmp, i * sizeof(u_int)); FREE(pval_tmp); pStateNow->num_xlat++; @@ -281,7 +281,7 @@ kstate_add_switcher(char *str) { K_SWITCH *switcher; - if (str == NULL) + if (!str) return; if (pStateNow->num_switcher >= MAX_SWITCHER) return; diff --git a/src/menus.c b/src/menus.c index 99143e0..f53c9ea 100644 --- a/src/menus.c +++ b/src/menus.c @@ -301,7 +301,7 @@ menu_handle_button_release(event_t *ev) if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) { /* Take action here based on the current menu item */ - if ((item = menuitem_get_current(current_menu)) != NULL) { + if ((item = menuitem_get_current(current_menu))) { if (item->type == MENUITEM_SUBMENU) { menu_display_submenu(current_menu, item); } else { @@ -326,7 +326,7 @@ menu_handle_button_release(event_t *ev) if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w) && (ev->xbutton.y < current_menu->h)) { /* Click inside the menu window. Activate the current item. */ - if ((item = menuitem_get_current(current_menu)) != NULL) { + if ((item = menuitem_get_current(current_menu))) { if (item->type == MENUITEM_SUBMENU) { menu_display_submenu(current_menu, item); } else { @@ -415,7 +415,7 @@ menu_handle_motion_notify(event_t *ev) unsigned char menu_dispatch_event(event_t *ev) { - if (menu_event_data.handlers[ev->type] != NULL) { + if (menu_event_data.handlers[ev->type]) { return ((menu_event_data.handlers[ev->type]) (ev)); } return (0); @@ -599,7 +599,7 @@ menu_is_child(menu_t *menu, menu_t *submenu) for (i = 0; i < menu->numitems; i++) { item = menu->items[i]; - if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) { + if (item->type == MENUITEM_SUBMENU && item->action.submenu) { if (item->action.submenu == submenu) { return 1; } else if (menu_is_child(item->action.submenu, submenu)) { @@ -686,8 +686,8 @@ menuitem_change_current(menuitem_t *item) menuitem_deselect(current_menu); /* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to no current item at all, reset the tree for the current submenu */ - if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) { - if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL + if (current->type == MENUITEM_SUBMENU && current->action.submenu) { + if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu && !menu_is_child(current->action.submenu, item->action.submenu) && !menu_is_child(item->action.submenu, current->action.submenu)) || (!item)) { @@ -839,7 +839,7 @@ menu_reset_all(menulist_t *list) return; D_MENU(("menu_reset_all(%8p) called\n", list)); - if (current_menu && menuitem_get_current(current_menu) != NULL) { + if (current_menu && menuitem_get_current(current_menu)) { menuitem_deselect(current_menu); } for (i = 0; i < list->nummenus; i++) { @@ -862,7 +862,7 @@ menu_reset_tree(menu_t *menu) } for (i = 0; i < menu->numitems; i++) { item = menu->items[i]; - if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) { + if (item->type == MENUITEM_SUBMENU && item->action.submenu) { menu_reset_tree(item->action.submenu); } } @@ -880,7 +880,7 @@ menu_reset_submenus(menu_t *menu) D_MENU(("menu_reset_submenus(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win)); for (i = 0; i < menu->numitems; i++) { item = menu->items[i]; - if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) { + if (item->type == MENUITEM_SUBMENU && item->action.submenu) { menu_reset_tree(item->action.submenu); } } @@ -1344,11 +1344,11 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v inp_tab = NULL; maxlen = 0; retstr = NULL; - if ((b = STRDUP("Press \"Return\" to continue...")) == NULL) { + if (!(b = STRDUP("Press \"Return\" to continue..."))) { return ret; } } else { - if (((b = MALLOC(maxlen + 1)) == NULL)) { + if ((!(b = MALLOC(maxlen + 1)))) { return ret; } else if (*retstr) { strncpy(b, *retstr, maxlen); diff --git a/src/misc.c b/src/misc.c index f793344..6a94aa1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -285,7 +285,7 @@ safe_print_string(const char *str, unsigned long len) rb_size = 0; return ((char *) NULL); } - if (ret_buff == NULL) { + if (!ret_buff) { rb_size = len; ret_buff = (char *) MALLOC(rb_size + 1); } else if (len > rb_size) { diff --git a/src/options.c b/src/options.c index 2b305a3..aa19b9a 100644 --- a/src/options.c +++ b/src/options.c @@ -1345,7 +1345,7 @@ parse_keyboard(char *buff, void *state) len = parse_escaped_string(str); if (len > 255) len = 255; /* We can only handle lengths that will fit in a char */ - if (len && KeySym_map[sym] == NULL) { + if (len && !KeySym_map[sym]) { char *p = MALLOC(len + 1); @@ -1674,7 +1674,7 @@ parse_image(char *buff, void *state) if (allow_list) { char *allow; - for (; (allow = (char *) strsep(&allow_list, " ")) != NULL;) { + for (; (allow = (char *)strsep(&allow_list, " "));) { if (!BEG_STRCASECMP(allow, "image")) { images[idx].mode |= ALLOW_IMAGE; } else if (!BEG_STRCASECMP(allow, "trans")) { @@ -1703,25 +1703,25 @@ parse_image(char *buff, void *state) return NULL; } if (!strcasecmp(state, "normal")) { - if (images[idx].norm == NULL) { + if (!images[idx].norm) { images[idx].norm = (simage_t *) MALLOC(sizeof(simage_t)); new = 1; } images[idx].current = images[idx].norm; } else if (!strcasecmp(state, "selected")) { - if (images[idx].selected == NULL) { + if (!images[idx].selected) { images[idx].selected = (simage_t *) MALLOC(sizeof(simage_t)); new = 1; } images[idx].current = images[idx].selected; } else if (!strcasecmp(state, "clicked")) { - if (images[idx].clicked == NULL) { + if (!images[idx].clicked) { images[idx].clicked = (simage_t *) MALLOC(sizeof(simage_t)); new = 1; } images[idx].current = images[idx].clicked; } else if (!strcasecmp(state, "disabled")) { - if (images[idx].disabled == NULL) { + if (!images[idx].disabled) { images[idx].disabled = (simage_t *) MALLOC(sizeof(simage_t)); new = 1; } @@ -1745,7 +1745,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -1777,7 +1777,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -1801,7 +1801,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -1825,7 +1825,7 @@ parse_image(char *buff, void *state) file_peek_path(), file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -1928,7 +1928,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -1938,7 +1938,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current->iml->bevel != NULL) { + if (images[idx].current->iml->bevel) { FREE(images[idx].current->iml->bevel->edges); FREE(images[idx].current->iml->bevel); } @@ -1968,7 +1968,7 @@ parse_image(char *buff, void *state) file_peek_line()); return NULL; } - if (images[idx].current == NULL) { + if (!images[idx].current) { libast_print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n", file_peek_path(), file_peek_line()); return NULL; @@ -2370,7 +2370,7 @@ parse_multichar(char *buff, void *state) } if (!BEG_STRCASECMP(buff, "encoding ")) { RESET_AND_ASSIGN(rs_multichar_encoding, spiftool_get_word(2, buff)); - if (rs_multichar_encoding != NULL) { + if (rs_multichar_encoding) { if (BEG_STRCASECMP(rs_multichar_encoding, "eucj") && BEG_STRCASECMP(rs_multichar_encoding, "sjis") && BEG_STRCASECMP(rs_multichar_encoding, "euckr") @@ -2486,13 +2486,13 @@ spifconf_parse_theme(char **theme, char *spifconf_name, unsigned char fallback) spifconf_shell_expand(path); } if (fallback & PARSE_TRY_USER_THEME) { - if (theme && *theme && (ret = spifconf_parse(spifconf_name, *theme, path)) != NULL) { + if (theme && *theme && (ret = spifconf_parse(spifconf_name, *theme, path))) { return ret; } } if (fallback & PARSE_TRY_DEFAULT_THEME) { RESET_AND_ASSIGN(*theme, STRDUP(PACKAGE)); - if ((ret = spifconf_parse(spifconf_name, *theme, path)) != NULL) { + if ((ret = spifconf_parse(spifconf_name, *theme, path))) { return ret; } } @@ -2634,8 +2634,8 @@ post_parse(void) } /* set any defaults not already set */ - if (rs_name == NULL) { - if (rs_exec_args != NULL) { + if (!rs_name) { + if (rs_exec_args) { rs_name = STRDUP(rs_exec_args[0]); } else { rs_name = STRDUP(APL_NAME " " VERSION); @@ -2666,7 +2666,7 @@ post_parse(void) #endif #ifndef NO_BOLDFONT - if (rs_font[0] == NULL && rs_boldFont != NULL) { + if (!rs_font[0] && rs_boldFont) { rs_font[0] = rs_boldFont; rs_boldFont = NULL; } @@ -2697,7 +2697,7 @@ post_parse(void) eterm_font_add(&etmfonts, rs_mfont[i], ((i == 0) ? def_font_idx : ((i <= def_font_idx) ? (i - 1) : i))); RESET_AND_ASSIGN(rs_mfont[i], NULL); } - } else if (etmfonts[i] == NULL) { + } else if (!etmfonts[i]) { eterm_font_add(&etmfonts, etfonts[i], i); } #endif @@ -2719,7 +2719,7 @@ post_parse(void) #endif } #ifdef MULTI_CHARSET - if (rs_multichar_encoding != NULL) { + if (rs_multichar_encoding) { set_multichar_encoding(rs_multichar_encoding); } #endif @@ -3042,7 +3042,7 @@ post_parse(void) NumLockMask = modmasks[rs_numlock_mod - 1]; } #ifdef BACKGROUND_CYCLING_SUPPORT - if (rs_anim_pixmap_list != NULL) { + if (rs_anim_pixmap_list) { rs_anim_delay = strtoul(rs_anim_pixmap_list, (char **) NULL, 0); fflush(stdout); if (rs_anim_delay == 0) { @@ -3058,7 +3058,7 @@ post_parse(void) for (i = 0; i < count; i++) { temp = spiftool_get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */ - if (temp == NULL) + if (!temp) break; if (spiftool_num_words(temp) != 3) { if (spiftool_num_words(temp) == 1) { @@ -3194,7 +3194,7 @@ save_config(char *path, unsigned char save_theme) link(path, bak_path); unlink(path); } - if ((fp = fopen(path, "w")) == NULL) { + if (!(fp = fopen(path, "w"))) { libast_print_error("Unable to save configuration to file \"%s\" -- %s\n", path, strerror(errno)); return errno; } @@ -3286,7 +3286,7 @@ save_config(char *path, unsigned char save_theme) fprintf(fp, "begin imageclasses\n"); fprintf(fp, " path \"%s\"\n", rs_path); #ifdef PIXMAP_SUPPORT - if (rs_icon != NULL) { + if (rs_icon) { fprintf(fp, " icon %s\n", rs_icon); } if (rs_anim_delay) { diff --git a/src/options.h b/src/options.h index 00c3fdf..2acb680 100644 --- a/src/options.h +++ b/src/options.h @@ -83,7 +83,7 @@ } while (0) #define CHECK_VALID_INDEX(i) (((i) >= image_bg) && ((i) < image_max)) -#define RESET_AND_ASSIGN(var, val) do {if ((var) != NULL) FREE(var); (var) = (val);} while (0) +#define RESET_AND_ASSIGN(var, val) do {if ((var)) FREE(var); (var) = (val);} while (0) #define BITFIELD_SET(var, field) ((var) |= (field)) #define BITFIELD_CLEAR(var, field) ((var) &= ~(field)) diff --git a/src/pixmap.c b/src/pixmap.c index 0330ac9..a9e45ad 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -263,7 +263,7 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap) char *p, *opstr; int n; - if (geom == NULL) + if (!geom) return 0; D_PIXMAP(("scale_pixmap(\"%s\")\n", geom)); @@ -272,13 +272,13 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap) xterm_seq(ESCSEQ_XTERM_TITLE, str); return 0; } - if ((opstr = strchr(geom, ':')) != NULL) { + if ((opstr = strchr(geom, ':'))) { *opstr++ = '\0'; op = parse_pixmap_ops(opstr); } else { op = pmap->op; } - if ((p = strchr(geom, ';')) == NULL) + if (!(p = strchr(geom, ';'))) p = strchr(geom, '\0'); n = (p - geom); if (n > GEOM_LEN - 1) @@ -696,7 +696,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int && need_colormod(simg->iml)) { colormod_trans(p, simg->iml, gc, width, height); } - if (simg->iml->bevel != NULL) { + if (simg->iml->bevel) { D_PIXMAP(("Beveling pixmap 0x%08x with edges %d, %d, %d, %d\n", p, simg->iml->bevel->edges->left, simg->iml->bevel->edges->top, simg->iml->bevel->edges->right, simg->iml->bevel->edges->bottom)); bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); @@ -872,7 +872,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign gc = LIBAST_X_CREATE_GC(0, NULL); p = create_viewport_pixmap(simg, win, x, y, w, h); - if (simg->iml->bevel != NULL) { + if (simg->iml->bevel) { bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up); } XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y); @@ -882,7 +882,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign } if (((which == image_max) || (image_mode_is(which, MODE_IMAGE) && image_mode_is(which, ALLOW_IMAGE))) - && (simg->iml != NULL)) { + && (simg->iml)) { imlib_context_set_image(simg->iml->im); imlib_context_set_drawable(d); imlib_context_set_anti_alias(1); @@ -1251,7 +1251,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h } else { shaped_window_apply_mask(win, simg->pmap->mask); } - if (simg->iml->bevel != NULL) { + if (simg->iml->bevel) { bevel_pixmap(simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); } D_PIXMAP(("Setting background of window 0x%08x to 0x%08x\n", win, simg->pmap->pixmap)); @@ -1285,14 +1285,14 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height); XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); } else { - if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel != NULL)) { + if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel)) { if (simg->pmap->pixmap != None) { LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap); } simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height); XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg))); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); - if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) { + if (simg->iml->bevel && simg->iml->bevel->edges) { DRAW_SOLID_BEVEL(simg->pmap->pixmap, width, height, simg->bg, simg->iml->bevel->up, simg->iml->bevel->edges->left); } @@ -1345,7 +1345,7 @@ search_path(const char *pathlist, const char *file) D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno))); } - if ((p = strchr(file, '@')) == NULL) + if (!(p = strchr(file, '@'))) p = strchr(file, '\0'); len = (p - file); /* leave room for an extra '/' and trailing '\0' */ @@ -1370,11 +1370,11 @@ search_path(const char *pathlist, const char *file) } else { D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno))); } - for (path = pathlist; path != NULL && *path != '\0'; path = p) { + for (path = pathlist; path && *path != '\0'; path = p) { int n; /* colon delimited */ - if ((p = strchr(path, ':')) == NULL) + if (!(p = strchr(path, ':'))) p = strchr(path, '\0'); n = (p - path); if (*p != '\0') @@ -1433,20 +1433,20 @@ load_image(const char *file, simage_t *simg) ASSERT_RVAL(simg != NULL, 0); D_PIXMAP(("load_image(%s, %8p)\n", file, simg)); if (*file != '\0') { - if ((geom = strchr(file, '@')) != NULL) { + if ((geom = strchr(file, '@'))) { *geom++ = 0; - } else if ((geom = strchr(file, ';')) != NULL) { + } else if ((geom = strchr(file, ';'))) { *geom++ = 0; } - if (geom != NULL) { + if (geom) { set_pixmap_scale(geom, simg->pmap); } - if ((f = search_path(rs_path, file)) == NULL) { + if (!(f = search_path(rs_path, file))) { f = search_path(getenv(PATH_ENV), file); } - if (f != NULL) { + if (f) { im = imlib_load_image_with_error_return(f, &im_err); - if (im == NULL) { + if (!im) { libast_print_error("Unable to load image file \"%s\" -- %s\n", file, imlib_strerror(im_err)); return 0; } else { @@ -1810,7 +1810,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h real_depth = Xdepth; } ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap); - if (ximg == NULL) { + if (!ximg) { libast_print_warning("XGetImage(Xdisplay, 0x%08x, 0, 0, %d, %d, -1, ZPixmap) returned NULL.\n", p, w, h); return; } @@ -2170,14 +2170,14 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints) imlib_context_set_color_modifier(tmp_cmod); imlib_reset_color_modifier(); if (filename && *filename) { - if ((icon_path = search_path(rs_path, filename)) == NULL) + if (!(icon_path = search_path(rs_path, filename))) icon_path = search_path(getenv(PATH_ENV), filename); - if (icon_path != NULL) { + if (icon_path) { XIconSize *icon_sizes; int count, i; temp_im = imlib_load_image_with_error_return(icon_path, &im_err); - if (temp_im == NULL) { + if (!temp_im) { libast_print_error("Unable to load icon file \"%s\" -- %s\n", icon_path, imlib_strerror(im_err)); } else { /* If we're going to render the image anyway, might as well be nice and give it to the WM in a size it likes. */ @@ -2205,7 +2205,7 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints) } } - if (temp_im == NULL) { + if (!temp_im) { w = h = 48; temp_im = imlib_create_image_using_data(48, 48, (DATA32 *) (icon_data + 2)); imlib_context_set_image(temp_im); diff --git a/src/screen.c b/src/screen.c index 006856b..1005fac 100644 --- a/src/screen.c +++ b/src/screen.c @@ -122,7 +122,7 @@ blank_screen_mem(text_t **tp, rend_t **rp, int row, rend_t efs) register unsigned int i = TERM_WINDOW_GET_REPORTED_COLS(); rend_t *r, fs = efs; - if (tp[row] == NULL) { + if (!tp[row]) { tp[row] = MALLOC(sizeof(text_t) * (TERM_WINDOW_GET_REPORTED_COLS() + 1)); rp[row] = MALLOC(sizeof(rend_t) * TERM_WINDOW_GET_REPORTED_COLS()); } @@ -264,7 +264,7 @@ scr_reset(void) screen.row += k; TermWin.nscrolled -= k; for (i = TermWin.saveLines - TermWin.nscrolled; k--; i--) { - if (screen.text[i] == NULL) { + if (!screen.text[i]) { blank_screen_mem(screen.text, screen.rend, i, DEFAULT_RSTYLE); } } @@ -455,7 +455,7 @@ scr_change_screen(int scrn) if (current_screen == PRIMARY) { scroll_text(0, (TERM_WINDOW_GET_REPORTED_ROWS() - 1), TERM_WINDOW_GET_REPORTED_ROWS(), 0); for (i = TermWin.saveLines; i < TERM_WINDOW_GET_REPORTED_ROWS() + TermWin.saveLines; i++) - if (screen.text[i] == NULL) { + if (!screen.text[i]) { blank_screen_mem(screen.text, screen.rend, i, DEFAULT_RSTYLE); } } @@ -634,7 +634,7 @@ scroll_text(int row1, int row2, int count, int spec) for (i = 0, j = row1; i < count; i++, j++) { buf_text[i] = screen.text[j]; buf_rend[i] = screen.rend[j]; - if (buf_text[i] == NULL) { + if (!buf_text[i]) { /* A new ALLOC is done with size ncol and blankline with size prev_ncol -- Sebastien van K */ buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1)); @@ -661,7 +661,7 @@ scroll_text(int row1, int row2, int count, int spec) for (i = 0, j = row2; i < count; i++, j--) { buf_text[i] = screen.text[j]; buf_rend[i] = screen.rend[j]; - if (buf_text[i] == NULL) { + if (!buf_text[i]) { /* A new ALLOC is done with size ncol and blankline with size prev_ncol -- Sebastien van K */ buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1)); @@ -728,7 +728,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len) BOUND(screen.row, -TermWin.nscrolled, TERM_WINDOW_GET_REPORTED_ROWS() - 1); row = screen.row + TermWin.saveLines; - if (screen.text[row] == NULL) { + if (!screen.text[row]) { blank_screen_mem(screen.text, screen.rend, row, DEFAULT_RSTYLE); } /* avoid segfault -- added by Sebastien van K */ beg.row = screen.row; @@ -1581,7 +1581,7 @@ scr_printscreen(int fullhist) text_t *t; FILE *fd; - if ((fd = popen_printer()) == NULL) + if (!(fd = popen_printer())) return; nrows = TERM_WINDOW_GET_REPORTED_ROWS(); if (fullhist) { @@ -1945,7 +1945,7 @@ scr_refresh(int type) XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); } #ifndef NO_BOLDFONT - if (!wbyte && MONO_BOLD(rend) && TermWin.boldFont != NULL) { + if (!wbyte && MONO_BOLD(rend) && TermWin.boldFont) { XSetFont(Xdisplay, TermWin.gc, TermWin.boldFont->fid); bfont = 1; } else if (bfont) { @@ -2256,8 +2256,8 @@ scr_search_scrollback(char *str) unsigned int *i; unsigned long row, lrow, col, rows, cols, len, k; - if (str == NULL) { - if ((str = last_str) == NULL) { + if (!str) { + if (!(str = last_str)) { return; } } else { @@ -2498,9 +2498,9 @@ selection_fetch(Window win, unsigned prop, int delete) if ((XGetWindowProperty (Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems, &bytes_after, &data) != Success) - || (actual_type == None) || (data == NULL)) { + || (actual_type == None) || (!data)) { D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win)); - if (data != NULL) { + if (data) { XFree(data); } return; @@ -2557,7 +2557,7 @@ void selection_copy_string(Atom sel, char *str, size_t len) { D_SELECT(("Copying %ul bytes from 0x%08x to selection %d\n", len, str, (int) sel)); - if (str == NULL || len == 0) { + if (!str || len == 0) { return; } if (IS_SELECTION(sel)) { @@ -2584,7 +2584,7 @@ void selection_paste(Atom sel) { D_SELECT(("Attempting to paste selection %d.\n", (int) sel)); - if (selection.text != NULL) { + if (selection.text) { /* If we have a selection of our own, paste it. */ D_SELECT(("Pasting my current selection of length %lu\n", selection.len)); selection_write(selection.text, selection.len); @@ -2857,9 +2857,9 @@ selection_click(int clicks, int x, int y) /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ #ifdef CUTCHAR_OPTION -# define DELIMIT_TEXT(x) (strchr((rs_cutchars?rs_cutchars:CUTCHARS), (x)) != NULL) +# define DELIMIT_TEXT(x) (strchr((rs_cutchars ? rs_cutchars : CUTCHARS), (x))) #else -# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)) != NULL) +# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x))) #endif #ifdef MULTI_CHARSET #define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) @@ -3351,7 +3351,7 @@ selection_send(XSelectionRequestEvent * rq) xtextp.value = NULL; xtextp.nitems = 0; if (XmbTextListToTextProperty(Xdisplay, l, 1, XUTF8StringStyle, &xtextp) == Success) { - if (xtextp.nitems > 0 && xtextp.value != NULL) { + if (xtextp.nitems > 0 && xtextp.value) { XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, 8, PropModeReplace, xtextp.value, xtextp.nitems); ev.xselection.property = rq->property; @@ -3367,7 +3367,7 @@ selection_send(XSelectionRequestEvent * rq) xtextp.value = NULL; xtextp.nitems = 0; if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) { - if (xtextp.nitems > 0 && xtextp.value != NULL) { + if (xtextp.nitems > 0 && xtextp.value) { XChangeProperty(Xdisplay, rq->requestor, rq->property, props[PROP_COMPOUND_TEXT], 8, PropModeReplace, xtextp.value, xtextp.nitems); ev.xselection.property = rq->property; diff --git a/src/script.c b/src/script.c index 2424904..336f20a 100644 --- a/src/script.c +++ b/src/script.c @@ -160,7 +160,7 @@ script_handler_copy(spif_charptr_t *params) Atom sel = XA_PRIMARY; if (params) { - for (i = 0; (buffer_id = params[i]) != NULL; i++) { + for (i = 0; (buffer_id = params[i]); i++) { if (*buffer_id) { if (*buffer_id >= '0' && *buffer_id <= '7') { sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0')); @@ -261,7 +261,7 @@ script_handler_paste(spif_charptr_t *params) Atom sel = XA_PRIMARY; if (params) { - for (i = 0; (buffer_id = params[i]) != NULL; i++) { + for (i = 0; (buffer_id = params[i]); i++) { if (*buffer_id) { if (*buffer_id >= '0' && *buffer_id <= '7') { sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0')); @@ -389,7 +389,7 @@ script_handler_search(spif_charptr_t *params) static char *search = NULL; if (params && *params) { - if (search != NULL) { + if (search) { FREE(search); } search = STRDUP(*params); @@ -740,7 +740,7 @@ script_parse(char *s) D_SCRIPT(("Parsing: \"%s\"\n", s)); token_list = spiftool_split(";", s); - if (token_list == NULL) { + if (!token_list) { D_SCRIPT(("No tokens found; ignoring script.\n")); return; } @@ -751,7 +751,7 @@ script_parse(char *s) if (!(*pstr)) { continue; } - if ((params = strchr(pstr, '(')) != NULL) { + if ((params = strchr(pstr, '('))) { if (params != pstr) { len = params - pstr; func_name = (char *) MALLOC(len + 1); @@ -771,7 +771,7 @@ script_parse(char *s) } if (params) { params++; - if ((tmp = strrchr(params, ')')) != NULL) { + if ((tmp = strrchr(params, ')'))) { *tmp = 0; } else { libast_print_error("Error in script \"%s\": Missing closing parentheses for \"%s\".\n", s, token_list[i]); @@ -783,7 +783,7 @@ script_parse(char *s) param_list = NULL; } D_SCRIPT(("Calling function %s with parameters: %s\n", func_name, NONULL(params))); - if ((func = script_find_handler(func_name)) != NULL) { + if ((func = script_find_handler(func_name))) { (func->handler) (param_list); } else { libast_print_error("Error in script \"%s\": No such function \"%s\".\n", s, func_name); diff --git a/src/scrollbar.c b/src/scrollbar.c index 1723931..2c3fc3b 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -357,7 +357,7 @@ sb_handle_motion_notify(event_t *ev) unsigned char scrollbar_dispatch_event(event_t *ev) { - if (scrollbar_event_data.handlers[ev->type] != NULL) { + if (scrollbar_event_data.handlers[ev->type]) { return ((scrollbar_event_data.handlers[ev->type]) (ev)); } return (0); diff --git a/src/startup.c b/src/startup.c index 6f54066..576c60f 100644 --- a/src/startup.c +++ b/src/startup.c @@ -95,7 +95,7 @@ eterm_bootstrap(int argc, char *argv[]) init_libast(); /* Open display, get options/resources and create the window */ - if (getenv("DISPLAY") != NULL) { + if (getenv("DISPLAY")) { display_name = STRDUP(getenv("DISPLAY")); } @@ -160,7 +160,7 @@ eterm_bootstrap(int argc, char *argv[]) props[PROP_EWMH_STATE] = XInternAtom(Xdisplay, "_NET_WM_STATE", False); props[PROP_EWMH_STATE_STICKY] = XInternAtom(Xdisplay, "_NET_WM_STATE_STICKY", False); - if ((theme_dir = spifconf_parse_theme(&rs_theme, THEME_CFG, PARSE_TRY_ALL)) != NULL) { + if ((theme_dir = spifconf_parse_theme(&rs_theme, THEME_CFG, PARSE_TRY_ALL))) { char *tmp; D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", theme_dir)); @@ -168,9 +168,7 @@ eterm_bootstrap(int argc, char *argv[]) sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir); putenv(tmp); } - if ((user_dir = - spifconf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), - (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) { + if ((user_dir = spifconf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME)))) { char *tmp; D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", user_dir)); @@ -268,7 +266,7 @@ eterm_bootstrap(int argc, char *argv[]) #endif val = XDisplayString(Xdisplay); - if (display_name == NULL) { + if (!display_name) { display_name = val; } @@ -292,7 +290,7 @@ eterm_bootstrap(int argc, char *argv[]) putenv("COLORTERM_BCE=" COLORTERMENV "-mono"); putenv("TERM=" TERMENV); } else { - if (rs_term_name != NULL) { + if (rs_term_name) { i = strlen(rs_term_name); term_string = MALLOC(i + 6); diff --git a/src/term.c b/src/term.c index 8435da1..44a4d29 100644 --- a/src/term.c +++ b/src/term.c @@ -473,7 +473,7 @@ lookup_key(XEvent * ev) PrivMode((!numlock_state), PrivMode_aplKP); } #ifdef USE_XIM - if (xim_input_context != NULL) { + if (xim_input_context) { Status status_return; kbuf[0] = '\0'; @@ -680,7 +680,7 @@ lookup_key(XEvent * ev) if (keysym >= 0xff00 && keysym <= 0xffff) { #ifdef KEYSYM_ATTRIBUTE /* The "keysym" attribute in the config file gets handled here. */ - if (!(shft | ctrl) && KeySym_map[keysym - 0xff00] != NULL) { + if (!(shft | ctrl) && KeySym_map[keysym - 0xff00]) { const unsigned char *tmpbuf; unsigned int len; @@ -1080,7 +1080,7 @@ popen_printer(void) libast_print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n"); RESET_AND_ASSIGN(rs_print_pipe, STRDUP(PRINTPIPE)); } - if ((stream = (FILE *) popen(rs_print_pipe, "w")) == NULL) { + if (!(stream = (FILE *)popen(rs_print_pipe, "w"))) { libast_print_error("Can't open printer pipe \"%s\" -- %s\n", rs_print_pipe, strerror(errno)); } return stream; @@ -1102,7 +1102,7 @@ process_print_pipe(void) int index; FILE *fd; - if ((fd = popen_printer()) != NULL) { + if ((fd = popen_printer())) { for (index = 0; index < 4; /* nil */ ) { unsigned char ch = cmd_getc(); @@ -2081,7 +2081,7 @@ append_to_title(const char *str) REQUIRE(str != NULL); XFetchName(Xdisplay, TermWin.parent, &name); - if (name != NULL) { + if (name) { buff = (char *) MALLOC(strlen(name) + strlen(str) + 1); strcpy(buff, name); strcat(buff, str); @@ -2098,7 +2098,7 @@ append_to_icon_name(const char *str) REQUIRE(str != NULL); XGetIconName(Xdisplay, TermWin.parent, &name); - if (name != NULL) { + if (name) { buff = (char *) MALLOC(strlen(name) + strlen(str) + 1); strcpy(buff, name); strcat(buff, str); @@ -2158,19 +2158,19 @@ xterm_seq(int op, const char *str) set_title(str); break; case ESCSEQ_XTERM_PROP: /* 3 */ - if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(nstr = (char *)strsep(&tnstr, ";"))) { break; } - if ((valptr = strchr(nstr, '=')) != NULL) { + if ((valptr = strchr(nstr, '='))) { *(valptr++) = 0; } set_text_property(TermWin.parent, nstr, valptr); break; case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */ - while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + while ((nstr = (char *)strsep(&tnstr, ";"))) { i = (unsigned int) strtoul(nstr, (char **) NULL, 0); nstr = (char *) strsep(&tnstr, ";"); - if ((i < 256) && (nstr != NULL)) { + if ((i < 256) && (nstr)) { D_COLORS(("Changing color : [%d] -> %s\n", i, nstr)); set_window_color(i, nstr); } @@ -2256,7 +2256,7 @@ xterm_seq(int op, const char *str) case 1: changed = 0; for (; 1;) { - if ((color = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(color = (char *)strsep(&tnstr, ";"))) { break; } which = image_max; @@ -2264,13 +2264,13 @@ xterm_seq(int op, const char *str) which = idx; break;} ); if (which != image_max) { - if ((color = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(color = (char *)strsep(&tnstr, ";"))) { break; } } else { which = image_bg; } - if ((mod = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(mod = (char *)strsep(&tnstr, ";"))) { break; } if (!strcasecmp(mod, "clear")) { @@ -2297,7 +2297,7 @@ xterm_seq(int op, const char *str) changed = 1; continue; } - if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(valptr = (char *)strsep(&tnstr, ";"))) { break; } D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", @@ -2314,7 +2314,7 @@ xterm_seq(int op, const char *str) if (!strcasecmp(color, "image")) { imlib_t *iml = images[which].current->iml; - if (iml->mod == NULL) { + if (!iml->mod) { iml->mod = create_colormod(); } if (!BEG_STRCASECMP(mod, "brightness")) { @@ -2331,7 +2331,7 @@ xterm_seq(int op, const char *str) } else if (!strcasecmp(color, "red")) { imlib_t *iml = images[which].current->iml; - if (iml->rmod == NULL) { + if (!iml->rmod) { iml->rmod = create_colormod(); } if (!BEG_STRCASECMP(mod, "brightness")) { @@ -2348,7 +2348,7 @@ xterm_seq(int op, const char *str) } else if (!strcasecmp(color, "green")) { imlib_t *iml = images[which].current->iml; - if (iml->gmod == NULL) { + if (!iml->gmod) { iml->gmod = create_colormod(); } if (!BEG_STRCASECMP(mod, "brightness")) { @@ -2365,7 +2365,7 @@ xterm_seq(int op, const char *str) } else if (!strcasecmp(color, "blue")) { imlib_t *iml = images[which].current->iml; - if (iml->bmod == NULL) { + if (!iml->bmod) { iml->bmod = create_colormod(); } if (!BEG_STRCASECMP(mod, "bright")) { @@ -2387,14 +2387,14 @@ xterm_seq(int op, const char *str) case 2: changed = 0; which = image_max; - if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(nstr = (char *)strsep(&tnstr, ";")) || !(valptr = (char *)strsep(&tnstr, ";"))) { break; } FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) { which = idx; break;} ); if (which != image_max) { - if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + if (!(valptr = (char *)strsep(&tnstr, ";"))) { break; } } else { @@ -2408,7 +2408,7 @@ xterm_seq(int op, const char *str) s = (int) strtol(valptr, (char **) NULL, 0); s = ((100 - s) << 8) / 100; if (s == 0x100) { - if (iml->mod != NULL) { + if (iml->mod) { if (iml->mod->brightness != 0x100) { iml->mod->brightness = 0x100; changed = 1; @@ -2418,7 +2418,7 @@ xterm_seq(int op, const char *str) } } } else { - if (iml->mod == NULL) { + if (!iml->mod) { iml->mod = create_colormod(); } if (iml->mod->brightness != s) { @@ -2438,7 +2438,7 @@ xterm_seq(int op, const char *str) } r = (t & 0xff0000) >> 16; if (r == 0xff) { - if (iml->rmod != NULL) { + if (iml->rmod) { if (iml->rmod->brightness != 0x100) { iml->rmod->brightness = 0x100; changed = 1; @@ -2448,7 +2448,7 @@ xterm_seq(int op, const char *str) } } } else { - if (iml->rmod == NULL) { + if (!iml->rmod) { iml->rmod = create_colormod(); } if (iml->rmod->brightness != (int) r) { @@ -2458,7 +2458,7 @@ xterm_seq(int op, const char *str) } g = (t & 0xff00) >> 8; if (g == 0xff) { - if (iml->gmod != NULL) { + if (iml->gmod) { if (iml->gmod->brightness != 0x100) { iml->gmod->brightness = 0x100; changed = 1; @@ -2468,7 +2468,7 @@ xterm_seq(int op, const char *str) } } } else { - if (iml->gmod == NULL) { + if (!iml->gmod) { iml->gmod = create_colormod(); } if (iml->gmod->brightness != (int) g) { @@ -2478,7 +2478,7 @@ xterm_seq(int op, const char *str) } b = t & 0xff; if (b == 0xff) { - if (iml->bmod != NULL) { + if (iml->bmod) { if (iml->bmod->brightness != 0x100) { iml->bmod->brightness = 0x100; changed = 1; @@ -2488,7 +2488,7 @@ xterm_seq(int op, const char *str) } } } else { - if (iml->bmod == NULL) { + if (!iml->bmod) { iml->bmod = create_colormod(); iml->bmod->contrast = iml->bmod->gamma = 0x100; } @@ -2709,54 +2709,54 @@ xterm_seq(int op, const char *str) #ifdef XTERM_COLOR_CHANGE case ESCSEQ_XTERM_FGCOLOR: /* 10 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { set_window_color(fgColor, nstr); } /* drop */ case ESCSEQ_XTERM_BGCOLOR: /* 11 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { set_window_color(bgColor, nstr); } /* drop */ case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { # ifndef NO_CURSORCOLOR set_window_color(cursorColor, nstr); # endif } /* drop */ case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { set_pointer_colors(nstr, NULL); } /* drop */ case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { /* UNSUPPORTED */ } /* drop */ case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { /* UNSUPPORTED */ } /* drop */ case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { /* UNSUPPORTED */ } /* drop */ case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { /* UNSUPPORTED */ } /* drop */ case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { set_window_color(colorBD, nstr); } /* drop */ case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + if ((nstr = (char *)strsep(&tnstr, ";"))) { set_window_color(colorUL, nstr); } #endif diff --git a/src/utmp.c b/src/utmp.c index f946514..32c6745 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -181,7 +181,7 @@ remove_utmp_entry(void) setutent(); strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id)); utmp.ut_type = USER_PROCESS; - if (getutid(&utmp) == NULL) { + if (!getutid(&utmp)) { return; } utmp.ut_type = DEAD_PROCESS; @@ -204,7 +204,7 @@ remove_utmp_entry(void) * The following code waw copied from the poeigl-1.20 login/init package. * Special thanks to poe for the code examples. */ - while ((putmp = getutent()) != NULL) { + while ((putmp = getutent())) { if (putmp->ut_pid == pid) { putmp->ut_type = DEAD_PROCESS; putmp->ut_pid = 0; @@ -286,10 +286,10 @@ get_tslot(const char *ttyname) char buf[256], name[256]; FILE *fd; - if ((fd = fopen(UTMP_FILENAME, "r")) != NULL) { + if ((fd = fopen(UTMP_FILENAME, "r"))) { int i; - for (i = 1; fgets(buf, sizeof(buf), fd) != NULL; i++) { + for (i = 1; fgets(buf, sizeof(buf), fd); i++) { if (*buf == '#' || sscanf(buf, "%s", name) != 1) continue; if (!strcmp(ttyname, name)) { @@ -313,7 +313,7 @@ write_utmp(struct utmp *putmp) fprintf(stderr, "Utmp file is %s\n", UTMP_FILENAME); privileges(INVOKE); - if ((fd = fopen(UTMP_FILENAME, "r+")) != NULL) { + if ((fd = fopen(UTMP_FILENAME, "r+"))) { utmp_pos = get_tslot(putmp->ut_line) * sizeof(struct utmp); if (utmp_pos >= 0) { @@ -384,7 +384,7 @@ remove_utmp_entry(void) FILE *fd; privileges(INVOKE); - if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+")) != NULL) { + if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+"))) { struct utmp utmp; MEMSET(&utmp, 0, sizeof(struct utmp)); diff --git a/src/windows.c b/src/windows.c index a9cff63..7c946aa 100644 --- a/src/windows.c +++ b/src/windows.c @@ -69,7 +69,7 @@ set_text_property(Window win, char *propname, char *value) ASSERT(propname != NULL); - if (value == NULL) { + if (!value) { atom = XInternAtom(Xdisplay, propname, True); if (atom == None) { return; @@ -189,8 +189,8 @@ get_color_by_name(const char *name, const char *fallback) { XColor xcol; - if (name == NULL) { - if (fallback == NULL) { + if (!name) { + if (!fallback) { return ((Pixel) - 1); } else { name = fallback; @@ -348,13 +348,13 @@ set_pointer_colors(const char *fg_name, const char *bg_name) { XColor fg, bg; - if (fg_name != NULL) { + if (fg_name) { fg.pixel = get_color_by_name(fg_name, COLOR_NAME(pointerColor)); } else { fg.pixel = PixColors[pointerColor]; } XQueryColor(Xdisplay, cmap, &fg); - if (bg_name != NULL) { + if (bg_name) { bg.pixel = get_color_by_name(bg_name, COLOR_NAME(bgColor)); } else { bg.pixel = PixColors[bgColor]; @@ -735,7 +735,7 @@ set_window_color(int idx, const char *color) D_X11(("idx == %d, color == \"%s\"\n", idx, NONULL(color))); - if (color == NULL || *color == '\0') + if (!color || *color == '\0') return; /* handle color aliases */ -- cgit v1.2.1