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
8b0a738288
commit
37716191a8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164945
@ -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