diff options
author | 2019-06-28 13:34:58 +0000 | |
---|---|---|
committer | 2019-06-28 13:34:58 +0000 | |
commit | 3aaa63eb46949490a39db9c6d82aacc8ee5d8551 (patch) | |
tree | ef48ea58ad350ab9d01fbfe32455a1df1fa2340c /usr.bin/rpcgen | |
parent | fputc/fputs return EOF on error (diff) | |
download | wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.tar.xz wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.zip |
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r-- | usr.bin/rpcgen/rpc_main.c | 10 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_svcout.c | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 0abb7d70263..3d04fdc7f9e 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.34 2018/04/26 12:42:51 guenther Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.35 2019/06/28 13:35:03 deraadt Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* @@ -282,14 +282,14 @@ find_cpp(void) struct stat buf; /* SVR4 or explicit cpp does not exist */ - if (stat(CPP, &buf) < 0) { + if (stat(CPP, &buf) == -1) { if (cppDefined) { fprintf(stderr, "cannot find C preprocessor: %s \n", CPP); crash(); } else { /* try the other one */ CPP = SUNOS_CPP; - if (stat(CPP, &buf) < 0) { /* can't find any cpp */ + if (stat(CPP, &buf) == -1) { /* can't find any cpp */ fprintf(stderr, "cannot find any C preprocessor: %s\n", CPP); crash(); @@ -830,13 +830,13 @@ checkfiles(infile, outfile) struct stat buf; if (infile) /* infile ! = NULL */ - if (stat(infile, &buf) < 0) { + if (stat(infile, &buf) == -1) { perror(infile); crash(); } #if 0 if (outfile) { - if (stat(outfile, &buf) < 0) + if (stat(outfile, &buf) == -1) return; /* file does not exist */ else { fprintf(stderr, diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c index bcaadc8e88f..19d6dbc1923 100644 --- a/usr.bin/rpcgen/rpc_svcout.c +++ b/usr.bin/rpcgen/rpc_svcout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_svcout.c,v 1.27 2012/12/05 23:20:26 deraadt Exp $ */ +/* $OpenBSD: rpc_svcout.c,v 1.28 2019/06/28 13:35:03 deraadt Exp $ */ /* $NetBSD: rpc_svcout.c,v 1.7 1995/06/24 14:59:59 pk Exp $ */ /* @@ -718,7 +718,7 @@ write_pm_most(infile, netflag) definition *def; version_list *vp; - fprintf(fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n"); + fprintf(fout, "\tif (!ioctl(0, I_LOOK, mname) == -1 &&\n"); fprintf(fout, "\t\t(!strcmp(mname, \"sockmod\") ||"); fprintf(fout, " !strcmp(mname, \"timod\"))) {\n"); fprintf(fout, "\t\tchar *netid;\n"); @@ -746,7 +746,7 @@ write_pm_most(infile, netflag) * sockmod, and RPC works only with timod, hence all this jugglery */ fprintf(fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n"); - fprintf(fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n"); + fprintf(fout, "\t\t\tif (ioctl(0, I_POP, 0) == -1 || ioctl(0, I_PUSH, \"timod\") == -1) {\n"); snprintf(_errbuf, sizeof _errbuf, "could not get the right module"); print_err_message("\t\t\t\t"); fprintf(fout, "\t\t\t\texit(1);\n"); @@ -810,7 +810,7 @@ write_rpc_svc_fg(infile, sp) fprintf(fout, "%spid_t pid;\n\n", sp); } fprintf(fout, "%spid = fork();\n", sp); - fprintf(fout, "%sif (pid < 0) {\n", sp); + fprintf(fout, "%sif (pid == -1) {\n", sp); fprintf(fout, "%s\tperror(\"cannot fork\");\n", sp); fprintf(fout, "%s\texit(1);\n", sp); fprintf(fout, "%s}\n", sp); @@ -837,7 +837,7 @@ write_rpc_svc_fg(infile, sp) fprintf(fout, "%ssetsid();\n", sp); else { fprintf(fout, "%si = open(\"/dev/tty\", 2);\n", sp); - fprintf(fout, "%sif (i >= 0) {\n", sp); + fprintf(fout, "%sif (i != -1) {\n", sp); fprintf(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp); fprintf(fout, "%s\t(void) close(i);\n", sp); fprintf(fout, "%s}\n", sp); |