diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-05-26 06:30:37 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-05-26 06:30:37 +0000 |
commit | 2de327593b32093f2b0fd22737c51dc94674640b (patch) | |
tree | fa0f8f030ad4de4f4cac2fe4a4b8fec2f3d6b387 /usr.sbin/lpr | |
parent | cf8e93299a23ca214f9ac8af77ef8230bcad3890 (diff) |
cgetstr(3) can also return 2 so handle that. Also restructre things a bit
to get rid of the flag var. ok deraadt@ fgsch@
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r-- | usr.sbin/lpr/lpd/lpd.c | 16 | ||||
-rw-r--r-- | usr.sbin/lpr/lpq/lpq.c | 16 |
2 files changed, 14 insertions, 18 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index 61669e223b3..32314723374 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpd.c,v 1.48 2008/05/22 08:06:57 otto Exp $ */ +/* $OpenBSD: lpd.c,v 1.49 2008/05/26 06:30:35 otto Exp $ */ /* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */ /* @@ -41,7 +41,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95"; #else -static const char rcsid[] = "$OpenBSD: lpd.c,v 1.48 2008/05/22 08:06:57 otto Exp $"; +static const char rcsid[] = "$OpenBSD: lpd.c,v 1.49 2008/05/26 06:30:35 otto Exp $"; #endif #endif /* not lint */ @@ -650,15 +650,13 @@ ckqueue(char *cap) struct dirent *d; DIR *dirp; char *spooldir; - int free_spooldir = 1; - if (cgetstr(cap, "sd", &spooldir) == -1) { - spooldir = _PATH_DEFSPOOL; - free_spooldir = 0; - } - dirp = opendir(spooldir); - if (free_spooldir) + if (cgetstr(cap, "sd", &spooldir) >= 0) { + dirp = opendir(spooldir); free(spooldir); + } else + dirp = opendir(_PATH_DEFSPOOL); + if (dirp == NULL) return (-1); while ((d = readdir(dirp)) != NULL) { diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c index 8df943c8597..a1be85efb4a 100644 --- a/usr.sbin/lpr/lpq/lpq.c +++ b/usr.sbin/lpr/lpq/lpq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpq.c,v 1.17 2008/05/22 08:06:57 otto Exp $ */ +/* $OpenBSD: lpq.c,v 1.18 2008/05/26 06:30:36 otto Exp $ */ /* $NetBSD: lpq.c,v 1.9 1999/12/07 14:54:47 mrg Exp $ */ /* @@ -41,7 +41,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lpq.c 8.3 (Berkeley) 5/10/95"; #else -static const char rcsid[] = "$OpenBSD: lpq.c,v 1.17 2008/05/22 08:06:57 otto Exp $"; +static const char rcsid[] = "$OpenBSD: lpq.c,v 1.18 2008/05/26 06:30:36 otto Exp $"; #endif #endif /* not lint */ @@ -168,15 +168,13 @@ ckqueue(char *cap) struct dirent *d; DIR *dirp; char *spooldir; - int free_spooldir = 1; - if (cgetstr(cap, "sd", &spooldir) == -1) { - spooldir = _PATH_DEFSPOOL; - free_spooldir = 0; - } - dirp = opendir(spooldir); - if (free_spooldir) + if (cgetstr(cap, "sd", &spooldir) >= 0) { + dirp = opendir(spooldir); free(spooldir); + } else + dirp = opendir(_PATH_DEFSPOOL); + if (dirp == NULL) return (-1); while ((d = readdir(dirp)) != NULL) { |