/* Find last '/'. */
last_slash = xmemrchr((uchar *)buf, '/', strlen(buf));
- if (last_slash != NULL && last_slash != buf && last_slash[1] == '\0') {
+ if (last_slash && last_slash != buf && last_slash[1] == '\0') {
/* Determine whether all remaining characters are slashes. */
for (runp = last_slash; runp != buf; --runp)
if (runp[-1] != '/')
last_slash = xmemrchr((uchar *)buf, '/', runp - buf);
}
- if (last_slash != NULL) {
+ if (last_slash) {
/* Determine whether all remaining characters are slashes. */
for (runp = last_slash; runp != buf; --runp)
if (runp[-1] != '/')
} else if (!initscr()) {
char *term = getenv("TERM");
- if (term != NULL)
+ if (term)
fprintf(stderr, "error opening TERM: %s\n", term);
else
fprintf(stderr, "initscr!\n");
{
DIR *dirp = opendir(path);
- if (dirp == NULL) {
+ if (!dirp) {
printwarn();
return FALSE;
}
DPRINTF_S(g_buf);
fp = popen(g_buf, "r");
- if (fp != NULL) {
- while (fgets(g_buf, CMD_LEN_MAX - 1, fp) != NULL)
+ if (fp) {
+ while (fgets(g_buf, CMD_LEN_MAX - 1, fp))
dprintf(fd, "%s", g_buf);
pclose(fp);
}
DIR *dirp = opendir(path);
static uint open_max;
- if (dirp == NULL)
+ if (!dirp)
return 0;
int fd = dirfd(dirp);
open_max = max_openfds();
}
- while ((dp = readdir(dirp)) != NULL) {
+ while ((dp = readdir(dirp))) {
namep = dp->d_name;
/* Skip self and parent */
if (n == total_dents) {
total_dents += ENTRY_INCR;
*dents = xrealloc(*dents, total_dents * sizeof(**dents));
- if (*dents == NULL) {
+ if (!*dents) {
free(pnamebuf);
closedir(dirp);
errexit();
pnb = pnamebuf;
pnamebuf = (char *)xrealloc(pnamebuf, namebuflen);
- if (pnamebuf == NULL) {
+ if (!pnamebuf) {
free(*dents);
closedir(dirp);
errexit();
goto begin;
}
- if (get_bm_loc(newpath, fd) == NULL) {
+ if (!get_bm_loc(newpath, fd)) {
printwait(messages[STR_INVBM_KEY], &presel);
goto nochange;
}
break;
}
- if (tmp == NULL || tmp[0] == '\0')
+ if (!tmp || !*tmp)
break;
/* Allow only relative, same dir paths */
}
if (ipath) { /* Open a bookmark directly */
- if (ipath[1] || get_bm_loc(cwd, *ipath) == NULL) {
+ if (ipath[1] || !get_bm_loc(cwd, *ipath)) {
fprintf(stderr, "%s\n", messages[STR_INVBM_KEY]);
return 1;
}
} else if (argc == optind) {
/* Start in the current directory */
ipath = getcwd(cwd, PATH_MAX);
- if (ipath == NULL)
+ if (!ipath)
ipath = "/";
} else {
ipath = realpath(argv[optind], cwd);
g_tmpfplen = xstrlcpy(g_tmpfpath, "/tmp", HOME_LEN_MAX);
else {
copier = getenv("TMPDIR");
- if (copier != NULL)
+ if (copier)
g_tmpfplen = xstrlcpy(g_tmpfpath, copier, HOME_LEN_MAX);
}