1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

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.
This commit is contained in:
David Malone 2004-04-01 16:37:46 +00:00
parent a8c6f0ac9c
commit de06a3982c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127714

View File

@ -1228,6 +1228,7 @@ char *parse (char *buf, int *cmd)
int open_cd () int open_cd ()
{ {
char devbuf[MAXPATHLEN]; char devbuf[MAXPATHLEN];
const char *dev;
if (fd > -1) if (fd > -1)
return (1); return (1);
@ -1238,13 +1239,13 @@ int open_cd ()
} else { } else {
snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname); snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname);
} }
fd = open (devbuf, O_RDONLY); fd = open (dev = devbuf, O_RDONLY);
} else { } else {
fd = open("/dev/cdrom", O_RDONLY); fd = open(dev = "/dev/cdrom", O_RDONLY);
if (fd < 0 && errno == ENOENT) if (fd < 0 && errno == ENOENT)
fd = open("/dev/cd0", O_RDONLY); fd = open(dev = "/dev/cd0", O_RDONLY);
if (fd < 0 && errno == ENOENT) if (fd < 0 && errno == ENOENT)
fd = open("/dev/acd0", O_RDONLY); fd = open(dev = "/dev/acd0", O_RDONLY);
} }
if (fd < 0) { if (fd < 0) {
@ -1252,10 +1253,10 @@ int open_cd ()
/* ENXIO has an overloaded meaning here. /* ENXIO has an overloaded meaning here.
* The original "Device not configured" should * The original "Device not configured" should
* be interpreted as "No disc in drive %s". */ * be interpreted as "No disc in drive %s". */
warnx("no disc in drive %s", devbuf); warnx("no disc in drive %s", dev);
return (0); return (0);
} }
err(1, "%s", devbuf); err(1, "%s", dev);
} }
return (1); return (1);
} }