From de06a3982c3473af5ad1d06e7b26110f4144b9fd Mon Sep 17 00:00:00 2001 From: David Malone Date: Thu, 1 Apr 2004 16:37:46 +0000 Subject: [PATCH] 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. --- usr.sbin/cdcontrol/cdcontrol.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 5dd5bd758f9e..edebd65056e9 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); }