o confstr(3) returns 0 on error. Check the return value accordingly.
PR: misc/106414 MFC after: 1 week
This commit is contained in:
parent
d8a0af2579
commit
ee86f7872a
@ -139,19 +139,23 @@ static void
|
||||
do_confstr(const char *name, int key)
|
||||
{
|
||||
size_t len;
|
||||
int savederr;
|
||||
|
||||
savederr = errno;
|
||||
errno = 0;
|
||||
len = confstr(key, 0, 0);
|
||||
if (len == (size_t)-1)
|
||||
err(EX_OSERR, "confstr: %s", name);
|
||||
|
||||
if (len == 0)
|
||||
printf("undefined\n");
|
||||
else {
|
||||
if (len == 0) {
|
||||
if (errno)
|
||||
err(EX_OSERR, "confstr: %s", name);
|
||||
else
|
||||
printf("undefined\n");
|
||||
} else {
|
||||
char buf[len + 1];
|
||||
|
||||
confstr(key, buf, len);
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
errno = savederr;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user