sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 1436518f9dad063bbfb8dc5595b9c744d025557c
parent 9b38355ae80e21afd156b5ddbdcea74c15011603
Author: FRIGN <dev@frign.de>
Date:   Wed Nov 19 20:59:37 +0100

Use < 0 instead of == -1

Diffstat:
chgrp.c | 4++--
chmod.c | 4++--
chown.c | 2+-
chroot.c | 4++--
libutil/apathmax.c | 2+-
libutil/cp.c | 4++--
libutil/fnck.c | 10+++++-----
libutil/recurse.c | 2+-
libutil/rm.c | 2+-
ls.c | 8++++----
mkdir.c | 4++--
mkfifo.c | 2+-
nohup.c | 6+++---
pwd.c | 4++--
renice.c | 2+-
rmdir.c | 2+-
sort.c | 4++--
split.c | 2+-
touch.c | 4++--
unlink.c | 2+-
xargs.c | 8++++----
21 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/chgrp.c b/chgrp.c @@ -24,7 +24,7 @@ usage(void) static void chgrp(const char *path) { - if (chown(path, st.st_uid, gid) == -1) { + if (chown(path, st.st_uid, gid) < 0) { weprintf("chown %s:", path); failures++; } @@ -57,7 +57,7 @@ main(int argc, char *argv[]) gid = gr->gr_gid; while (*++argv) { - if (stat(*argv, &st) == -1) { + if (stat(*argv, &st) < 0) { weprintf("stat %s:", *argv); failures++; continue; diff --git a/chmod.c b/chmod.c @@ -65,14 +65,14 @@ chmodr(const char *path) struct stat st; mode_t m; - if (stat(path, &st) == -1) { + if (stat(path, &st) < 0) { weprintf("stat %s:", path); ret = 1; return; } m = parsemode(modestr, st.st_mode, mask); - if (chmod(path, m) == -1) { + if (chmod(path, m) < 0) { weprintf("chmod %s:", path); ret = 1; } diff --git a/chown.c b/chown.c @@ -81,7 +81,7 @@ main(int argc, char *argv[]) void chownpwgr(const char *path) { - if (chown(path, uid, gid) == -1) { + if (chown(path, uid, gid) < 0) { weprintf("chown %s:", path); ret = 1; } diff --git a/chroot.c b/chroot.c @@ -28,10 +28,10 @@ main(int argc, char *argv[]) if ((aux = getenv("SHELL"))) shell[0] = aux; - if (chroot(argv[0]) == -1) + if (chroot(argv[0]) < 0) eprintf("chroot %s:", argv[0]); - if (chdir("/") == -1) + if (chdir("/") < 0) eprintf("chdir:"); if (argc == 1) { diff --git a/libutil/apathmax.c b/libutil/apathmax.c @@ -11,7 +11,7 @@ apathmax(char **p, long *size) { errno = 0; - if ((*size = pathconf("/", _PC_PATH_MAX)) == -1) { + if ((*size = pathconf("/", _PC_PATH_MAX)) < 0) { if (errno == 0) { *size = BUFSIZ; } else { diff --git a/libutil/cp.c b/libutil/cp.c @@ -66,7 +66,7 @@ cp(const char *s1, const char *s2) if (!(dp = opendir(s1))) eprintf("opendir %s:", s1); - if (mkdir(s2, st.st_mode) == -1 && errno != EEXIST) + if (mkdir(s2, st.st_mode) < 0 && errno != EEXIST) eprintf("mkdir %s:", s2); apathmax(&ns1, &size1); @@ -144,7 +144,7 @@ preserve: r = lchown(s2, st.st_uid, st.st_gid); else r = chown(s2, st.st_uid, st.st_gid); - if (r == -1) { + if (r < 0) { weprintf("cp: can't preserve ownership of '%s':", s2); cp_status = 1; } diff --git a/libutil/fnck.c b/libutil/fnck.c @@ -8,13 +8,13 @@ fnck(const char *a, const char *b, int (*fn)(const char *, const char *)) { struct stat sta, stb; - if (stat(a, &sta) == 0 - && stat(b, &stb) == 0 - && sta.st_dev == stb.st_dev - && sta.st_ino == stb.st_ino) { + if (!stat(a, &sta) + && !stat(b, &stb) + && sta.st_dev == stb.st_dev + && sta.st_ino == stb.st_ino) { eprintf("%s -> %s: same file\n", a, b); } - if (fn(a, b) == -1) + if (fn(a, b) < 0) eprintf("%s -> %s:", a, b); } diff --git a/libutil/recurse.c b/libutil/recurse.c @@ -18,7 +18,7 @@ recurse(const char *path, void (*fn)(const char *)) struct stat st; DIR *dp; - if (lstat(path, &st) == -1 || S_ISDIR(st.st_mode) == 0) + if (lstat(path, &st) < 0 || !S_ISDIR(st.st_mode)) return; if (!(dp = opendir(path))) diff --git a/libutil/rm.c b/libutil/rm.c @@ -12,6 +12,6 @@ rm(const char *path) { if (rm_rflag) recurse(path, rm); - if (remove(path) == -1 && !rm_fflag) + if (remove(path) < 0 && !rm_fflag) eprintf("remove %s:", path); } diff --git a/ls.c b/ls.c @@ -137,7 +137,7 @@ lsdir(const char *path) cwd = agetcwd(); if (!(dp = opendir(path))) eprintf("opendir %s:", path); - if (chdir(path) == -1) + if (chdir(path) < 0) eprintf("chdir %s:", path); if (many) { @@ -168,7 +168,7 @@ lsdir(const char *path) free(ents[rflag ? n-i-1 : i].name); } } - if (chdir(cwd) == -1) + if (chdir(cwd) < 0) eprintf("chdir %s:", cwd); free(ents); free(cwd); @@ -182,7 +182,7 @@ mkent(Entry *ent, char *path, int dostat) ent->name = path; if (!dostat) return; - if (lstat(path, &st) == -1) + if (lstat(path, &st) < 0) eprintf("lstat %s:", path); ent->mode = st.st_mode; ent->nlink = st.st_nlink; @@ -291,7 +291,7 @@ output(Entry *ent) printf("%10lu ", (unsigned long)ent->size); printf("%s %s%s", buf, ent->name, indicator(ent->mode)); if (S_ISLNK(ent->mode)) { - if ((len = readlink(ent->name, buf, sizeof buf)) == -1) + if ((len = readlink(ent->name, buf, sizeof buf)) < 0) eprintf("readlink %s:", ent->name); buf[len] = '\0'; mkent(&entlnk, buf, Fflag); diff --git a/mkdir.c b/mkdir.c @@ -41,7 +41,7 @@ main(int argc, char *argv[]) for (; argc > 0; argc--, argv++) { if (pflag) { mkdirp(argv[0]); - } else if (mkdir(argv[0], S_IRWXU|S_IRWXG|S_IRWXO) == -1) { + } else if (mkdir(argv[0], S_IRWXU|S_IRWXG|S_IRWXO) < 0) { eprintf("mkdir %s:", argv[0]); } if (mflag) @@ -60,7 +60,7 @@ mkdirp(char *path) do { if (*p && (p = strchr(&p[1], '/'))) *p = '\0'; - if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) == -1 && errno != EEXIST) + if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) < 0 && errno != EEXIST) eprintf("mkdir %s:", path); if (p) *p = '/'; diff --git a/mkfifo.c b/mkfifo.c @@ -30,7 +30,7 @@ main(int argc, char *argv[]) usage(); for (; argc > 0; argc--, argv++) - if (mkfifo(argv[0], mode) == -1) + if (mkfifo(argv[0], mode) < 0) eprintf("mkfifo %s:", argv[0]); return 0; } diff --git a/nohup.c b/nohup.c @@ -34,15 +34,15 @@ main(int argc, char *argv[]) if (isatty(STDOUT_FILENO)) { if ((fd = open("nohup.out", O_APPEND|O_CREAT, - S_IRUSR|S_IWUSR)) == -1) { + S_IRUSR|S_IWUSR)) < 0) { enprintf(Error, "open nohup.out:"); } - if (dup2(fd, STDOUT_FILENO) == -1) + if (dup2(fd, STDOUT_FILENO) < 0) enprintf(Error, "dup2:"); close(fd); } if (isatty(STDERR_FILENO)) - if (dup2(STDOUT_FILENO, STDERR_FILENO) == -1) + if (dup2(STDOUT_FILENO, STDERR_FILENO) < 0) enprintf(Error, "dup2:"); execvp(argv[0], &argv[0]); diff --git a/pwd.c b/pwd.c @@ -41,9 +41,9 @@ getpwd(const char *cwd) const char *pwd; struct stat cst, pst; - if (!(pwd = getenv("PWD")) || pwd[0] != '/' || stat(pwd, &pst) == -1) + if (!(pwd = getenv("PWD")) || pwd[0] != '/' || stat(pwd, &pst) < 0) return cwd; - if (stat(cwd, &cst) == -1) + if (stat(cwd, &cst) < 0) eprintf("stat %s:", cwd); if (pst.st_dev == cst.st_dev && pst.st_ino == cst.st_ino) return pwd; diff --git a/renice.c b/renice.c @@ -105,7 +105,7 @@ renice(int which, int who, long adj) } adj = MAX(PRIO_MIN, MIN(adj, PRIO_MAX)); - if (setpriority(which, who, (int)adj) == -1) { + if (setpriority(which, who, (int)adj) < 0) { weprintf("setpriority %d:", who); return 0; } diff --git a/rmdir.c b/rmdir.c @@ -23,7 +23,7 @@ main(int argc, char *argv[]) usage(); for (; argc > 0; argc--, argv++) - if (rmdir(argv[0]) == -1) + if (rmdir(argv[0]) < 0) weprintf("rmdir %s:", argv[0]); return 0; } diff --git a/sort.c b/sort.c @@ -208,7 +208,7 @@ parse_keydef(struct keydef *kd, char *s, int flags) kd->start_char = strtol(rest+1, &rest, 10); if (kd->start_char < 1) return -1; - if (parse_flags(&rest, &kd->flags, MOD_STARTB) == -1) + if (parse_flags(&rest, &kd->flags, MOD_STARTB) < 0) return -1; if (*rest == ',') { kd->end_column = strtol(rest+1, &rest, 10); @@ -219,7 +219,7 @@ parse_keydef(struct keydef *kd, char *s, int flags) if (kd->end_char < 1) return -1; } - if (parse_flags(&rest, &kd->flags, MOD_ENDB) == -1) + if (parse_flags(&rest, &kd->flags, MOD_ENDB) < 0) return -1; } if (*rest != '\0') diff --git a/split.c b/split.c @@ -131,7 +131,7 @@ nextfile(FILE *f, char *buf, int plen, int slen) if (f) fclose(f); s = itostr(buf+plen, n++, slen); - if (s == -1) + if (s < 0) return NULL; f = fopen(buf, "w"); diff --git a/touch.c b/touch.c @@ -55,7 +55,7 @@ touch(const char *str) if (stat(str, &st) == 0) { ut.actime = st.st_atime; ut.modtime = t; - if (utime(str, &ut) == -1) + if (utime(str, &ut) < 0) eprintf("utime %s:", str); return; } @@ -64,7 +64,7 @@ touch(const char *str) else if (cflag) return; if ((fd = open(str, O_CREAT|O_EXCL, - S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) == -1) + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) eprintf("open %s:", str); close(fd); touch(str); diff --git a/unlink.c b/unlink.c @@ -16,7 +16,7 @@ main(int argc, char *argv[]) if (argc != 2) usage(); - if (unlink(argv[1]) == -1) + if (unlink(argv[1]) < 0) eprintf("unlink: '%s':", argv[1]); return 0; diff --git a/xargs.c b/xargs.c @@ -191,22 +191,22 @@ poparg(void) int ch; argbpos = 0; - if (eatspace() == -1) + if (eatspace() < 0) return NULL; while ((ch = inputc()) != EOF) { switch (ch) { case ' ': case '\t': case '\n': goto out; case '\'': - if (parsequote('\'') == -1) + if (parsequote('\'') < 0) eprintf("unterminated single quote\n"); break; case '\"': - if (parsequote('\"') == -1) + if (parsequote('\"') < 0) eprintf("unterminated double quote\n"); break; case '\\': - if (parseescape() == -1) + if (parseescape() < 0) eprintf("backslash at EOF\n"); break; default: