Convert (hopefully) all comparisons to NULL

Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
This commit is contained in:
Lucas De Marchi 2010-08-21 13:52:25 +00:00
parent c81f5795de
commit 3f375e63e2
23 changed files with 310 additions and 312 deletions

View File

@ -52,7 +52,7 @@ unsigned char
action_handle_string(event_t *ev, action_t *action) action_handle_string(event_t *ev, action_t *action)
{ {
USE_VAR(ev); USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0); REQUIRE_RVAL(!!action->param.string, 0);
cmd_write((unsigned char *) action->param.string, strlen(action->param.string)); cmd_write((unsigned char *) action->param.string, strlen(action->param.string));
return 1; return 1;
} }
@ -61,7 +61,7 @@ unsigned char
action_handle_echo(event_t *ev, action_t *action) action_handle_echo(event_t *ev, action_t *action)
{ {
USE_VAR(ev); USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0); REQUIRE_RVAL(!!action->param.string, 0);
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend) { if (TermWin.screen && TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN # ifdef NS_HAVE_SCREEN
@ -78,7 +78,7 @@ unsigned char
action_handle_script(event_t *ev, action_t *action) action_handle_script(event_t *ev, action_t *action)
{ {
USE_VAR(ev); USE_VAR(ev);
REQUIRE_RVAL(action->param.script != NULL, 0); REQUIRE_RVAL(!!action->param.script, 0);
script_parse(action->param.script); script_parse(action->param.script);
return 1; return 1;
} }
@ -86,7 +86,7 @@ action_handle_script(event_t *ev, action_t *action)
unsigned char unsigned char
action_handle_menu(event_t *ev, action_t *action) action_handle_menu(event_t *ev, action_t *action)
{ {
REQUIRE_RVAL(action->param.menu != NULL, 0); REQUIRE_RVAL(!!action->param.menu, 0);
menu_invoke(ev->xbutton.x, ev->xbutton.y, TermWin.parent, action->param.menu, ev->xbutton.time); menu_invoke(ev->xbutton.x, ev->xbutton.y, TermWin.parent, action->param.menu, ev->xbutton.time);
return 1; return 1;
} }
@ -202,7 +202,7 @@ action_dispatch(event_t *ev, KeySym keysym)
{ {
action_t *action; action_t *action;
ASSERT_RVAL(ev != NULL, 0); ASSERT_RVAL(!!ev, 0);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0); ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0);
D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym, D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym,
ev->xkey.state, SHOW_X_MODS(ev->xkey.state))); ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
@ -228,7 +228,7 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_
action_t *action; 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 = (action_t *) MALLOC(sizeof(action_t));
action->next = action_list; action->next = action_list;
action_list = action; action_list = action;

View File

