Check the return value of getcwd() to avoid printf()ing a NULL. Mark
usage() as __dead2 to avoid a GCC warning. Spotted by: keramida
This commit is contained in:
parent
60f9b09d26
commit
f3a09c6c9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98057
@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static void usage(void);
|
static void usage(void) __dead2;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
@ -49,9 +49,10 @@ main(int argc, char *argv[])
|
|||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1) {
|
||||||
p = getcwd(NULL, 0);
|
if ((p = getcwd(NULL, 0)) == NULL)
|
||||||
else if (argc == 2) {
|
err(1, "getcwd()");
|
||||||
|
} else if (argc == 2) {
|
||||||
if ((p = realpath(argv[1], buf)) == NULL)
|
if ((p = realpath(argv[1], buf)) == NULL)
|
||||||
err(1, "%s", argv[1]);
|
err(1, "%s", argv[1]);
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user