Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/utils/sysinst Trying to print a function pointer as ...
details: https://anonhg.NetBSD.org/src/rev/fcac943472ef
branches: trunk
changeset: 779862:fcac943472ef
user: christos <christos%NetBSD.org@localhost>
date: Sat Jun 23 14:06:02 2012 +0000
description:
Trying to print a function pointer as a string is likely to cause tears.
While here, don't match on the unit either
diffstat:
distrib/utils/sysinst/disks.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diffs (52 lines):
diff -r ea834ec1a7fa -r fcac943472ef distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c Sat Jun 23 08:48:15 2012 +0000
+++ b/distrib/utils/sysinst/disks.c Sat Jun 23 14:06:02 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.125 2012/06/22 20:54:39 abs Exp $ */
+/* $NetBSD: disks.c,v 1.126 2012/06/23 14:06:02 christos Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -324,21 +324,24 @@
const char *cd_dev;
/* On error just use first entry in cdrom_devices */
- if (sysctlbyname(mib_name, NULL, &len, NULL, 0) != 0)
+ if (sysctlbyname(mib_name, NULL, &len, NULL, 0) == -1)
return cdrom_devices[0];
- if ((disknames = malloc(len)) == 0) /* skip on malloc fail */
+ if ((disknames = malloc(len + 2)) == 0) /* skip on malloc fail */
return cdrom_devices[0];
- sysctlbyname(mib_name, disknames, &len, NULL, 0);
+ (void)sysctlbyname(mib_name, disknames, &len, NULL, 0);
for ((name = strtok_r(disknames, " ", &last)); name;
(name = strtok_r(NULL, " ", &last))) {
- for (arg = cdrom_devices ; *arg ; ++arg ) {
+ for (arg = cdrom_devices; *arg; ++arg) {
cd_dev = *arg;
- if (strncmp(cd_dev, name, strlen(cd_dev) - 1) == 0) {
- free(disknames);
- return cd_dev;
- }
-
+ /* skip unit and partition */
+ if (strncmp(cd_dev, name, strlen(cd_dev) - 2) != 0)
+ continue;
+ if (name != disknames)
+ strcpy(disknames, name);
+ strcat(disknames, "a");
+ /* XXX: leaks, but so what? */
+ return disknames;
}
}
free(disknames);
@@ -814,7 +817,7 @@
scripting_fprintf(f, "ptyfs\t\t/dev/pts\tptyfs\trw\n");
scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n");
scripting_fprintf(f, "/dev/%s\t\t/cdrom\tcd9660\tro,noauto\n",
- (char *)get_default_cdrom);
+ get_default_cdrom());
make_target_dir("/kern");
make_target_dir("/proc");
make_target_dir("/dev/pts");
Home |
Main Index |
Thread Index |
Old Index