diff options
author | 2015-01-23 02:37:25 +0000 | |
---|---|---|
committer | 2015-01-23 02:37:25 +0000 | |
commit | dd2fc19c1bcbf43e5acf03814c79377818cdc2e1 (patch) | |
tree | 55354534d03dbaddff98fd0a20a05abdf4b84fe0 /usr.sbin/cron/crontab.c | |
parent | don't need to define debugging 0 anymore (diff) | |
download | wireguard-openbsd-dd2fc19c1bcbf43e5acf03814c79377818cdc2e1.tar.xz wireguard-openbsd-dd2fc19c1bcbf43e5acf03814c79377818cdc2e1.zip |
Remove the OK and ERR macros. They obfuscate the code and don't
help legibility. (unix system calls use 0 for ok, but hundreds of
other projects use 1 to indicate success.) Despite the name, many
system calls (e.g., open) also return not OK values for success.
It also cleans up some weird code like int crontab_fd = OK - 1;
This diff is mechanical in nature. Later I will fix the bugs it reveals.
ok deraadt
Diffstat (limited to 'usr.sbin/cron/crontab.c')
-rw-r--r-- | usr.sbin/cron/crontab.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 17a5632e0f0..05971bec12c 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.68 2015/01/23 01:01:06 tedu Exp $ */ +/* $OpenBSD: crontab.c,v 1.69 2015/01/23 02:37:25 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -196,7 +196,7 @@ parse_args(int argc, char *argv[]) { * the race. */ - if (swap_gids() < OK) { + if (swap_gids() < 0) { perror("swapping gids"); exit(EXIT_FAILURE); } @@ -204,7 +204,7 @@ parse_args(int argc, char *argv[]) { perror(Filename); exit(EXIT_FAILURE); } - if (swap_gids_back() < OK) { + if (swap_gids_back() < 0) { perror("swapping gids back"); exit(EXIT_FAILURE); } @@ -312,12 +312,12 @@ edit_cmd(void) { fprintf(stderr, "path too long\n"); goto fatal; } - if (swap_gids() < OK) { + if (swap_gids() < 0) { perror("swapping gids"); exit(EXIT_FAILURE); } t = mkstemp(Filename); - if (swap_gids_back() < OK) { + if (swap_gids_back() < 0) { perror("swapping gids back"); exit(EXIT_FAILURE); } @@ -334,7 +334,7 @@ edit_cmd(void) { copy_crontab(f, NewCrontab); fclose(f); - if (fflush(NewCrontab) < OK) { + if (fflush(NewCrontab) < 0) { perror(Filename); exit(EXIT_FAILURE); } @@ -345,12 +345,12 @@ edit_cmd(void) { fprintf(stderr, "%s: error while writing new crontab to %s\n", ProgramName, Filename); fatal: - if (swap_gids() < OK) { + if (swap_gids() < 0) { perror("swapping gids"); exit(EXIT_FAILURE); } unlink(Filename); - if (swap_gids_back() < OK) { + if (swap_gids_back() < 0) { perror("swapping gids back"); exit(EXIT_FAILURE); } @@ -374,7 +374,7 @@ edit_cmd(void) { goto fatal; } if (timespeccmp(&ts[1], &statbuf.st_mtim, ==)) { - if (swap_gids() < OK) { + if (swap_gids() < 0) { perror("swapping gids"); exit(EXIT_FAILURE); } @@ -383,7 +383,7 @@ edit_cmd(void) { fprintf(stderr, "%s: crontab temp file moved, editor " "may create backup files improperly\n", ProgramName); } - if (swap_gids_back() < OK) { + if (swap_gids_back() < 0) { perror("swapping gids back"); exit(EXIT_FAILURE); } @@ -427,12 +427,12 @@ edit_cmd(void) { goto fatal; } remove: - if (swap_gids() < OK) { + if (swap_gids() < 0) { perror("swapping gids"); exit(EXIT_FAILURE); } unlink(Filename); - if (swap_gids_back() < OK) { + if (swap_gids_back() < 0) { perror("swapping gids back"); exit(EXIT_FAILURE); } @@ -514,7 +514,7 @@ replace_cmd(void) { CheckErrorCount = 0; eof = FALSE; while (!CheckErrorCount && !eof) { switch (load_env(envstr, tmp)) { - case ERR: + case -1: /* check for data before the EOF */ if (envstr[0] != '\0') { Set_LineNum(LineNumber + 1); @@ -539,7 +539,7 @@ replace_cmd(void) { goto done; } - if (fchown(fileno(tmp), pw->pw_uid, -1) < OK) { + if (fchown(fileno(tmp), pw->pw_uid, -1) < 0) { perror("fchown"); fclose(tmp); error = -2; |