Fix warnings. This is now WARNS=9, std=c99 clean in i386.

Use return(0) for main() instead of exit(0). Makes it a
wee bit smaller.
This commit is contained in:
markm 2003-05-03 10:14:26 +00:00
parent a3b8d0b40b
commit aed36bd125

View File

@ -47,10 +47,10 @@ __FBSDID("$FreeBSD$");
#include <ctype.h> #include <ctype.h>
#include <limits.h> #include <limits.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
void usage(void); void usage(void);
@ -64,7 +64,7 @@ main(int argc, char *argv[])
if (argc != 2) { if (argc != 2) {
usage(); usage();
/* NOTREACHED */ return(1);
} }
p = argv[1]; p = argv[1];
@ -78,9 +78,10 @@ main(int argc, char *argv[])
if (*p == '-') { if (*p == '-') {
neg = 1; neg = 1;
++p; ++p;
if (!isdigit((unsigned char)*p) && *p != '.') if (!isdigit((unsigned char)*p) && *p != '.') {
usage(); usage();
/* NOTREACHED */ return(1);
}
} }
else if (*p == '+') else if (*p == '+')
++p; ++p;
@ -109,20 +110,20 @@ main(int argc, char *argv[])
time_to_sleep.tv_nsec += (*p - '0') * l; time_to_sleep.tv_nsec += (*p - '0') * l;
else else
break; break;
} while (l /= 10); l /= 10;
} while (l);
} }
if (!neg && (time_to_sleep.tv_sec > 0 || time_to_sleep.tv_nsec > 0)) if (!neg && (time_to_sleep.tv_sec > 0 || time_to_sleep.tv_nsec > 0))
(void)nanosleep(&time_to_sleep, (struct timespec *)NULL); (void)nanosleep(&time_to_sleep, (struct timespec *)NULL);
exit(0); return(0);
} }
void void
usage(void) usage(void)
{ {
const char *msg = "usage: sleep seconds\n"; const char msg[] = "usage: sleep seconds\n";
write(STDERR_FILENO, msg, strlen(msg)); write(STDERR_FILENO, msg, sizeof(msg) - 1);
exit(1);
} }