@ -62,7 +62,7 @@ draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_
D_BBAR(("Writing string \"%s\" (length %lu) using font 0x%08x onto drawable 0x%08x at %d, %d\n", D_BBAR(("Writing string \"%s\" (length %lu) using font 0x%08x onto drawable 0x%08x at %d, %d\n",
str, len, bbar->font, d, x, y)); str, len, bbar->font, d, x, y));
REQUIRE(bbar != NULL); REQUIRE(!!bbar);
REQUIRE(d != None); REQUIRE(d != None);
REQUIRE(gc != None); REQUIRE(gc != None);
@ -193,7 +193,7 @@ bbar_handle_enter_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); 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; return 0;
} }
bbar_draw(bbar, IMAGE_STATE_SELECTED, 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); 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; return 0;
} }
bbar_draw(bbar, IMAGE_STATE_NORMAL, 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); 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")); D_EVENTS((" -> No buttonbar found for this window.\n"));
return 0; return 0;
} }
@ -326,7 +326,7 @@ bbar_handle_button_release(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); 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")); D_EVENTS((" -> No buttonbar found for this window.\n"));
return 0; return 0;
} }
@ -364,7 +364,7 @@ bbar_handle_motion_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); 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; return 0;
} }
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev));
@ -392,7 +392,7 @@ bbar_handle_motion_notify(event_t *ev)
unsigned char unsigned char
bbar_dispatch_event(event_t *ev) 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 ((buttonbar->event_data.handlers[ev->type]) (ev));
} }
return (0); return (0);
@ -633,7 +633,7 @@ bbar_add_button(buttonbar_t *bbar, button_t *button)
D_BBAR(("bbar_add_button(%8p, %8p): Adding button \"%s\".\n", bbar, button, button->text)); D_BBAR(("bbar_add_button(%8p, %8p): Adding button \"%s\".\n", bbar, button, button->text));
ASSERT(bbar != NULL); ASSERT(!!bbar);
if (bbar->buttons) { if (bbar->buttons) {
for (b = bbar->buttons; b->next; b = b->next); for (b = bbar->buttons; b->next; b = b->next);
@ -661,7 +661,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
{ {
XFontStruct *font; XFontStruct *font;
ASSERT_RVAL(fontname != NULL, 0); ASSERT_RVAL(!!fontname, 0);
D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth,
bbar->fheight, bbar->h)); bbar->fheight, bbar->h));
@ -695,7 +695,7 @@ button_t *find_button_by_text(buttonbar_t *bbar, char *text)
{ {
register button_t *b; register button_t *b;
REQUIRE_RVAL(text != NULL, NULL); REQUIRE_RVAL(!!text, NULL);
for (b = bbar->buttons; b; b = b->next) { for (b = bbar->buttons; b; b = b->next) {
if (!strcasecmp(b->text, text)) { if (!strcasecmp(b->text, text)) {
@ -721,7 +721,7 @@ button_t *find_button_by_index(buttonbar_t *bbar, long idx)
} else { } else {
b = bbar->buttons; 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)); return ((i == idx) ? (b) : (NULL));
} }
@ -729,7 +729,7 @@ button_t *find_button_by_coords(buttonbar_t *bbar, int x, int y)
{ {
register button_t *b; register button_t *b;
ASSERT_RVAL(bbar != NULL, NULL); ASSERT_RVAL(!!bbar, NULL);
for (b = bbar->buttons; b; b = b->next) { for (b = bbar->buttons; b; b = b->next) {
if ((x >= b->x) && (y >= b->y) && (x < b->x + b->w) && (y < b->y + b->h)) { if ((x >= b->x) && (y >= b->y) && (x < b->x + b->w) && (y < b->y + b->h)) {
@ -782,7 +782,7 @@ button_free(button_t *button)
unsigned char unsigned char
button_set_text(button_t *button, const char *text) button_set_text(button_t *button, const char *text)
{ {
ASSERT_RVAL(button != NULL, 0); ASSERT_RVAL(!!button, 0);
if (button->text) { if (button->text) {
FREE(button->text); FREE(button->text);
@ -800,8 +800,8 @@ button_set_text(button_t *button, const char *text)
unsigned char unsigned char
button_set_icon(button_t *button, simage_t *icon) button_set_icon(button_t *button, simage_t *icon)
{ {
ASSERT_RVAL(button != NULL, 0); ASSERT_RVAL(!!button, 0);
ASSERT_RVAL(icon != NULL, 0); ASSERT_RVAL(!!icon, 0);
button->icon = icon; button->icon = icon;
return 1; return 1;
@ -810,25 +810,25 @@ button_set_icon(button_t *button, simage_t *icon)
unsigned char unsigned char
button_set_action(button_t *button, action_type_t type, char *action) button_set_action(button_t *button, action_type_t type, char *action)
{ {
ASSERT_RVAL(button != NULL, 0); ASSERT_RVAL(!!button, 0);
button->type = type; button->type = type;
switch (type) { switch (type) {
case ACTION_MENU: case ACTION_MENU:
button->action.menu = find_menu_by_title(menu_list, action); button->action.menu = find_menu_by_title(menu_list, action);
return ((button->action.menu == NULL) ? (0) : (1)); return ((!button->action.menu) ? (0) : (1));
break; break;
case ACTION_STRING: case ACTION_STRING:
case ACTION_ECHO: case ACTION_ECHO:
button->action.string = (char *) MALLOC(strlen(action) + 2); button->action.string = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.string, action); strcpy(button->action.string, action);
parse_escaped_string(button->action.string); parse_escaped_string(button->action.string);
return ((button->action.string == NULL) ? (0) : (1)); return ((!button->action.string) ? (0) : (1));
break; break;
case ACTION_SCRIPT: case ACTION_SCRIPT:
button->action.script = (char *) MALLOC(strlen(action) + 2); button->action.script = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.script, action); strcpy(button->action.script, action);
return ((button->action.script == NULL) ? (0) : (1)); return ((!button->action.script) ? (0) : (1));
break; break;
default: default:
break; break;
@ -874,7 +874,7 @@ bbar_deselect_button(buttonbar_t *bbar, button_t *button)
void void
bbar_click_button(buttonbar_t *bbar, button_t *button) bbar_click_button(buttonbar_t *bbar, button_t *button)
{ {
REQUIRE(button != NULL); REQUIRE(!!button);
D_BBAR(("Drawing clicked button %8p (%s) on buttonbar %8p\n", button, NONULL(button->text), bbar)); D_BBAR(("Drawing clicked button %8p (%s) on buttonbar %8p\n", button, NONULL(button->text), bbar));
@ -903,7 +903,7 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
{ {
static unsigned char prvs = 0; static unsigned char prvs = 0;
REQUIRE(button != NULL); REQUIRE(!!button);
D_BBAR(("Checking action for button %8p (%s) on buttonbar %8p, press %d, prvs %d, time %lu\n", button, NONULL(button->text), D_BBAR(("Checking action for button %8p (%s) on buttonbar %8p, press %d, prvs %d, time %lu\n", button, NONULL(button->text),
bbar, (int) press, (int) prvs, (unsigned long) t)); bbar, (int) press, (int) prvs, (unsigned long) t));
@ -1075,7 +1075,7 @@ bbar_draw(buttonbar_t *bbar, unsigned char image_state, unsigned char force_mode
{ {
button_t *button; button_t *button;
ASSERT(bbar != NULL); ASSERT(!!bbar);
D_BBAR(("bbar_draw(%8p, 0x%02x, 0x%02x) called.\n", bbar, image_state, force_modes)); D_BBAR(("bbar_draw(%8p, 0x%02x, 0x%02x) called.\n", bbar, image_state, force_modes));
if (image_state != IMAGE_STATE_CURRENT) { if (image_state != IMAGE_STATE_CURRENT) {

View File

@ -1330,7 +1330,7 @@ sgi_get_pty(void)
privileges(INVOKE); privileges(INVOKE);
ptydev = ttydev = _getpty(&fd, O_RDWR | O_NDELAY, 0620, 0); ptydev = ttydev = _getpty(&fd, O_RDWR | O_NDELAY, 0620, 0);
privileges(REVERT); privileges(REVERT);
return (ptydev == NULL ? -1 : fd); return (!ptydev ? -1 : fd);
} }
#endif #endif
@ -1411,7 +1411,7 @@ posix_get_pty(void)
return (-1); return (-1);
} else { } else {
ptydev = ttydev = ptsname(fd); ptydev = ttydev = ptsname(fd);
if (ttydev == NULL) { if (!ttydev) {
libast_print_error("ptsname(%d) failed: %s\n", fd, strerror(errno)); libast_print_error("ptsname(%d) failed: %s\n", fd, strerror(errno));
return (-1); return (-1);
} }
@ -1509,7 +1509,7 @@ get_tty(void)
#endif /* ultrix */ #endif /* ultrix */
privileges(INVOKE); privileges(INVOKE);
if (ttydev == NULL) { if (!ttydev) {
libast_print_error("Slave tty device name is NULL. Failed to open slave pty.\n"); libast_print_error("Slave tty device name is NULL. Failed to open slave pty.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if ((fd = open(ttydev, O_RDWR)) < 0) { } else if ((fd = open(ttydev, O_RDWR)) < 0) {
@ -1859,7 +1859,7 @@ create_fontset(const char *font1, const char *font2)
int mc; int mc;
/*const char fs_base[] = ",-misc-fixed-*-r-*-*-*-120-*-*-*-*-*-*,*";*/ /*const char fs_base[] = ",-misc-fixed-*-r-*-*-*-120-*-*-*-*-*-*,*";*/
ASSERT_RVAL(font1 != NULL, (XFontSet) 0); ASSERT_RVAL(!!font1, (XFontSet) 0);
if (font2) { if (font2) {
fontname = MALLOC(strlen(font1) + strlen(font2) /*+ sizeof(fs_base)*/ + 2); fontname = MALLOC(strlen(font1) + strlen(font2) /*+ sizeof(fs_base)*/ + 2);
@ -1908,7 +1908,7 @@ init_locale(void)
locale = setlocale(LC_ALL, ""); locale = setlocale(LC_ALL, "");
XSetLocaleModifiers(""); XSetLocaleModifiers("");
TermWin.fontset = (XFontSet) 0; TermWin.fontset = (XFontSet) 0;
if ((locale == NULL) || (!XSupportsLocale())) { if ((!locale) || (!XSupportsLocale())) {
libast_print_warning("Locale not supported; defaulting to portable \"C\" locale.\n"); libast_print_warning("Locale not supported; defaulting to portable \"C\" locale.\n");
locale = setlocale(LC_ALL, "C"); locale = setlocale(LC_ALL, "C");
XSetLocaleModifiers(""); XSetLocaleModifiers("");
@ -1956,7 +1956,7 @@ xim_send_spot(void)
static XPoint oldSpot = { -1, -1 }; static XPoint oldSpot = { -1, -1 };
XVaNestedList preedit_attr; XVaNestedList preedit_attr;
if (xim_input_context == NULL) { if (!xim_input_context) {
return; return;
} }
@ -2029,7 +2029,7 @@ xim_real_init(void)
XVaNestedList preedit_attr = NULL; XVaNestedList preedit_attr = NULL;
XVaNestedList status_attr = NULL; XVaNestedList status_attr = NULL;
REQUIRE_RVAL(xim_input_context == NULL, -1); REQUIRE_RVAL(!xim_input_context, -1);
xim_input_style = 0; xim_input_style = 0;
@ -2045,8 +2045,8 @@ xim_real_init(void)
*(end + 1) = '\0'; *(end + 1) = '\0';
if (*s) { if (*s) {
snprintf(buf, sizeof(buf), "@im=%s", s); snprintf(buf, sizeof(buf), "@im=%s", s);
if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) if (((p = XSetLocaleModifiers(buf))) && (*p)
&& ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) { && ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)))) {
break; break;
} }
} }
@ -2057,20 +2057,20 @@ xim_real_init(void)
} }
/* try with XMODIFIERS env. var. */ /* 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); xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
} }
/* try with no modifiers base */ /* 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); 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); xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
} }
if (xim_input_method == NULL) { if (!xim_input_method) {
return -1; return -1;
} }
#ifdef USE_X11R6_XIM #ifdef USE_X11R6_XIM
@ -2157,7 +2157,7 @@ xim_real_init(void)
if (status_attr) { if (status_attr) {
XFree(status_attr); XFree(status_attr);
} }
if (xim_input_context == NULL) { if (!xim_input_context) {
libast_print_error("Failed to create input context\n"); libast_print_error("Failed to create input context\n");
XCloseIM(xim_input_method); XCloseIM(xim_input_method);
return -1; return -1;
@ -2174,7 +2174,7 @@ xim_set_status_position(void)
XVaNestedList preedit_attr, status_attr; XVaNestedList preedit_attr, status_attr;
XPoint spot; XPoint spot;
REQUIRE(xim_input_context != NULL); REQUIRE(!!xim_input_context);
if (xim_input_style & XIMPreeditPosition) { if (xim_input_style & XIMPreeditPosition) {
xim_set_size(&rect); xim_set_size(&rect);
@ -2205,7 +2205,7 @@ xim_set_fontset(void)
XVaNestedList preedit_attr = NULL; XVaNestedList preedit_attr = NULL;
XVaNestedList status_attr = NULL; XVaNestedList status_attr = NULL;
REQUIRE(xim_input_context != NULL); REQUIRE(!!xim_input_context);
if (xim_input_style & XIMStatusArea) { if (xim_input_style & XIMStatusArea) {
status_attr = XVaCreateNestedList(0, XNFontSet, TermWin.fontset, NULL); status_attr = XVaCreateNestedList(0, XNFontSet, TermWin.fontset, NULL);
@ -2376,7 +2376,7 @@ run_command(char **argv)
if (chdir(initial_dir)) { if (chdir(initial_dir)) {
libast_print_warning("Unable to chdir to \"%s\" -- %s\n", initial_dir, strerror(errno)); 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 >= DEBUG_CMD
if (DEBUG_LEVEL >= DEBUG_CMD) { if (DEBUG_LEVEL >= DEBUG_CMD) {
int i; int i;
@ -2393,7 +2393,7 @@ run_command(char **argv)
const char *argv0, *shell; const char *argv0, *shell;
if ((shell = getenv("SHELL")) == NULL || *shell == '\0') if (!(shell = getenv("SHELL")) || *shell == '\0')
shell = "/bin/sh"; shell = "/bin/sh";
argv0 = my_basename(shell); argv0 = my_basename(shell);
@ -3089,14 +3089,14 @@ escreen_init(char **argv)
efuns = escreen_reg_funcs(); efuns = escreen_reg_funcs();
/* Create buttonbar for Escreen's use. */ /* Create buttonbar for Escreen's use. */
if ((bbar = bbar_create()) == NULL) { if (!(bbar = bbar_create())) {
if (buttonbar != NULL) { if (buttonbar) {
bbar = buttonbar; bbar = buttonbar;
} else { } else {
return -1; return -1;
} }
} else { } else {
if (buttonbar == NULL) { if (!buttonbar) {
buttonbar = bbar; buttonbar = bbar;
} }
bbar_set_font(bbar, ((rs_es_font) ? (rs_es_font) : ("-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1"))); 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); 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)); D_CMD(("ns_attach_by_URL(%s,%s) failed\n", rs_url, rs_hop));
return -1; return -1;
} }
@ -3284,7 +3284,7 @@ check_pixmap_change(int sig)
last_update = now; last_update = now;
old_handler = signal(SIGALRM, check_pixmap_change); old_handler = signal(SIGALRM, check_pixmap_change);
alarm(rs_anim_delay); alarm(rs_anim_delay);
if (rs_anim_pixmaps[image_idx] == NULL) { if (!rs_anim_pixmaps[image_idx]) {
image_idx = 0; image_idx = 0;
} }
} }
@ -3390,7 +3390,7 @@ cmd_getc(void)
XNextEvent(Xdisplay, &ev); XNextEvent(Xdisplay, &ev);
#ifdef USE_XIM #ifdef USE_XIM
if (xim_input_context != NULL) { if (xim_input_context) {
if (!XFilterEvent(&ev, ev.xkey.window)) { if (!XFilterEvent(&ev, ev.xkey.window)) {
event_dispatch(&ev); event_dispatch(&ev);
} }
@ -3803,7 +3803,7 @@ v_writeBig(int f, char *d, int len)
int written; int written;
int c = len; int c = len;
if (v_bufstr == NULL && len > 0) { if (!v_bufstr && len > 0) {
v_buffer = MALLOC(len); v_buffer = MALLOC(len);
v_bufstr = v_buffer; v_bufstr = v_buffer;

View File

@ -178,10 +178,10 @@ eterm_default_font_locale(char ***fonts, char ***mfonts, char **mencoding, int *
int j, k; int j, k;
locale = setlocale(LC_CTYPE, ""); locale = setlocale(LC_CTYPE, "");
if (locale == NULL) if (!locale)
if ((locale = getenv("LC_ALL")) == NULL) if (!(locale = getenv("LC_ALL")))
if ((locale = getenv("LC_CTYPE")) == NULL) if (!(locale = getenv("LC_CTYPE")))
if ((locale = getenv("LANG")) == NULL) if (!(locale = getenv("LANG")))
locale = "C"; /* failsafe */ locale = "C"; /* failsafe */
/* Obtain a "normalized" name of current encoding. /* Obtain a "normalized" name of current encoding.

View File

@ -168,7 +168,7 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up)
real_depth = Xdepth; real_depth = Xdepth;
} }
ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap); ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap);
if (ximg == NULL) { if (!ximg) {
return; return;
} }
/* Determine bitshift and bitmask values */ /* Determine bitshift and bitmask values */

View File

@ -156,12 +156,12 @@ enl_ipc_send(char *str)
unsigned short len; unsigned short len;
XEvent ev; XEvent ev;
if (str == NULL) { if (!str) {
ASSERT(last_msg != NULL); ASSERT(!!last_msg);
str = last_msg; str = last_msg;
D_ENL(("Resending last message \"%s\" to Enlightenment.\n", str)); D_ENL(("Resending last message \"%s\" to Enlightenment.\n", str));
} else { } else {
if (last_msg != NULL) { if (last_msg) {
FREE(last_msg); FREE(last_msg);
} }
last_msg = STRDUP(str); last_msg = STRDUP(str);
@ -246,7 +246,7 @@ enl_ipc_get(const char *msg_data)
} }
buff[12] = 0; buff[12] = 0;
blen = strlen(buff); blen = strlen(buff);
if (message != NULL) { if (message) {
len += blen; len += blen;
message = (char *) REALLOC(message, len + 1); message = (char *) REALLOC(message, len + 1);
strcat(message, buff); strcat(message, buff);

View File

@ -192,8 +192,8 @@ static enc_context_t *enc_create_context(const char *id)
static void static void
enc_context_add_state(enc_context_t *context, enc_state_t *state) enc_context_add_state(enc_context_t *context, enc_state_t *state)
{ {
ASSERT(context != NULL); ASSERT(!!context);
ASSERT(state != NULL); ASSERT(!!state);
state->next = context->states; state->next = context->states;
context->states = state; context->states = state;
@ -225,14 +225,14 @@ enc_state_add_switch(enc_state_t *state, unsigned char key, enc_state_t *next_st
static void static void
enc_state_set_in_table(enc_state_t *state, trans_table_t in_tbl) enc_state_set_in_table(enc_state_t *state, trans_table_t in_tbl)
{ {
ASSERT(state != NULL); ASSERT(!!state);
state->in_tbl = in_tbl; state->in_tbl = in_tbl;
} }
static void static void
enc_state_set_out_table(enc_state_t *state, trans_table_t out_tbl) enc_state_set_out_table(enc_state_t *state, trans_table_t out_tbl)
{ {
ASSERT(state != NULL); ASSERT(!!state);
state->out_tbl = out_tbl; state->out_tbl = out_tbl;
} }

View File

@ -99,7 +99,7 @@ void
event_data_add_mywin(event_dispatcher_data_t *data, Window win) event_data_add_mywin(event_dispatcher_data_t *data, Window win)
{ {
ASSERT(data != NULL); ASSERT(!!data);
if (data->num_my_windows > 0) { if (data->num_my_windows > 0) {
(data->num_my_windows)++; (data->num_my_windows)++;
@ -116,7 +116,7 @@ void
event_data_add_parent(event_dispatcher_data_t *data, Window win) event_data_add_parent(event_dispatcher_data_t *data, Window win)
{ {
ASSERT(data != NULL); ASSERT(!!data);
if (data->num_my_parents > 0) { if (data->num_my_parents > 0) {
(data->num_my_parents)++; (data->num_my_parents)++;
@ -171,7 +171,7 @@ event_win_is_mywin(register event_dispatcher_data_t *data, Window win)
register unsigned short i; register unsigned short i;
ASSERT_RVAL(data != NULL, 0); ASSERT_RVAL(!!data, 0);
for (i = 0; i < data->num_my_windows; i++) { for (i = 0; i < data->num_my_windows; i++) {
if (data->my_windows[i] == win) { if (data->my_windows[i] == win) {
@ -187,7 +187,7 @@ event_win_is_parent(register event_dispatcher_data_t *data, Window win)
register unsigned short i; register unsigned short i;
ASSERT_RVAL(data != NULL, 0); ASSERT_RVAL(!!data, 0);
for (i = 0; i < data->num_my_parents; i++) { for (i = 0; i < data->num_my_parents; i++) {
if (data->my_parents[i] == win) { if (data->my_parents[i] == win) {
@ -353,7 +353,7 @@ handle_client_message(event_t *ev)
XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType,
&ActualFormat, &Size, &RemainingBytes, &data); &ActualFormat, &Size, &RemainingBytes, &data);
if (data != NULL) { if (data) {
XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data)); XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data));
selection_paste(XA_CUT_BUFFER0); selection_paste(XA_CUT_BUFFER0);
XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime); XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime);
@ -493,7 +493,7 @@ handle_focus_in(event_t *ev)
} }
bbar_draw_all(IMAGE_STATE_NORMAL, MODE_SOLID); bbar_draw_all(IMAGE_STATE_NORMAL, MODE_SOLID);
#ifdef USE_XIM #ifdef USE_XIM
if (xim_input_context != NULL) if (xim_input_context)
XSetICFocus(xim_input_context); XSetICFocus(xim_input_context);
#endif #endif
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) { 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); bbar_draw_all(IMAGE_STATE_DISABLED, MODE_SOLID);
#ifdef USE_XIM #ifdef USE_XIM
if (xim_input_context != NULL) if (xim_input_context)
XUnsetICFocus(xim_input_context); XUnsetICFocus(xim_input_context);
#endif #endif
} }
@ -874,7 +874,7 @@ process_x_event(event_t *ev)
#if 0 #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)); 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 #endif
if (primary_data.handlers[ev->type] != NULL) { if (primary_data.handlers[ev->type]) {
return ((primary_data.handlers[ev->type]) (ev)); return ((primary_data.handlers[ev->type]) (ev));
} }
return (0); return (0);

View File

@ -71,7 +71,7 @@ eterm_font_add(char ***plist, const char *fontname, unsigned char idx)
char **flist; char **flist;
D_FONT(("Adding \"%s\" at %u (%8p)\n", NONULL(fontname), (unsigned int) idx, plist)); D_FONT(("Adding \"%s\" at %u (%8p)\n", NONULL(fontname), (unsigned int) idx, plist));
ASSERT(plist != NULL); /* plist is the address of either etfonts or etmfonts */ ASSERT(!!plist); /* plist is the address of either etfonts or etmfonts */
/* If we're adding the font at an index we don't have yet, we must resize to fit it. */ /* If we're adding the font at an index we don't have yet, we must resize to fit it. */
if (idx >= font_cnt) { if (idx >= font_cnt) {
@ -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)); 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. */ /* 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_cache = cur_font = font;
font->next = NULL; font->next = NULL;
D_FONT((" -> Stored as first font in cache. font_cache == cur_font == font == %p\n", font_cache)); 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)); 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... */ return; /* No fonts in the cache. Theoretically this should never happen, but... */
} }
@ -284,7 +284,7 @@ static cachefont_t *font_cache_find(const char *name, unsigned char type)
cachefont_t *current; cachefont_t *current;
ASSERT_RVAL(name != NULL, NULL); ASSERT_RVAL(!!name, NULL);
D_FONT(("font_cache_find(%s, %d) called.\n", NONULL(name), type)); D_FONT(("font_cache_find(%s, %d) called.\n", NONULL(name), type));
@ -306,7 +306,7 @@ font_cache_find_info(const char *name, unsigned char type)
cachefont_t *current; cachefont_t *current;
REQUIRE_RVAL(name != NULL, NULL); REQUIRE_RVAL(!!name, NULL);
D_FONT(("font_cache_find_info(%s, %d) called.\n", NONULL(name), type)); D_FONT(("font_cache_find_info(%s, %d) called.\n", NONULL(name), type));
@ -340,7 +340,7 @@ get_font_name(void *info)
{ {
cachefont_t *current; cachefont_t *current;
REQUIRE_RVAL(info != NULL, NULL); REQUIRE_RVAL(!!info, NULL);
D_FONT(("get_font_name(%8p) called.\n", info)); D_FONT(("get_font_name(%8p) called.\n", info));
@ -376,7 +376,7 @@ load_font(const char *name, const char *fallback, unsigned char type)
} }
/* Specify some sane fallbacks */ /* Specify some sane fallbacks */
if (name == NULL) { if (!name) {
if (fallback) { if (fallback) {
name = fallback; name = fallback;
fallback = "fixed"; 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"; fallback = "-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1";
#endif #endif
} }
} else if (fallback == NULL) { } else if (!fallback) {
fallback = "fixed"; fallback = "fixed";
} }
D_FONT((" -> Using name == \"%s\" and fallback == \"%s\"\n", name, fallback)); 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 /* 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. */ 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); font_cache_add_ref(font);
D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt)); D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt));
switch (type) { 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. */ /* No match in the cache, so we'll have to add it. */
if (type == FONT_TYPE_X) { 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); 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"); libast_fatal_error("Couldn't load the fallback font either. Giving up.\n");
} else { } else {
font_cache_add(fallback, type, (void *) xfont); font_cache_add(fallback, type, (void *) xfont);
@ -441,7 +441,7 @@ load_font(const char *name, const char *fallback, unsigned char type)
void void
free_font(const void *info) free_font(const void *info)
{ {
ASSERT(info != NULL); ASSERT(!!info);
font_cache_del(info); font_cache_del(info);
} }
@ -460,19 +460,19 @@ change_font(int init, const char *fontname)
(unsigned int) font_idx)); (unsigned int) font_idx));
if (init) { if (init) {
ASSERT(etfonts != NULL); ASSERT(!!etfonts);
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; def_font_idx = font_idx;
} else { } else {
font_idx = def_font_idx; font_idx = def_font_idx;
} }
ASSERT(etfonts[font_idx] != NULL); ASSERT(!!etfonts[font_idx]);
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
ASSERT(etmfonts != NULL); ASSERT(!!etmfonts);
ASSERT(etmfonts[font_idx] != NULL); ASSERT(!!etmfonts[font_idx]);
#endif #endif
} else { } else {
ASSERT(fontname != NULL); ASSERT(!!fontname);
switch (*fontname) { switch (*fontname) {
/* Empty font name. Reset to default. */ /* Empty font name. Reset to default. */
@ -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 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); eterm_font_add(&etfonts, fontname, font_idx);
} else if (font_idx == old_idx) { } else if (font_idx == old_idx) {
/* Sigh. What a waste of time, changing to the same font. */ /* 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 #ifndef NO_BOLDFONT
if (init && rs_boldFont != NULL) { if (init && rs_boldFont) {
/* If we're initializing, load the bold font too. */ /* 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); 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 */ /* Check the bold font size and make sure it matches the normal font */
#ifndef NO_BOLDFONT #ifndef NO_BOLDFONT
TermWin.boldFont = NULL; /* FIXME: Memory leak? Not that anyone uses bold fonts.... */ TermWin.boldFont = NULL; /* FIXME: Memory leak? Not that anyone uses bold fonts.... */
if (boldFont != NULL) { if (boldFont) {
fw = boldFont->min_bounds.width; fw = boldFont->min_bounds.width;
fh = boldFont->ascent + boldFont->descent + rs_line_space; fh = boldFont->ascent + boldFont->descent + rs_line_space;
@ -746,7 +746,7 @@ parse_font_fx(char *line)
unsigned char which, n; unsigned char which, n;
Pixel p; Pixel p;
ASSERT_RVAL(line != NULL, 0); ASSERT_RVAL(!!line, 0);
n = spiftool_num_words(line); n = spiftool_num_words(line);
@ -825,7 +825,7 @@ parse_font_fx(char *line)
} }
set_shadow_color_by_name(which, color); set_shadow_color_by_name(which, color);
FREE(color); FREE(color);
if (line == NULL) { if (!line) {
break; break;
} }
} }

View File

@ -250,7 +250,7 @@ kstate_add_xlat(char *str)
char *sval; char *sval;
int i; int i;
if (str == NULL) if (!str)
return; return;
/* add a new xlat table in state */ /* add a new xlat table in state */
if (pStateNow->num_xlat == 0) { if (pStateNow->num_xlat == 0) {
@ -263,11 +263,11 @@ kstate_add_xlat(char *str)
xlat->last = (u_int) atoi(strtok(NULL, ":")); xlat->last = (u_int) atoi(strtok(NULL, ":"));
i = 0; i = 0;
pval_tmp = CALLOC(MAX_VAL, sizeof(K_XLAT)); pval_tmp = CALLOC(MAX_VAL, sizeof(K_XLAT));
while ((sval = strtok(NULL, ",")) != NULL) { while ((sval = strtok(NULL, ","))) {
pval_tmp[i++] = (u_int) (atoi(sval)); pval_tmp[i++] = (u_int) (atoi(sval));
} }
xlat->pval = CALLOC(i, sizeof(K_XLAT)); xlat->pval = CALLOC(i, sizeof(K_XLAT));
if (xlat->pval != NULL) if (xlat->pval)
memcpy(xlat->pval, pval_tmp, i * sizeof(u_int)); memcpy(xlat->pval, pval_tmp, i * sizeof(u_int));
FREE(pval_tmp); FREE(pval_tmp);
pStateNow->num_xlat++; pStateNow->num_xlat++;
@ -281,7 +281,7 @@ kstate_add_switcher(char *str)
{ {
K_SWITCH *switcher; K_SWITCH *switcher;
if (str == NULL) if (!str)
return; return;
if (pStateNow->num_switcher >= MAX_SWITCHER) if (pStateNow->num_switcher >= MAX_SWITCHER)
return; return;

View File

@ -301,7 +301,7 @@ menu_handle_button_release(event_t *ev)
if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) { if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) {
/* Take action here based on the current menu item */ /* 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) { if (item->type == MENUITEM_SUBMENU) {
menu_display_submenu(current_menu, item); menu_display_submenu(current_menu, item);
} else { } 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) if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w)
&& (ev->xbutton.y < current_menu->h)) { && (ev->xbutton.y < current_menu->h)) {
/* Click inside the menu window. Activate the current item. */ /* 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) { if (item->type == MENUITEM_SUBMENU) {
menu_display_submenu(current_menu, item); menu_display_submenu(current_menu, item);
} else { } else {
@ -415,7 +415,7 @@ menu_handle_motion_notify(event_t *ev)
unsigned char unsigned char
menu_dispatch_event(event_t *ev) 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 ((menu_event_data.handlers[ev->type]) (ev));
} }
return (0); return (0);
@ -423,7 +423,7 @@ menu_dispatch_event(event_t *ev)
menulist_t *menulist_add_menu(menulist_t *list, menu_t *menu) menulist_t *menulist_add_menu(menulist_t *list, menu_t *menu)
{ {
ASSERT_RVAL(menu != NULL, list); ASSERT_RVAL(!!menu, list);
if (list) { if (list) {
list->nummenus++; list->nummenus++;
@ -442,7 +442,7 @@ menulist_clear(menulist_t *list)
{ {
unsigned long i; unsigned long i;
ASSERT(list != NULL); ASSERT(!!list);
for (i = 0; i < list->nummenus; i++) { for (i = 0; i < list->nummenus; i++) {
menu_delete(list->menus[i]); menu_delete(list->menus[i]);
@ -496,7 +496,7 @@ menu_delete(menu_t *menu)
{ {
unsigned short i; unsigned short i;
ASSERT(menu != NULL); ASSERT(!!menu);
D_MENU(("Deleting menu \"%s\"\n", menu->title)); D_MENU(("Deleting menu \"%s\"\n", menu->title));
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
@ -535,8 +535,8 @@ menu_delete(menu_t *menu)
unsigned char unsigned char
menu_set_title(menu_t *menu, const char *title) menu_set_title(menu_t *menu, const char *title)
{ {
ASSERT_RVAL(menu != NULL, 0); ASSERT_RVAL(!!menu, 0);
REQUIRE_RVAL(title != NULL, 0); REQUIRE_RVAL(!!title, 0);
FREE(menu->title); FREE(menu->title);
menu->title = STRDUP(title); menu->title = STRDUP(title);
@ -550,8 +550,8 @@ menu_set_font(menu_t *menu, const char *fontname)
XFontStruct *font; XFontStruct *font;
XGCValues gcvalue; XGCValues gcvalue;
ASSERT_RVAL(menu != NULL, 0); ASSERT_RVAL(!!menu, 0);
REQUIRE_RVAL(fontname != NULL, 0); REQUIRE_RVAL(!!fontname, 0);
font = (XFontStruct *) load_font(fontname, "fixed", FONT_TYPE_X); font = (XFontStruct *) load_font(fontname, "fixed", FONT_TYPE_X);
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
@ -571,8 +571,8 @@ menu_set_font(menu_t *menu, const char *fontname)
unsigned char unsigned char
menu_add_item(menu_t *menu, menuitem_t *item) menu_add_item(menu_t *menu, menuitem_t *item)
{ {
ASSERT_RVAL(menu != NULL, 0); ASSERT_RVAL(!!menu, 0);
ASSERT_RVAL(item != NULL, 0); ASSERT_RVAL(!!item, 0);
if (menu->numitems) { if (menu->numitems) {
menu->numitems++; menu->numitems++;
@ -594,12 +594,12 @@ menu_is_child(menu_t *menu, menu_t *submenu)
register unsigned char i; register unsigned char i;
register menuitem_t *item; register menuitem_t *item;
ASSERT_RVAL(menu != NULL, 0); ASSERT_RVAL(!!menu, 0);
ASSERT_RVAL(submenu != NULL, 0); ASSERT_RVAL(!!submenu, 0);
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
item = menu->items[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) { if (item->action.submenu == submenu) {
return 1; return 1;
} else if (menu_is_child(item->action.submenu, submenu)) { } else if (menu_is_child(item->action.submenu, submenu)) {
@ -614,7 +614,7 @@ menu_t *find_menu_by_title(menulist_t *list, char *title)
{ {
register unsigned char i; register unsigned char i;
REQUIRE_RVAL(list != NULL, NULL); REQUIRE_RVAL(!!list, NULL);
for (i = 0; i < list->nummenus; i++) { for (i = 0; i < list->nummenus; i++) {
if (!strcasecmp(list->menus[i]->title, title)) { if (!strcasecmp(list->menus[i]->title, title)) {
@ -628,7 +628,7 @@ menu_t *find_menu_by_window(menulist_t *list, Window win)
{ {
register unsigned char i; register unsigned char i;
REQUIRE_RVAL(list != NULL, NULL); REQUIRE_RVAL(!!list, NULL);
for (i = 0; i < list->nummenus; i++) { for (i = 0; i < list->nummenus; i++) {
if (list->menus[i]->win == win) { if (list->menus[i]->win == win) {
@ -643,7 +643,7 @@ menuitem_t *find_item_by_coords(menu_t *menu, int x, int y)
register unsigned char i; register unsigned char i;
register menuitem_t *item; register menuitem_t *item;
ASSERT_RVAL(menu != NULL, NULL); ASSERT_RVAL(!!menu, NULL);
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
item = menu->items[i]; item = menu->items[i];
@ -659,8 +659,8 @@ find_item_in_menu(menu_t *menu, menuitem_t *item)
{ {
register unsigned char i; register unsigned char i;
ASSERT_RVAL(menu != NULL, (unsigned short) -1); ASSERT_RVAL(!!menu, (unsigned short) -1);
ASSERT_RVAL(item != NULL, (unsigned short) -1); ASSERT_RVAL(!!item, (unsigned short) -1);
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
if (item == menu->items[i]) { if (item == menu->items[i]) {
@ -675,7 +675,7 @@ menuitem_change_current(menuitem_t *item)
{ {
menuitem_t *current; menuitem_t *current;
ASSERT(current_menu != NULL); ASSERT(!!current_menu);
current = menuitem_get_current(current_menu); current = menuitem_get_current(current_menu);
if (current != item) { if (current != item) {
@ -686,8 +686,8 @@ menuitem_change_current(menuitem_t *item)
menuitem_deselect(current_menu); 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 /* 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 */ no current item at all, reset the tree for the current submenu */
if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) { if (current->type == MENUITEM_SUBMENU && current->action.submenu) {
if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu
&& !menu_is_child(current->action.submenu, item->action.submenu) && !menu_is_child(current->action.submenu, item->action.submenu)
&& !menu_is_child(item->action.submenu, current->action.submenu)) && !menu_is_child(item->action.submenu, current->action.submenu))
|| (!item)) { || (!item)) {
@ -727,7 +727,7 @@ menuitem_t *menuitem_create(char *text)
void void
menuitem_delete(menuitem_t *item) menuitem_delete(menuitem_t *item)
{ {
ASSERT(item != NULL); ASSERT(!!item);
if (item->icon) { if (item->icon) {
free_simage(item->icon); free_simage(item->icon);
@ -751,8 +751,8 @@ menuitem_delete(menuitem_t *item)
unsigned char unsigned char
menuitem_set_text(menuitem_t *item, const char *text) menuitem_set_text(menuitem_t *item, const char *text)
{ {
ASSERT_RVAL(item != NULL, 0); ASSERT_RVAL(!!item, 0);
REQUIRE_RVAL(text != NULL, 0); REQUIRE_RVAL(!!text, 0);
if (item->text) { if (item->text) {
FREE(item->text); FREE(item->text);
@ -765,8 +765,8 @@ menuitem_set_text(menuitem_t *item, const char *text)
unsigned char unsigned char
menuitem_set_icon(menuitem_t *item, simage_t *icon) menuitem_set_icon(menuitem_t *item, simage_t *icon)
{ {
ASSERT_RVAL(item != NULL, 0); ASSERT_RVAL(!!item, 0);
ASSERT_RVAL(icon != NULL, 0); ASSERT_RVAL(!!icon, 0);
item->icon = icon; item->icon = icon;
return 1; return 1;
@ -775,7 +775,7 @@ menuitem_set_icon(menuitem_t *item, simage_t *icon)
unsigned char unsigned char
menuitem_set_action(menuitem_t *item, unsigned char type, char *action) menuitem_set_action(menuitem_t *item, unsigned char type, char *action)
{ {
ASSERT_RVAL(item != NULL, 0); ASSERT_RVAL(!!item, 0);
item->type = type; item->type = type;
switch (type) { switch (type) {
@ -805,8 +805,8 @@ menuitem_set_action(menuitem_t *item, unsigned char type, char *action)
unsigned char unsigned char
menuitem_set_rtext(menuitem_t *item, char *rtext) menuitem_set_rtext(menuitem_t *item, char *rtext)
{ {
ASSERT_RVAL(item != NULL, 0); ASSERT_RVAL(!!item, 0);
ASSERT_RVAL(rtext != NULL, 0); ASSERT_RVAL(!!rtext, 0);
item->rtext = STRDUP(rtext); item->rtext = STRDUP(rtext);
item->rlen = strlen(rtext); item->rlen = strlen(rtext);
@ -816,7 +816,7 @@ menuitem_set_rtext(menuitem_t *item, char *rtext)
void void
menu_reset(menu_t *menu) menu_reset(menu_t *menu)
{ {
ASSERT(menu != NULL); ASSERT(!!menu);
D_MENU(("menu_reset(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win)); D_MENU(("menu_reset(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win));
if (!(menu->state & MENU_STATE_IS_MAPPED)) { if (!(menu->state & MENU_STATE_IS_MAPPED)) {
@ -833,13 +833,13 @@ menu_reset_all(menulist_t *list)
{ {
register unsigned short i; register unsigned short i;
ASSERT(list != NULL); ASSERT(!!list);
if (list->nummenus == 0) if (list->nummenus == 0)
return; return;
D_MENU(("menu_reset_all(%8p) called\n", list)); 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); menuitem_deselect(current_menu);
} }
for (i = 0; i < list->nummenus; i++) { for (i = 0; i < list->nummenus; i++) {
@ -854,7 +854,7 @@ menu_reset_tree(menu_t *menu)
register unsigned short i; register unsigned short i;
register menuitem_t *item; register menuitem_t *item;
ASSERT(menu != NULL); ASSERT(!!menu);
D_MENU(("menu_reset_tree(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win)); D_MENU(("menu_reset_tree(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win));
if (!(menu->state & MENU_STATE_IS_MAPPED)) { if (!(menu->state & MENU_STATE_IS_MAPPED)) {
@ -862,7 +862,7 @@ menu_reset_tree(menu_t *menu)
} }
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
item = menu->items[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); menu_reset_tree(item->action.submenu);
} }
} }
@ -875,12 +875,12 @@ menu_reset_submenus(menu_t *menu)
register unsigned short i; register unsigned short i;
register menuitem_t *item; register menuitem_t *item;
ASSERT(menu != NULL); ASSERT(!!menu);
D_MENU(("menu_reset_submenus(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win)); D_MENU(("menu_reset_submenus(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win));
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
item = menu->items[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); menu_reset_tree(item->action.submenu);
} }
} }
@ -892,7 +892,7 @@ menuitem_select(menu_t *menu)
static Pixel top = 0, bottom = 0; static Pixel top = 0, bottom = 0;
menuitem_t *item; menuitem_t *item;
ASSERT(menu != NULL); ASSERT(!!menu);
if (top == 0) { if (top == 0) {
top = get_top_shadow_color(images[image_submenu].selected->bg, "submenu top shadow color"); top = get_top_shadow_color(images[image_submenu].selected->bg, "submenu top shadow color");
@ -900,7 +900,7 @@ menuitem_select(menu_t *menu)
} }
item = menuitem_get_current(menu); item = menuitem_get_current(menu);
REQUIRE(item != NULL); REQUIRE(!!item);
D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text, D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text,
menu->title, menu->win, menu->swin)); menu->title, menu->win, menu->swin));
item->state |= MENU_STATE_IS_CURRENT; item->state |= MENU_STATE_IS_CURRENT;
@ -939,10 +939,10 @@ menuitem_deselect(menu_t *menu)
{ {
menuitem_t *item; menuitem_t *item;
ASSERT(menu != NULL); ASSERT(!!menu);
item = menuitem_get_current(menu); item = menuitem_get_current(menu);
REQUIRE(item != NULL); REQUIRE(!!item);
D_MENU(("Deselecting item \"%s\"\n", item->text)); D_MENU(("Deselecting item \"%s\"\n", item->text));
item->state &= ~(MENU_STATE_IS_CURRENT); item->state &= ~(MENU_STATE_IS_CURRENT);
XUnmapWindow(Xdisplay, menu->swin); XUnmapWindow(Xdisplay, menu->swin);
@ -953,9 +953,9 @@ menu_display_submenu(menu_t *menu, menuitem_t *item)
{ {
menu_t *submenu; menu_t *submenu;
ASSERT(menu != NULL); ASSERT(!!menu);
ASSERT(item != NULL); ASSERT(!!item);
REQUIRE(item->action.submenu != NULL); REQUIRE(!!item->action.submenu);
submenu = item->action.submenu; submenu = item->action.submenu;
D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title, D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title,
@ -974,7 +974,7 @@ void
menu_move(menu_t *menu, unsigned short x, unsigned short y) menu_move(menu_t *menu, unsigned short x, unsigned short y)
{ {
ASSERT(menu != NULL); ASSERT(!!menu);
D_MENU(("Moving menu \"%s\" to %hu, %hu\n", menu->title, x, y)); D_MENU(("Moving menu \"%s\" to %hu, %hu\n", menu->title, x, y));
menu->x = x; menu->x = x;
@ -996,7 +996,7 @@ menu_draw(menu_t *menu)
XCharStruct chars; XCharStruct chars;
Screen *scr; Screen *scr;
ASSERT(menu != NULL); ASSERT(!!menu);
scr = ScreenOfDisplay(Xdisplay, Xscreen); scr = ScreenOfDisplay(Xdisplay, Xscreen);
if (!menu->font) { if (!menu->font) {
@ -1177,7 +1177,7 @@ menu_draw(menu_t *menu)
void void
menu_display(int x, int y, menu_t *menu) menu_display(int x, int y, menu_t *menu)
{ {
ASSERT(menu != NULL); ASSERT(!!menu);
menu->state |= (MENU_STATE_IS_CURRENT); menu->state |= (MENU_STATE_IS_CURRENT);
current_menu = menu; current_menu = menu;
@ -1197,7 +1197,7 @@ menu_display(int x, int y, menu_t *menu)
void void
menu_action(menuitem_t *item) menu_action(menuitem_t *item)
{ {
ASSERT(item != NULL); ASSERT(!!item);
D_MENU(("menu_action() called to invoke %s\n", item->text)); D_MENU(("menu_action() called to invoke %s\n", item->text));
switch (item->type) { switch (item->type) {
@ -1250,7 +1250,7 @@ menu_invoke(int x, int y, Window win, menu_t *menu, Time timestamp)
int root_x, root_y; int root_x, root_y;
Window unused; Window unused;
REQUIRE(menu != NULL); REQUIRE(!!menu);
if (timestamp != CurrentTime) { if (timestamp != CurrentTime) {
button_press_time = timestamp; button_press_time = timestamp;
@ -1266,8 +1266,8 @@ menu_invoke_by_title(int x, int y, Window win, char *title, Time timestamp)
{ {
menu_t *menu; menu_t *menu;
REQUIRE(title != NULL); REQUIRE(!!title);
REQUIRE(menu_list != NULL); REQUIRE(!!menu_list);
menu = find_menu_by_title(menu_list, title); menu = find_menu_by_title(menu_list, title);
if (!menu) { if (!menu) {
@ -1344,11 +1344,11 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
inp_tab = NULL; inp_tab = NULL;
maxlen = 0; maxlen = 0;
retstr = NULL; retstr = NULL;
if ((b = STRDUP("Press \"Return\" to continue...")) == NULL) { if (!(b = STRDUP("Press \"Return\" to continue..."))) {
return ret; return ret;
} }
} else { } else {
if (((b = MALLOC(maxlen + 1)) == NULL)) { if ((!(b = MALLOC(maxlen + 1)))) {
return ret; return ret;
} else if (*retstr) { } else if (*retstr) {
strncpy(b, *retstr, maxlen); strncpy(b, *retstr, maxlen);

View File

@ -285,7 +285,7 @@ safe_print_string(const char *str, unsigned long len)
rb_size = 0; rb_size = 0;
return ((char *) NULL); return ((char *) NULL);
} }
if (ret_buff == NULL) { if (!ret_buff) {
rb_size = len; rb_size = len;
ret_buff = (char *) MALLOC(rb_size + 1); ret_buff = (char *) MALLOC(rb_size + 1);
} else if (len > rb_size) { } else if (len > rb_size) {

View File

@ -1345,7 +1345,7 @@ parse_keyboard(char *buff, void *state)
len = parse_escaped_string(str); len = parse_escaped_string(str);
if (len > 255) if (len > 255)
len = 255; /* We can only handle lengths that will fit in a char */ 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); char *p = MALLOC(len + 1);
@ -1592,7 +1592,7 @@ parse_image(char *buff, void *state)
*tmp = -1; *tmp = -1;
return ((void *) tmp); return ((void *) tmp);
} }
ASSERT_RVAL(state != NULL, (void *) (file_skip_to_end(), NULL)); ASSERT_RVAL(!!state, (void *) (file_skip_to_end(), NULL));
if (*buff == SPIFCONF_END_CHAR) { if (*buff == SPIFCONF_END_CHAR) {
int *tmp; int *tmp;
@ -1674,7 +1674,7 @@ parse_image(char *buff, void *state)
if (allow_list) { if (allow_list) {
char *allow; char *allow;
for (; (allow = (char *) strsep(&allow_list, " ")) != NULL;) { for (; (allow = (char *)strsep(&allow_list, " "));) {
if (!BEG_STRCASECMP(allow, "image")) { if (!BEG_STRCASECMP(allow, "image")) {
images[idx].mode |= ALLOW_IMAGE; images[idx].mode |= ALLOW_IMAGE;
} else if (!BEG_STRCASECMP(allow, "trans")) { } else if (!BEG_STRCASECMP(allow, "trans")) {
@ -1703,25 +1703,25 @@ parse_image(char *buff, void *state)
return NULL; return NULL;
} }
if (!strcasecmp(state, "normal")) { if (!strcasecmp(state, "normal")) {
if (images[idx].norm == NULL) { if (!images[idx].norm) {
images[idx].norm = (simage_t *) MALLOC(sizeof(simage_t)); images[idx].norm = (simage_t *) MALLOC(sizeof(simage_t));
new = 1; new = 1;
} }
images[idx].current = images[idx].norm; images[idx].current = images[idx].norm;
} else if (!strcasecmp(state, "selected")) { } else if (!strcasecmp(state, "selected")) {
if (images[idx].selected == NULL) { if (!images[idx].selected) {
images[idx].selected = (simage_t *) MALLOC(sizeof(simage_t)); images[idx].selected = (simage_t *) MALLOC(sizeof(simage_t));
new = 1; new = 1;
} }
images[idx].current = images[idx].selected; images[idx].current = images[idx].selected;
} else if (!strcasecmp(state, "clicked")) { } else if (!strcasecmp(state, "clicked")) {
if (images[idx].clicked == NULL) { if (!images[idx].clicked) {
images[idx].clicked = (simage_t *) MALLOC(sizeof(simage_t)); images[idx].clicked = (simage_t *) MALLOC(sizeof(simage_t));
new = 1; new = 1;
} }
images[idx].current = images[idx].clicked; images[idx].current = images[idx].clicked;
} else if (!strcasecmp(state, "disabled")) { } else if (!strcasecmp(state, "disabled")) {
if (images[idx].disabled == NULL) { if (!images[idx].disabled) {
images[idx].disabled = (simage_t *) MALLOC(sizeof(simage_t)); images[idx].disabled = (simage_t *) MALLOC(sizeof(simage_t));
new = 1; new = 1;
} }
@ -1745,7 +1745,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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(), libast_print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image state defined\n", file_peek_path(),
file_peek_line()); file_peek_line());
return NULL; return NULL;
@ -1777,7 +1777,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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(), libast_print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined\n", file_peek_path(),
file_peek_line()); file_peek_line());
return NULL; return NULL;
@ -1801,7 +1801,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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(), libast_print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined\n", file_peek_path(),
file_peek_line()); file_peek_line());
return NULL; return NULL;
@ -1825,7 +1825,7 @@ parse_image(char *buff, void *state)
file_peek_path(), file_peek_line()); file_peek_path(), file_peek_line());
return NULL; 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", 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()); file_peek_path(), file_peek_line());
return NULL; return NULL;
@ -1928,7 +1928,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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(), libast_print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined\n", file_peek_path(),
file_peek_line()); file_peek_line());
return NULL; return NULL;
@ -1938,7 +1938,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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->edges);
FREE(images[idx].current->iml->bevel); FREE(images[idx].current->iml->bevel);
} }
@ -1968,7 +1968,7 @@ parse_image(char *buff, void *state)
file_peek_line()); file_peek_line());
return NULL; 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", libast_print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n",
file_peek_path(), file_peek_line()); file_peek_path(), file_peek_line());
return NULL; return NULL;
@ -2099,7 +2099,7 @@ parse_menu(char *buff, void *state)
menu = menu_create(title); menu = menu_create(title);
return ((void *) menu); return ((void *) menu);
} }
ASSERT_RVAL(state != NULL, (void *) (file_skip_to_end(), NULL)); ASSERT_RVAL(!!state, (void *) (file_skip_to_end(), NULL));
menu = (menu_t *) state; menu = (menu_t *) state;
if (*buff == SPIFCONF_END_CHAR) { if (*buff == SPIFCONF_END_CHAR) {
if (!(*(menu->title))) { if (!(*(menu->title))) {
@ -2149,14 +2149,14 @@ parse_menuitem(char *buff, void *state)
static menu_t *menu; static menu_t *menu;
menuitem_t *curitem; menuitem_t *curitem;
ASSERT_RVAL(state != NULL, (void *) (file_skip_to_end(), NULL)); ASSERT_RVAL(!!state, (void *) (file_skip_to_end(), NULL));
if (*buff == SPIFCONF_BEGIN_CHAR) { if (*buff == SPIFCONF_BEGIN_CHAR) {
menu = (menu_t *) state; menu = (menu_t *) state;
curitem = menuitem_create(NULL); curitem = menuitem_create(NULL);
return ((void *) curitem); return ((void *) curitem);
} }
curitem = (menuitem_t *) state; curitem = (menuitem_t *) state;
ASSERT_RVAL(menu != NULL, state); ASSERT_RVAL(!!menu, state);
if (*buff == SPIFCONF_END_CHAR) { if (*buff == SPIFCONF_END_CHAR) {
if (!(curitem->text)) { if (!(curitem->text)) {
libast_print_error("Parse error in file %s, line %lu: Menuitem context ended with no text given. Discarding this entry.\n", libast_print_error("Parse error in file %s, line %lu: Menuitem context ended with no text given. Discarding this entry.\n",
@ -2231,7 +2231,7 @@ parse_bbar(char *buff, void *state)
bbar = bbar_create(); bbar = bbar_create();
return ((void *) bbar); return ((void *) bbar);
} }
ASSERT_RVAL(state != NULL, (void *) (file_skip_to_end(), NULL)); ASSERT_RVAL(!!state, (void *) (file_skip_to_end(), NULL));
bbar = (buttonbar_t *) state; bbar = (buttonbar_t *) state;
if (*buff == SPIFCONF_END_CHAR) { if (*buff == SPIFCONF_END_CHAR) {
bbar_add(bbar); bbar_add(bbar);
@ -2370,7 +2370,7 @@ parse_multichar(char *buff, void *state)
} }
if (!BEG_STRCASECMP(buff, "encoding ")) { if (!BEG_STRCASECMP(buff, "encoding ")) {
RESET_AND_ASSIGN(rs_multichar_encoding, spiftool_get_word(2, buff)); 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") if (BEG_STRCASECMP(rs_multichar_encoding, "eucj")
&& BEG_STRCASECMP(rs_multichar_encoding, "sjis") && BEG_STRCASECMP(rs_multichar_encoding, "sjis")
&& BEG_STRCASECMP(rs_multichar_encoding, "euckr") && 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); spifconf_shell_expand(path);
} }
if (fallback & PARSE_TRY_USER_THEME) { 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; return ret;
} }
} }
if (fallback & PARSE_TRY_DEFAULT_THEME) { if (fallback & PARSE_TRY_DEFAULT_THEME) {
RESET_AND_ASSIGN(*theme, STRDUP(PACKAGE)); 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; return ret;
} }
} }
@ -2634,8 +2634,8 @@ post_parse(void)
} }
/* set any defaults not already set */ /* set any defaults not already set */
if (rs_name == NULL) { if (!rs_name) {
if (rs_exec_args != NULL) { if (rs_exec_args) {
rs_name = STRDUP(rs_exec_args[0]); rs_name = STRDUP(rs_exec_args[0]);
} else { } else {
rs_name = STRDUP(APL_NAME " " VERSION); rs_name = STRDUP(APL_NAME " " VERSION);
@ -2666,7 +2666,7 @@ post_parse(void)
#endif #endif
#ifndef NO_BOLDFONT #ifndef NO_BOLDFONT
if (rs_font[0] == NULL && rs_boldFont != NULL) { if (!rs_font[0] && rs_boldFont) {
rs_font[0] = rs_boldFont; rs_font[0] = rs_boldFont;
rs_boldFont = NULL; 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))); 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); RESET_AND_ASSIGN(rs_mfont[i], NULL);
} }
} else if (etmfonts[i] == NULL) { } else if (!etmfonts[i]) {
eterm_font_add(&etmfonts, etfonts[i], i); eterm_font_add(&etmfonts, etfonts[i], i);
} }
#endif #endif
@ -2719,7 +2719,7 @@ post_parse(void)
#endif #endif
} }
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
if (rs_multichar_encoding != NULL) { if (rs_multichar_encoding) {
set_multichar_encoding(rs_multichar_encoding); set_multichar_encoding(rs_multichar_encoding);
} }
#endif #endif
@ -3042,7 +3042,7 @@ post_parse(void)
NumLockMask = modmasks[rs_numlock_mod - 1]; NumLockMask = modmasks[rs_numlock_mod - 1];
} }
#ifdef BACKGROUND_CYCLING_SUPPORT #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); rs_anim_delay = strtoul(rs_anim_pixmap_list, (char **) NULL, 0);
fflush(stdout); fflush(stdout);
if (rs_anim_delay == 0) { if (rs_anim_delay == 0) {
@ -3058,7 +3058,7 @@ post_parse(void)
for (i = 0; i < count; i++) { 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 */ 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; break;
if (spiftool_num_words(temp) != 3) { if (spiftool_num_words(temp) != 3) {
if (spiftool_num_words(temp) == 1) { if (spiftool_num_words(temp) == 1) {
@ -3194,7 +3194,7 @@ save_config(char *path, unsigned char save_theme)
link(path, bak_path); link(path, bak_path);
unlink(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)); libast_print_error("Unable to save configuration to file \"%s\" -- %s\n", path, strerror(errno));
return errno; return errno;
} }
@ -3286,7 +3286,7 @@ save_config(char *path, unsigned char save_theme)
fprintf(fp, "begin imageclasses\n"); fprintf(fp, "begin imageclasses\n");
fprintf(fp, " path \"%s\"\n", rs_path); fprintf(fp, " path \"%s\"\n", rs_path);
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
if (rs_icon != NULL) { if (rs_icon) {
fprintf(fp, " icon %s\n", rs_icon); fprintf(fp, " icon %s\n", rs_icon);
} }
if (rs_anim_delay) { if (rs_anim_delay) {

View File

@ -83,7 +83,7 @@
} while (0) } while (0)
#define CHECK_VALID_INDEX(i) (((i) >= image_bg) && ((i) < image_max)) #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_SET(var, field) ((var) |= (field))
#define BITFIELD_CLEAR(var, field) ((var) &= ~(field)) #define BITFIELD_CLEAR(var, field) ((var) &= ~(field))

View File

@ -263,7 +263,7 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap)
char *p, *opstr; char *p, *opstr;
int n; int n;
if (geom == NULL) if (!geom)
return 0; return 0;
D_PIXMAP(("scale_pixmap(\"%s\")\n", geom)); 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); xterm_seq(ESCSEQ_XTERM_TITLE, str);
return 0; return 0;
} }
if ((opstr = strchr(geom, ':')) != NULL) { if ((opstr = strchr(geom, ':'))) {
*opstr++ = '\0'; *opstr++ = '\0';
op = parse_pixmap_ops(opstr); op = parse_pixmap_ops(opstr);
} else { } else {
op = pmap->op; op = pmap->op;
} }
if ((p = strchr(geom, ';')) == NULL) if (!(p = strchr(geom, ';')))
p = strchr(geom, '\0'); p = strchr(geom, '\0');
n = (p - geom); n = (p - geom);
if (n > GEOM_LEN - 1) if (n > GEOM_LEN - 1)
@ -364,7 +364,7 @@ image_t *create_eterm_image(void)
void void
reset_eterm_image(image_t *img, unsigned long mask) reset_eterm_image(image_t *img, unsigned long mask)
{ {
ASSERT(img != NULL); ASSERT(!!img);
D_PIXMAP(("reset_image(%8p, 0x%08x)\n", img, mask)); D_PIXMAP(("reset_image(%8p, 0x%08x)\n", img, mask));
@ -443,7 +443,7 @@ void
reset_simage(simage_t *simg, unsigned long mask) reset_simage(simage_t *simg, unsigned long mask)
{ {
ASSERT(simg != NULL); ASSERT(!!simg);
D_PIXMAP(("reset_simage(%8p, 0x%08x)\n", simg, mask)); D_PIXMAP(("reset_simage(%8p, 0x%08x)\n", simg, mask));
@ -529,7 +529,7 @@ colormod_t *create_colormod(void)
void void
reset_colormod(colormod_t *cmod) reset_colormod(colormod_t *cmod)
{ {
ASSERT(cmod != NULL); ASSERT(!!cmod);
cmod->brightness = cmod->contrast = cmod->gamma = 0x100; cmod->brightness = cmod->contrast = cmod->gamma = 0x100;
if (cmod->imlib_mod) { if (cmod->imlib_mod) {
imlib_context_set_color_modifier(cmod->imlib_mod); imlib_context_set_color_modifier(cmod->imlib_mod);
@ -540,7 +540,7 @@ reset_colormod(colormod_t *cmod)
void void
free_colormod(colormod_t *cmod) free_colormod(colormod_t *cmod)
{ {
ASSERT(cmod != NULL); ASSERT(!!cmod);
if (cmod->imlib_mod) { if (cmod->imlib_mod) {
imlib_context_set_color_modifier(cmod->imlib_mod); imlib_context_set_color_modifier(cmod->imlib_mod);
imlib_free_color_modifier(); imlib_free_color_modifier();
@ -696,7 +696,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
&& need_colormod(simg->iml)) { && need_colormod(simg->iml)) {
colormod_trans(p, simg->iml, gc, width, height); 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, 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)); 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); bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
@ -800,7 +800,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
Pixmap pmap = None, mask = None; Pixmap pmap = None, mask = None;
GC gc; GC gc;
ASSERT(simg != NULL); ASSERT(!!simg);
D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), (int) win, D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), (int) win,
(int) d, x, y, w, h)); (int) d, x, y, w, h));
@ -872,7 +872,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
gc = LIBAST_X_CREATE_GC(0, NULL); gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, win, x, y, w, h); 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); bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up);
} }
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y); 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))) 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_image(simg->iml->im);
imlib_context_set_drawable(d); imlib_context_set_drawable(d);
imlib_context_set_anti_alias(1); imlib_context_set_anti_alias(1);
@ -1010,9 +1010,9 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
scr = ScreenOfDisplay(Xdisplay, Xscreen); scr = ScreenOfDisplay(Xdisplay, Xscreen);
if (!scr) if (!scr)
return; return;
ASSERT(simg != NULL); ASSERT(!!simg);
ASSERT(simg->iml != NULL); ASSERT(!!simg->iml);
ASSERT(simg->pmap != NULL); ASSERT(!!simg->pmap);
REQUIRE(win != None); REQUIRE(win != None);
D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), width, D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), width,
height, win)); height, win));
@ -1251,7 +1251,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else { } else {
shaped_window_apply_mask(win, simg->pmap->mask); 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); 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)); 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); copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height);
XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap);
} else { } else {
if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel != NULL)) { if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel)) {
if (simg->pmap->pixmap != None) { if (simg->pmap->pixmap != None) {
LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap); LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
} }
simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height); simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg))); XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); 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, DRAW_SOLID_BEVEL(simg->pmap->pixmap, width, height, simg->bg, simg->iml->bevel->up,
simg->iml->bevel->edges->left); 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))); D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno)));
} }
if ((p = strchr(file, '@')) == NULL) if (!(p = strchr(file, '@')))
p = strchr(file, '\0'); p = strchr(file, '\0');
len = (p - file); len = (p - file);
/* leave room for an extra '/' and trailing '\0' */ /* leave room for an extra '/' and trailing '\0' */
@ -1370,11 +1370,11 @@ search_path(const char *pathlist, const char *file)
} else { } else {
D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno))); 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; int n;
/* colon delimited */ /* colon delimited */
if ((p = strchr(path, ':')) == NULL) if (!(p = strchr(path, ':')))
p = strchr(path, '\0'); p = strchr(path, '\0');
n = (p - path); n = (p - path);
if (*p != '\0') if (*p != '\0')
@ -1429,24 +1429,24 @@ load_image(const char *file, simage_t *simg)
Imlib_Load_Error im_err; Imlib_Load_Error im_err;
char *geom; char *geom;
ASSERT_RVAL(file != NULL, 0); ASSERT_RVAL(!!file, 0);
ASSERT_RVAL(simg != NULL, 0); ASSERT_RVAL(!!simg, 0);
D_PIXMAP(("load_image(%s, %8p)\n", file, simg)); D_PIXMAP(("load_image(%s, %8p)\n", file, simg));
if (*file != '\0') { if (*file != '\0') {
if ((geom = strchr(file, '@')) != NULL) { if ((geom = strchr(file, '@'))) {
*geom++ = 0; *geom++ = 0;
} else if ((geom = strchr(file, ';')) != NULL) { } else if ((geom = strchr(file, ';'))) {
*geom++ = 0; *geom++ = 0;
} }
if (geom != NULL) { if (geom) {
set_pixmap_scale(geom, simg->pmap); 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); f = search_path(getenv(PATH_ENV), file);
} }
if (f != NULL) { if (f) {
im = imlib_load_image_with_error_return(f, &im_err); 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)); libast_print_error("Unable to load image file \"%s\" -- %s\n", file, imlib_strerror(im_err));
return 0; return 0;
} else { } else {
@ -1466,7 +1466,7 @@ load_image(const char *file, simage_t *simg)
void void
update_cmod(colormod_t *cmod) update_cmod(colormod_t *cmod)
{ {
ASSERT(cmod != NULL); ASSERT(!!cmod);
/* When a particular R/G/B color modifier is changed, this function must be called /* When a particular R/G/B color modifier is changed, this function must be called
to resync the Imlib2 color modifier (imlib_mod) with our new brightness, to resync the Imlib2 color modifier (imlib_mod) with our new brightness,
contrast, and gamma values. */ contrast, and gamma values. */
@ -1810,7 +1810,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
real_depth = Xdepth; real_depth = Xdepth;
} }
ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap); 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); libast_print_warning("XGetImage(Xdisplay, 0x%08x, 0, 0, %d, %d, -1, ZPixmap) returned NULL.\n", p, w, h);
return; return;
} }
@ -2170,14 +2170,14 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
imlib_context_set_color_modifier(tmp_cmod); imlib_context_set_color_modifier(tmp_cmod);
imlib_reset_color_modifier(); imlib_reset_color_modifier();
if (filename && *filename) { 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); icon_path = search_path(getenv(PATH_ENV), filename);
if (icon_path != NULL) { if (icon_path) {
XIconSize *icon_sizes; XIconSize *icon_sizes;
int count, i; int count, i;
temp_im = imlib_load_image_with_error_return(icon_path, &im_err); 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)); libast_print_error("Unable to load icon file \"%s\" -- %s\n", icon_path, imlib_strerror(im_err));
} else { } 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. */ /* 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; w = h = 48;
temp_im = imlib_create_image_using_data(48, 48, (DATA32 *) (icon_data + 2)); temp_im = imlib_create_image_using_data(48, 48, (DATA32 *) (icon_data + 2));
imlib_context_set_image(temp_im); imlib_context_set_image(temp_im);

View File

@ -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(); register unsigned int i = TERM_WINDOW_GET_REPORTED_COLS();
rend_t *r, fs = efs; rend_t *r, fs = efs;
if (tp[row] == NULL) { if (!tp[row]) {
tp[row] = MALLOC(sizeof(text_t) * (TERM_WINDOW_GET_REPORTED_COLS() + 1)); tp[row] = MALLOC(sizeof(text_t) * (TERM_WINDOW_GET_REPORTED_COLS() + 1));
rp[row] = MALLOC(sizeof(rend_t) * TERM_WINDOW_GET_REPORTED_COLS()); rp[row] = MALLOC(sizeof(rend_t) * TERM_WINDOW_GET_REPORTED_COLS());
} }
@ -264,7 +264,7 @@ scr_reset(void)
screen.row += k; screen.row += k;
TermWin.nscrolled -= k; TermWin.nscrolled -= k;
for (i = TermWin.saveLines - TermWin.nscrolled; k--; i--) { 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); blank_screen_mem(screen.text, screen.rend, i, DEFAULT_RSTYLE);
} }
} }
@ -455,7 +455,7 @@ scr_change_screen(int scrn)
if (current_screen == PRIMARY) { if (current_screen == PRIMARY) {
scroll_text(0, (TERM_WINDOW_GET_REPORTED_ROWS() - 1), TERM_WINDOW_GET_REPORTED_ROWS(), 0); 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++) 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); 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++) { for (i = 0, j = row1; i < count; i++, j++) {
buf_text[i] = screen.text[j]; buf_text[i] = screen.text[j];
buf_rend[i] = screen.rend[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 /* A new ALLOC is done with size ncol and
blankline with size prev_ncol -- Sebastien van K */ blankline with size prev_ncol -- Sebastien van K */
buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1)); 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--) { for (i = 0, j = row2; i < count; i++, j--) {
buf_text[i] = screen.text[j]; buf_text[i] = screen.text[j];
buf_rend[i] = screen.rend[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 /* A new ALLOC is done with size ncol and
blankline with size prev_ncol -- Sebastien van K */ blankline with size prev_ncol -- Sebastien van K */
buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1)); 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); BOUND(screen.row, -TermWin.nscrolled, TERM_WINDOW_GET_REPORTED_ROWS() - 1);
row = screen.row + TermWin.saveLines; row = screen.row + TermWin.saveLines;
if (screen.text[row] == NULL) { if (!screen.text[row]) {
blank_screen_mem(screen.text, screen.rend, row, DEFAULT_RSTYLE); blank_screen_mem(screen.text, screen.rend, row, DEFAULT_RSTYLE);
} /* avoid segfault -- added by Sebastien van K */ } /* avoid segfault -- added by Sebastien van K */
beg.row = screen.row; beg.row = screen.row;
@ -1492,7 +1492,7 @@ scr_expose(int x, int y, int width, int height)
register short nc, nr; register short nc, nr;
row_col_t rect_beg, rect_end; row_col_t rect_beg, rect_end;
REQUIRE(drawn_text != NULL); REQUIRE(!!drawn_text);
nc = TERM_WINDOW_GET_REPORTED_COLS() - 1; nc = TERM_WINDOW_GET_REPORTED_COLS() - 1;
nr = TERM_WINDOW_GET_ROWS() - 1; nr = TERM_WINDOW_GET_ROWS() - 1;
@ -1581,7 +1581,7 @@ scr_printscreen(int fullhist)
text_t *t; text_t *t;
FILE *fd; FILE *fd;
if ((fd = popen_printer()) == NULL) if (!(fd = popen_printer()))
return; return;
nrows = TERM_WINDOW_GET_REPORTED_ROWS(); nrows = TERM_WINDOW_GET_REPORTED_ROWS();
if (fullhist) { if (fullhist) {
@ -1945,7 +1945,7 @@ scr_refresh(int type)
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
} }
#ifndef NO_BOLDFONT #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); XSetFont(Xdisplay, TermWin.gc, TermWin.boldFont->fid);
bfont = 1; bfont = 1;
} else if (bfont) { } else if (bfont) {
@ -2256,8 +2256,8 @@ scr_search_scrollback(char *str)
unsigned int *i; unsigned int *i;
unsigned long row, lrow, col, rows, cols, len, k; unsigned long row, lrow, col, rows, cols, len, k;
if (str == NULL) { if (!str) {
if ((str = last_str) == NULL) { if (!(str = last_str)) {
return; return;
} }
} else { } else {
@ -2361,7 +2361,7 @@ scr_dump_to_file(const char *fname)
unsigned long row, col, rows, cols; unsigned long row, col, rows, cols;
struct stat st; struct stat st;
REQUIRE(fname != NULL); REQUIRE(!!fname);
rows = TERM_WINDOW_GET_REPORTED_ROWS() + TermWin.saveLines; rows = TERM_WINDOW_GET_REPORTED_ROWS() + TermWin.saveLines;
cols = TERM_WINDOW_GET_REPORTED_COLS(); cols = TERM_WINDOW_GET_REPORTED_COLS();
@ -2498,9 +2498,9 @@ selection_fetch(Window win, unsigned prop, int delete)
if ((XGetWindowProperty if ((XGetWindowProperty
(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems, (Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems,
&bytes_after, &data) != Success) &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)); 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); XFree(data);
} }
return; return;
@ -2557,7 +2557,7 @@ void
selection_copy_string(Atom sel, char *str, size_t len) 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)); 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; return;
} }
if (IS_SELECTION(sel)) { if (IS_SELECTION(sel)) {
@ -2584,7 +2584,7 @@ void
selection_paste(Atom sel) selection_paste(Atom sel)
{ {
D_SELECT(("Attempting to paste selection %d.\n", (int) 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. */ /* If we have a selection of our own, paste it. */
D_SELECT(("Pasting my current selection of length %lu\n", selection.len)); D_SELECT(("Pasting my current selection of length %lu\n", selection.len));
selection_write(selection.text, 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 */ /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
#ifdef CUTCHAR_OPTION #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 #else
# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)) != NULL) # define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)))
#endif #endif
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
#define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) #define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0)
@ -3351,7 +3351,7 @@ selection_send(XSelectionRequestEvent * rq)
xtextp.value = NULL; xtextp.value = NULL;
xtextp.nitems = 0; xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XUTF8StringStyle, &xtextp) == Success) { 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, XChangeProperty(Xdisplay, rq->requestor, rq->property,
rq->target, 8, PropModeReplace, xtextp.value, xtextp.nitems); rq->target, 8, PropModeReplace, xtextp.value, xtextp.nitems);
ev.xselection.property = rq->property; ev.xselection.property = rq->property;
@ -3367,7 +3367,7 @@ selection_send(XSelectionRequestEvent * rq)
xtextp.value = NULL; xtextp.value = NULL;
xtextp.nitems = 0; xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) { 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], XChangeProperty(Xdisplay, rq->requestor, rq->property, props[PROP_COMPOUND_TEXT],
8, PropModeReplace, xtextp.value, xtextp.nitems); 8, PropModeReplace, xtextp.value, xtextp.nitems);
ev.xselection.property = rq->property; ev.xselection.property = rq->property;

View File

@ -82,7 +82,7 @@ eterm_handle_winop(char *action)
char *winid; char *winid;
Window win = 0; Window win = 0;
ASSERT(action != NULL); ASSERT(!!action);
winid = strchr(action, ' '); winid = strchr(action, ' ');
if (winid) { if (winid) {
@ -160,7 +160,7 @@ script_handler_copy(spif_charptr_t *params)
Atom sel = XA_PRIMARY; Atom sel = XA_PRIMARY;
if (params) { 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) {
if (*buffer_id >= '0' && *buffer_id <= '7') { if (*buffer_id >= '0' && *buffer_id <= '7') {
sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0')); 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; Atom sel = XA_PRIMARY;
if (params) { 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) {
if (*buffer_id >= '0' && *buffer_id <= '7') { if (*buffer_id >= '0' && *buffer_id <= '7') {
sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0')); 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; static char *search = NULL;
if (params && *params) { if (params && *params) {
if (search != NULL) { if (search) {
FREE(search); FREE(search);
} }
search = STRDUP(*params); search = STRDUP(*params);
@ -735,12 +735,12 @@ script_parse(char *s)
size_t len; size_t len;
eterm_script_handler_t *func; eterm_script_handler_t *func;
REQUIRE(s != NULL); REQUIRE(!!s);
D_SCRIPT(("Parsing: \"%s\"\n", s)); D_SCRIPT(("Parsing: \"%s\"\n", s));
token_list = spiftool_split(";", s); token_list = spiftool_split(";", s);
if (token_list == NULL) { if (!token_list) {
D_SCRIPT(("No tokens found; ignoring script.\n")); D_SCRIPT(("No tokens found; ignoring script.\n"));
return; return;
} }
@ -751,7 +751,7 @@ script_parse(char *s)
if (!(*pstr)) { if (!(*pstr)) {
continue; continue;
} }
if ((params = strchr(pstr, '(')) != NULL) { if ((params = strchr(pstr, '('))) {
if (params != pstr) { if (params != pstr) {
len = params - pstr; len = params - pstr;
func_name = (char *) MALLOC(len + 1); func_name = (char *) MALLOC(len + 1);
@ -771,7 +771,7 @@ script_parse(char *s)
} }
if (params) { if (params) {
params++; params++;
if ((tmp = strrchr(params, ')')) != NULL) { if ((tmp = strrchr(params, ')'))) {
*tmp = 0; *tmp = 0;
} else { } else {
libast_print_error("Error in script \"%s\": Missing closing parentheses for \"%s\".\n", s, token_list[i]); 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; param_list = NULL;
} }
D_SCRIPT(("Calling function %s with parameters: %s\n", func_name, NONULL(params))); 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); (func->handler) (param_list);
} else { } else {
libast_print_error("Error in script \"%s\": No such function \"%s\".\n", s, func_name); libast_print_error("Error in script \"%s\": No such function \"%s\".\n", s, func_name);

View File

@ -357,7 +357,7 @@ sb_handle_motion_notify(event_t *ev)
unsigned char unsigned char
scrollbar_dispatch_event(event_t *ev) 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 ((scrollbar_event_data.handlers[ev->type]) (ev));
} }
return (0); return (0);

View File

@ -95,7 +95,7 @@ eterm_bootstrap(int argc, char *argv[])
init_libast(); init_libast();
/* Open display, get options/resources and create the window */ /* Open display, get options/resources and create the window */
if (getenv("DISPLAY") != NULL) { if (getenv("DISPLAY")) {
display_name = STRDUP(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] = XInternAtom(Xdisplay, "_NET_WM_STATE", False);
props[PROP_EWMH_STATE_STICKY] = XInternAtom(Xdisplay, "_NET_WM_STATE_STICKY", 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; char *tmp;
D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", theme_dir)); 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); sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir);
putenv(tmp); putenv(tmp);
} }
if ((user_dir = if ((user_dir = spifconf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME)))) {
spifconf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG),
(PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) {
char *tmp; char *tmp;
D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", user_dir)); D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", user_dir));
@ -268,7 +266,7 @@ eterm_bootstrap(int argc, char *argv[])
#endif #endif
val = XDisplayString(Xdisplay); val = XDisplayString(Xdisplay);
if (display_name == NULL) { if (!display_name) {
display_name = val; display_name = val;
} }
@ -292,7 +290,7 @@ eterm_bootstrap(int argc, char *argv[])
putenv("COLORTERM_BCE=" COLORTERMENV "-mono"); putenv("COLORTERM_BCE=" COLORTERMENV "-mono");
putenv("TERM=" TERMENV); putenv("TERM=" TERMENV);
} else { } else {
if (rs_term_name != NULL) { if (rs_term_name) {
i = strlen(rs_term_name); i = strlen(rs_term_name);
term_string = MALLOC(i + 6); term_string = MALLOC(i + 6);

View File

@ -473,7 +473,7 @@ lookup_key(XEvent * ev)
PrivMode((!numlock_state), PrivMode_aplKP); PrivMode((!numlock_state), PrivMode_aplKP);
} }
#ifdef USE_XIM #ifdef USE_XIM
if (xim_input_context != NULL) { if (xim_input_context) {
Status status_return; Status status_return;
kbuf[0] = '\0'; kbuf[0] = '\0';
@ -680,7 +680,7 @@ lookup_key(XEvent * ev)
if (keysym >= 0xff00 && keysym <= 0xffff) { if (keysym >= 0xff00 && keysym <= 0xffff) {
#ifdef KEYSYM_ATTRIBUTE #ifdef KEYSYM_ATTRIBUTE
/* The "keysym" attribute in the config file gets handled here. */ /* 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; const unsigned char *tmpbuf;
unsigned int len; unsigned int len;
@ -1080,7 +1080,7 @@ popen_printer(void)
libast_print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n"); libast_print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n");
RESET_AND_ASSIGN(rs_print_pipe, STRDUP(PRINTPIPE)); 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)); libast_print_error("Can't open printer pipe \"%s\" -- %s\n", rs_print_pipe, strerror(errno));
} }
return stream; return stream;
@ -1102,7 +1102,7 @@ process_print_pipe(void)
int index; int index;
FILE *fd; FILE *fd;
if ((fd = popen_printer()) != NULL) { if ((fd = popen_printer())) {
for (index = 0; index < 4; /* nil */ ) { for (index = 0; index < 4; /* nil */ ) {
unsigned char ch = cmd_getc(); unsigned char ch = cmd_getc();
@ -2078,10 +2078,10 @@ append_to_title(const char *str)
{ {
char *name, *buff; char *name, *buff;
REQUIRE(str != NULL); REQUIRE(!!str);
XFetchName(Xdisplay, TermWin.parent, &name); XFetchName(Xdisplay, TermWin.parent, &name);
if (name != NULL) { if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1); buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name); strcpy(buff, name);
strcat(buff, str); strcat(buff, str);
@ -2095,10 +2095,10 @@ append_to_icon_name(const char *str)
{ {
char *name, *buff; char *name, *buff;
REQUIRE(str != NULL); REQUIRE(!!str);
XGetIconName(Xdisplay, TermWin.parent, &name); XGetIconName(Xdisplay, TermWin.parent, &name);
if (name != NULL) { if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1); buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name); strcpy(buff, name);
strcat(buff, str); strcat(buff, str);
@ -2158,19 +2158,19 @@ xterm_seq(int op, const char *str)
set_title(str); set_title(str);
break; break;
case ESCSEQ_XTERM_PROP: /* 3 */ case ESCSEQ_XTERM_PROP: /* 3 */
if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) { if (!(nstr = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
if ((valptr = strchr(nstr, '=')) != NULL) { if ((valptr = strchr(nstr, '='))) {
*(valptr++) = 0; *(valptr++) = 0;
} }
set_text_property(TermWin.parent, nstr, valptr); set_text_property(TermWin.parent, nstr, valptr);
break; break;
case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */ 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); i = (unsigned int) strtoul(nstr, (char **) NULL, 0);
nstr = (char *) strsep(&tnstr, ";"); nstr = (char *) strsep(&tnstr, ";");
if ((i < 256) && (nstr != NULL)) { if ((i < 256) && (nstr)) {
D_COLORS(("Changing color : [%d] -> %s\n", i, nstr)); D_COLORS(("Changing color : [%d] -> %s\n", i, nstr));
set_window_color(i, nstr); set_window_color(i, nstr);
} }
@ -2256,7 +2256,7 @@ xterm_seq(int op, const char *str)
case 1: case 1:
changed = 0; changed = 0;
for (; 1;) { for (; 1;) {
if ((color = (char *) strsep(&tnstr, ";")) == NULL) { if (!(color = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
which = image_max; which = image_max;
@ -2264,13 +2264,13 @@ xterm_seq(int op, const char *str)
which = idx; break;} which = idx; break;}
); );
if (which != image_max) { if (which != image_max) {
if ((color = (char *) strsep(&tnstr, ";")) == NULL) { if (!(color = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
} else { } else {
which = image_bg; which = image_bg;
} }
if ((mod = (char *) strsep(&tnstr, ";")) == NULL) { if (!(mod = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
if (!strcasecmp(mod, "clear")) { if (!strcasecmp(mod, "clear")) {
@ -2297,7 +2297,7 @@ xterm_seq(int op, const char *str)
changed = 1; changed = 1;
continue; continue;
} }
if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", 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")) { if (!strcasecmp(color, "image")) {
imlib_t *iml = images[which].current->iml; imlib_t *iml = images[which].current->iml;
if (iml->mod == NULL) { if (!iml->mod) {
iml->mod = create_colormod(); iml->mod = create_colormod();
} }
if (!BEG_STRCASECMP(mod, "brightness")) { if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2331,7 +2331,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "red")) { } else if (!strcasecmp(color, "red")) {
imlib_t *iml = images[which].current->iml; imlib_t *iml = images[which].current->iml;
if (iml->rmod == NULL) { if (!iml->rmod) {
iml->rmod = create_colormod(); iml->rmod = create_colormod();
} }
if (!BEG_STRCASECMP(mod, "brightness")) { if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2348,7 +2348,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "green")) { } else if (!strcasecmp(color, "green")) {
imlib_t *iml = images[which].current->iml; imlib_t *iml = images[which].current->iml;
if (iml->gmod == NULL) { if (!iml->gmod) {
iml->gmod = create_colormod(); iml->gmod = create_colormod();
} }
if (!BEG_STRCASECMP(mod, "brightness")) { if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2365,7 +2365,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "blue")) { } else if (!strcasecmp(color, "blue")) {
imlib_t *iml = images[which].current->iml; imlib_t *iml = images[which].current->iml;
if (iml->bmod == NULL) { if (!iml->bmod) {
iml->bmod = create_colormod(); iml->bmod = create_colormod();
} }
if (!BEG_STRCASECMP(mod, "bright")) { if (!BEG_STRCASECMP(mod, "bright")) {
@ -2387,14 +2387,14 @@ xterm_seq(int op, const char *str)
case 2: case 2:
changed = 0; changed = 0;
which = image_max; which = image_max;
if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) { if (!(nstr = (char *)strsep(&tnstr, ";")) || !(valptr = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) { FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) {
which = idx; break;} which = idx; break;}
); );
if (which != image_max) { if (which != image_max) {
if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break; break;
} }
} else { } else {
@ -2408,7 +2408,7 @@ xterm_seq(int op, const char *str)
s = (int) strtol(valptr, (char **) NULL, 0); s = (int) strtol(valptr, (char **) NULL, 0);
s = ((100 - s) << 8) / 100; s = ((100 - s) << 8) / 100;
if (s == 0x100) { if (s == 0x100) {
if (iml->mod != NULL) { if (iml->mod) {
if (iml->mod->brightness != 0x100) { if (iml->mod->brightness != 0x100) {
iml->mod->brightness = 0x100; iml->mod->brightness = 0x100;
changed = 1; changed = 1;
@ -2418,7 +2418,7 @@ xterm_seq(int op, const char *str)
} }
} }
} else { } else {
if (iml->mod == NULL) { if (!iml->mod) {
iml->mod = create_colormod(); iml->mod = create_colormod();
} }
if (iml->mod->brightness != s) { if (iml->mod->brightness != s) {
@ -2438,7 +2438,7 @@ xterm_seq(int op, const char *str)
} }
r = (t & 0xff0000) >> 16; r = (t & 0xff0000) >> 16;
if (r == 0xff) { if (r == 0xff) {
if (iml->rmod != NULL) { if (iml->rmod) {
if (iml->rmod->brightness != 0x100) { if (iml->rmod->brightness != 0x100) {
iml->rmod->brightness = 0x100; iml->rmod->brightness = 0x100;
changed = 1; changed = 1;
@ -2448,7 +2448,7 @@ xterm_seq(int op, const char *str)
} }
} }
} else { } else {
if (iml->rmod == NULL) { if (!iml->rmod) {
iml->rmod = create_colormod(); iml->rmod = create_colormod();
} }
if (iml->rmod->brightness != (int) r) { if (iml->rmod->brightness != (int) r) {
@ -2458,7 +2458,7 @@ xterm_seq(int op, const char *str)
} }
g = (t & 0xff00) >> 8; g = (t & 0xff00) >> 8;
if (g == 0xff) { if (g == 0xff) {
if (iml->gmod != NULL) { if (iml->gmod) {
if (iml->gmod->brightness != 0x100) { if (iml->gmod->brightness != 0x100) {
iml->gmod->brightness = 0x100; iml->gmod->brightness = 0x100;
changed = 1; changed = 1;
@ -2468,7 +2468,7 @@ xterm_seq(int op, const char *str)
} }
} }
} else { } else {
if (iml->gmod == NULL) { if (!iml->gmod) {
iml->gmod = create_colormod(); iml->gmod = create_colormod();
} }
if (iml->gmod->brightness != (int) g) { if (iml->gmod->brightness != (int) g) {
@ -2478,7 +2478,7 @@ xterm_seq(int op, const char *str)
} }
b = t & 0xff; b = t & 0xff;
if (b == 0xff) { if (b == 0xff) {
if (iml->bmod != NULL) { if (iml->bmod) {
if (iml->bmod->brightness != 0x100) { if (iml->bmod->brightness != 0x100) {
iml->bmod->brightness = 0x100; iml->bmod->brightness = 0x100;
changed = 1; changed = 1;
@ -2488,7 +2488,7 @@ xterm_seq(int op, const char *str)
} }
} }
} else { } else {
if (iml->bmod == NULL) { if (!iml->bmod) {
iml->bmod = create_colormod(); iml->bmod = create_colormod();
iml->bmod->contrast = iml->bmod->gamma = 0x100; iml->bmod->contrast = iml->bmod->gamma = 0x100;
} }
@ -2709,54 +2709,54 @@ xterm_seq(int op, const char *str)
#ifdef XTERM_COLOR_CHANGE #ifdef XTERM_COLOR_CHANGE
case ESCSEQ_XTERM_FGCOLOR: /* 10 */ case ESCSEQ_XTERM_FGCOLOR: /* 10 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(fgColor, nstr); set_window_color(fgColor, nstr);
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_BGCOLOR: /* 11 */ case ESCSEQ_XTERM_BGCOLOR: /* 11 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(bgColor, nstr); set_window_color(bgColor, nstr);
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */ case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
# ifndef NO_CURSORCOLOR # ifndef NO_CURSORCOLOR
set_window_color(cursorColor, nstr); set_window_color(cursorColor, nstr);
# endif # endif
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */ case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_pointer_colors(nstr, NULL); set_pointer_colors(nstr, NULL);
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */ case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */ /* UNSUPPORTED */
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */ case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */ /* UNSUPPORTED */
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */ case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */ /* UNSUPPORTED */
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */ case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */ /* UNSUPPORTED */
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */ case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorBD, nstr); set_window_color(colorBD, nstr);
} }
/* drop */ /* drop */
case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */ case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorUL, nstr); set_window_color(colorUL, nstr);
} }
#endif #endif

View File

@ -181,7 +181,7 @@ remove_utmp_entry(void)
setutent(); setutent();
strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id)); strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
utmp.ut_type = USER_PROCESS; utmp.ut_type = USER_PROCESS;
if (getutid(&utmp) == NULL) { if (!getutid(&utmp)) {
return; return;
} }
utmp.ut_type = DEAD_PROCESS; 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. * The following code waw copied from the poeigl-1.20 login/init package.
* Special thanks to poe for the code examples. * Special thanks to poe for the code examples.
*/ */
while ((putmp = getutent()) != NULL) { while ((putmp = getutent())) {
if (putmp->ut_pid == pid) { if (putmp->ut_pid == pid) {
putmp->ut_type = DEAD_PROCESS; putmp->ut_type = DEAD_PROCESS;
putmp->ut_pid = 0; putmp->ut_pid = 0;
@ -286,10 +286,10 @@ get_tslot(const char *ttyname)
char buf[256], name[256]; char buf[256], name[256];
FILE *fd; FILE *fd;
if ((fd = fopen(UTMP_FILENAME, "r")) != NULL) { if ((fd = fopen(UTMP_FILENAME, "r"))) {
int i; 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) if (*buf == '#' || sscanf(buf, "%s", name) != 1)
continue; continue;
if (!strcmp(ttyname, name)) { if (!strcmp(ttyname, name)) {
@ -313,7 +313,7 @@ write_utmp(struct utmp *putmp)
fprintf(stderr, "Utmp file is %s\n", UTMP_FILENAME); fprintf(stderr, "Utmp file is %s\n", UTMP_FILENAME);
privileges(INVOKE); 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); utmp_pos = get_tslot(putmp->ut_line) * sizeof(struct utmp);
if (utmp_pos >= 0) { if (utmp_pos >= 0) {
@ -384,7 +384,7 @@ remove_utmp_entry(void)
FILE *fd; FILE *fd;
privileges(INVOKE); privileges(INVOKE);
if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+")) != NULL) { if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+"))) {
struct utmp utmp; struct utmp utmp;
MEMSET(&utmp, 0, sizeof(struct utmp)); MEMSET(&utmp, 0, sizeof(struct utmp));

View File

@ -67,9 +67,9 @@ set_text_property(Window win, char *propname, char *value)
XTextProperty prop; XTextProperty prop;
Atom atom; Atom atom;
ASSERT(propname != NULL); ASSERT(!!propname);
if (value == NULL) { if (!value) {
atom = XInternAtom(Xdisplay, propname, True); atom = XInternAtom(Xdisplay, propname, True);
if (atom == None) { if (atom == None) {
return; return;
@ -189,8 +189,8 @@ get_color_by_name(const char *name, const char *fallback)
{ {
XColor xcol; XColor xcol;
if (name == NULL) { if (!name) {
if (fallback == NULL) { if (!fallback) {
return ((Pixel) - 1); return ((Pixel) - 1);
} else { } else {
name = fallback; name = fallback;
@ -348,13 +348,13 @@ set_pointer_colors(const char *fg_name, const char *bg_name)
{ {
XColor fg, bg; XColor fg, bg;
if (fg_name != NULL) { if (fg_name) {
fg.pixel = get_color_by_name(fg_name, COLOR_NAME(pointerColor)); fg.pixel = get_color_by_name(fg_name, COLOR_NAME(pointerColor));
} else { } else {
fg.pixel = PixColors[pointerColor]; fg.pixel = PixColors[pointerColor];
} }
XQueryColor(Xdisplay, cmap, &fg); XQueryColor(Xdisplay, cmap, &fg);
if (bg_name != NULL) { if (bg_name) {
bg.pixel = get_color_by_name(bg_name, COLOR_NAME(bgColor)); bg.pixel = get_color_by_name(bg_name, COLOR_NAME(bgColor));
} else { } else {
bg.pixel = PixColors[bgColor]; 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))); D_X11(("idx == %d, color == \"%s\"\n", idx, NONULL(color)));
if (color == NULL || *color == '\0') if (!color || *color == '\0')
return; return;
/* handle color aliases */ /* handle color aliases */

View File

@ -181,7 +181,7 @@ main(int argc, char *argv[])
imlib_context_set_display(Xdisplay); imlib_context_set_display(Xdisplay);
imlib_context_set_visual(DefaultVisual(Xdisplay, DefaultScreen(Xdisplay))); imlib_context_set_visual(DefaultVisual(Xdisplay, DefaultScreen(Xdisplay)));
im = imlib_load_image_immediately(fname); im = imlib_load_image_immediately(fname);
if (im == NULL) { if (!im) {
fprintf(stderr, "%s: Unable to load image file \"%s\".\n", *argv, fname); fprintf(stderr, "%s: Unable to load image file \"%s\".\n", *argv, fname);
exit(1); exit(1);
} else if (debug) { } else if (debug) {