summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-04-11 16:54:29 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-04-11 16:54:29 +0000
commiteccb04705ac1a9a387c0e27658f1ddf8f9c131ea (patch)
tree272dd09993e78123bb9d4e8cbb9e1f214eb4bcbb
parent067553ae75910d88e0e9edb968609e4e994a040c (diff)
readlabel() either errored out or returned a pointer to the global
'lab'. So there is no need for the return value. Just use &lab wherever it was used. No functional change. Slightly different version read ok to blambert@
-rw-r--r--sbin/disklabel/disklabel.c47
-rw-r--r--sbin/disklabel/extern.h4
2 files changed, 20 insertions, 31 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 928ef2634e9..0ceefa749ae 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.148 2009/04/10 20:54:08 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.149 2009/04/11 16:54:28 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.148 2009/04/10 20:54:08 krw Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.149 2009/04/11 16:54:28 krw Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -265,27 +265,24 @@ main(int argc, char *argv[])
case EDIT:
if (argc != 1)
usage();
- if ((lp = readlabel(f)) == NULL)
- exit(1);
- error = edit(lp, f);
+ readlabel(f);
+ error = edit(&lab, f);
break;
case EDITOR:
if (argc != 1)
usage();
- if ((lp = readlabel(f)) == NULL)
- exit(1);
- error = editor(lp, f);
+ readlabel(f);
+ error = editor(&lab, f);
break;
case READ:
if (argc != 1)
usage();
- if ((lp = readlabel(f)) == NULL)
- exit(1);
+ readlabel(f);
if (tflag)
- makedisktab(stdout, lp);
+ makedisktab(stdout, &lab);
else
- display(stdout, lp, print_unit, 1);
- error = checklabel(lp);
+ display(stdout, &lab, print_unit, 1);
+ error = checklabel(&lab);
break;
case RESTORE:
if (argc < 2 || argc > 3)
@@ -311,8 +308,7 @@ main(int argc, char *argv[])
break;
case WRITE:
if (dflag | aflag) {
- if (readlabel(f) == NULL)
- exit(1);
+ readlabel(f);
} else if (argc < 2 || argc > 3)
usage();
else
@@ -327,9 +323,8 @@ main(int argc, char *argv[])
{
struct disklabel tlab;
- if ((lp = readlabel(f)) == NULL)
- exit(1);
- tlab = *lp;
+ readlabel(f);
+ tlab = lab;
if (argc == 2)
makelabel(argv[1], NULL, &lab);
lp = makebootarea(bootarea, &lab, f);
@@ -685,30 +680,24 @@ check_dpme(int f, uint32_t *start, uint32_t *size)
#endif
/*
- * Fetch disklabel for disk using ioctl.
+ * Fetch requested disklabel into 'lab' using ioctl.
*/
-struct disklabel *
+void
readlabel(int f)
{
- struct disklabel *lp = NULL;
-
if (cflag && ioctl(f, DIOCRLDINFO) < 0)
err(4, "ioctl DIOCRLDINFO");
if (dflag | aflag) {
- lp = &lab;
- if (ioctl(f, DIOCGPDINFO, lp) < 0)
+ if (ioctl(f, DIOCGPDINFO, &lab) < 0)
err(4, "ioctl DIOCGPDINFO");
} else {
- lp = &lab;
- if (ioctl(f, DIOCGDINFO, lp) < 0)
+ if (ioctl(f, DIOCGDINFO, &lab) < 0)
err(4, "ioctl DIOCGDINFO");
}
if (aflag)
- editor_allocspace(lp);
-
- return (lp);
+ editor_allocspace(&lab);
}
/*
diff --git a/sbin/disklabel/extern.h b/sbin/disklabel/extern.h
index 077a1d08f68..8de8d5dc753 100644
--- a/sbin/disklabel/extern.h
+++ b/sbin/disklabel/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.12 2009/04/10 20:54:08 krw Exp $ */
+/* $OpenBSD: extern.h,v 1.13 2009/04/11 16:54:28 krw Exp $ */
/*
* Copyright (c) 2003 Theo de Raadt <deraadt@openbsd.org>
@@ -22,7 +22,7 @@ double scale(u_int64_t, char, struct disklabel *);
void display(FILE *, struct disklabel *, char, int);
void display_partition(FILE *, struct disklabel *, int, char);
-struct disklabel *readlabel(int);
+void readlabel(int);
struct disklabel *makebootarea(char *, struct disklabel *, int);
int editor(struct disklabel *, int);