summaryrefslogtreecommitdiff
path: root/usr.bin/mkimg/scheme.c
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2015-02-22 01:20:49 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2015-02-22 01:20:49 +0000
commitaba885c9603137ab96425ff89d993b32f1c6c712 (patch)
tree7907ee6ce057eaba935ecbe0aa6005afff1f09ae /usr.bin/mkimg/scheme.c
parent8617260a035acbc099d6fb839f27668911019296 (diff)
downloadsrc-test2-aba885c9603137ab96425ff89d993b32f1c6c712.tar.gz
src-test2-aba885c9603137ab96425ff89d993b32f1c6c712.zip
Don't require a scheme if no partitions are given. Change the code
to handle that case. Note that we still require partitions, so the change is effectively a no-op.
Notes
Notes: svn path=/head/; revision=279128
Diffstat (limited to 'usr.bin/mkimg/scheme.c')
-rw-r--r--usr.bin/mkimg/scheme.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/mkimg/scheme.c b/usr.bin/mkimg/scheme.c
index 5c6308fde9df..336f953c8b6c 100644
--- a/usr.bin/mkimg/scheme.c
+++ b/usr.bin/mkimg/scheme.c
@@ -31,8 +31,10 @@ __FBSDID("$FreeBSD$");
#include <sys/linker_set.h>
#include <sys/queue.h>
#include <sys/stat.h>
+#include <assert.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -104,7 +106,7 @@ scheme_bootcode(int fd)
{
struct stat sb;
- if (scheme->bootcode == 0)
+ if (scheme == NULL || scheme->bootcode == 0)
return (ENXIO);
if (fstat(fd, &sb) == -1)
@@ -130,6 +132,8 @@ scheme_check_part(struct part *p)
struct mkimg_alias *iter;
enum alias alias;
+ assert(scheme != NULL);
+
/* Check the partition type alias */
alias = scheme_parse_alias(p->alias);
if (alias == ALIAS_NONE)
@@ -158,28 +162,26 @@ u_int
scheme_max_parts(void)
{
- return (scheme->nparts);
+ return ((scheme == NULL) ? 0 : scheme->nparts);
}
u_int
scheme_max_secsz(void)
{
- return (scheme->maxsecsz);
+ return ((scheme == NULL) ? INT_MAX+1U : scheme->maxsecsz);
}
lba_t
scheme_metadata(u_int where, lba_t start)
{
- return (scheme->metadata(where, start));
+ return ((scheme == NULL) ? start : scheme->metadata(where, start));
}
int
scheme_write(lba_t end)
{
- int error;
- error = scheme->write(end, bootcode);
- return (error);
+ return ((scheme == NULL) ? 0 : scheme->write(end, bootcode));
}