summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2004-04-01 16:37:46 +0000
committerdwmalone <dwmalone@FreeBSD.org>2004-04-01 16:37:46 +0000
commitdcbc9095f34531087d77e6cdf8818cdb9e74b40d (patch)
tree34a7adf6d1b558bae18f3bdbaac7a2589efa5b0f /usr.sbin
parentee1f5105c158db34192416a02861551eece37731 (diff)
downloadFreeBSD-src-dcbc9095f34531087d77e6cdf8818cdb9e74b40d.zip
FreeBSD-src-dcbc9095f34531087d77e6cdf8818cdb9e74b40d.tar.gz
If the user doesn't specify a device and we can't open any of the defaults,
don't print an error using a uninitialised devbuf.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c
index 5dd5bd7..edebd65 100644
--- a/usr.sbin/cdcontrol/cdcontrol.c
+++ b/usr.sbin/cdcontrol/cdcontrol.c
@@ -1228,6 +1228,7 @@ char *parse (char *buf, int *cmd)
int open_cd ()
{
char devbuf[MAXPATHLEN];
+ const char *dev;
if (fd > -1)
return (1);
@@ -1238,13 +1239,13 @@ int open_cd ()
} else {
snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname);
}
- fd = open (devbuf, O_RDONLY);
+ fd = open (dev = devbuf, O_RDONLY);
} else {
- fd = open("/dev/cdrom", O_RDONLY);
+ fd = open(dev = "/dev/cdrom", O_RDONLY);
if (fd < 0 && errno == ENOENT)
- fd = open("/dev/cd0", O_RDONLY);
+ fd = open(dev = "/dev/cd0", O_RDONLY);
if (fd < 0 && errno == ENOENT)
- fd = open("/dev/acd0", O_RDONLY);
+ fd = open(dev = "/dev/acd0", O_RDONLY);
}
if (fd < 0) {
@@ -1252,10 +1253,10 @@ int open_cd ()
/* ENXIO has an overloaded meaning here.
* The original "Device not configured" should
* be interpreted as "No disc in drive %s". */
- warnx("no disc in drive %s", devbuf);
+ warnx("no disc in drive %s", dev);
return (0);
}
- err(1, "%s", devbuf);
+ err(1, "%s", dev);
}
return (1);
}
OpenPOWER on IntegriCloud