Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160135800
D52612.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D52612.diff
View Options
diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c
--- a/bin/pwait/pwait.c
+++ b/bin/pwait/pwait.c
@@ -39,6 +39,7 @@
#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -48,7 +49,6 @@
static void
usage(void)
{
-
fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
exit(EX_USAGE);
}
@@ -61,15 +61,15 @@
{
struct itimerval itv;
struct kevent *e;
- int oflag, tflag, verbose;
- int i, kq, n, nleft, opt, status;
- long pid;
char *end, *s;
double timeout;
+ long pid;
+ int i, kq, n, nleft, opt, status;
+ bool oflag, tflag, verbose;
- oflag = 0;
- tflag = 0;
- verbose = 0;
+ oflag = false;
+ tflag = false;
+ verbose = false;
memset(&itv, 0, sizeof(itv));
while ((opt = getopt(argc, argv, "ot:v")) != -1) {
@@ -78,25 +78,31 @@
oflag = 1;
break;
case 't':
- tflag = 1;
+ tflag = true;
errno = 0;
timeout = strtod(optarg, &end);
if (end == optarg || errno == ERANGE || timeout < 0) {
errx(EX_DATAERR, "timeout value");
}
- switch(*end) {
- case 0:
+ switch (*end) {
+ case '\0':
+ break;
case 's':
+ end++;
break;
case 'h':
timeout *= 60;
/* FALLTHROUGH */
case 'm':
timeout *= 60;
+ end++;
break;
default:
errx(EX_DATAERR, "timeout unit");
}
+ if (*end != '\0') {
+ errx(EX_DATAERR, "timeout unit");
+ }
if (timeout > 100000000L) {
errx(EX_DATAERR, "timeout value");
}
@@ -106,7 +112,7 @@
(suseconds_t)(timeout * 1000000UL);
break;
case 'v':
- verbose = 1;
+ verbose = true;
break;
default:
usage();
@@ -134,7 +140,7 @@
for (n = 0; n < argc; n++) {
s = argv[n];
/* Undocumented Solaris compat */
- if (!strncmp(s, "/proc/", 6)) {
+ if (strncmp(s, "/proc/", 6) == 0) {
s += 6;
}
errno = 0;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jun 22, 4:37 PM (43 m, 39 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34199162
Default Alt Text
D52612.diff (1 KB)
Attached To
Mode
D52612: pwait: Fix timeout unit parser
Attached
Detach File
Event Timeline
Log In to Comment