From 90c976fdaf54ccab88d53c7e0cb88f8edf790fa6 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Wed, 30 Mar 2016 14:14:29 -0700 Subject: [PATCH] Require the -F option for swupd_create_update To decrease chances of specifying an incorrect format number, since the default is a hardcoded value "3", always require the user to pass the -F option to swupd_create_update. In the future, it would be nice to read the default value from a config file, with the -F option overriding the value. Signed-off-by: Patrick McCarty --- include/swupd.h | 1 - src/globals.c | 3 ++- src/main.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/swupd.h b/include/swupd.h index d038489..b45f46e 100644 --- a/include/swupd.h +++ b/include/swupd.h @@ -13,7 +13,6 @@ // SWUPD_NUM_PACKS is also "PREV_CHECK" in releas tool swupd_bb.py (change both) #define SWUPD_NUM_PACKS 4 #define SWUPD_NUM_MANIFEST_DELTAS 25 -#define SWUPD_DEFAULT_FORMAT 3 #define SWUPD_SERVER_STATE_DIR "/var/lib/update" diff --git a/src/globals.c b/src/globals.c index 214c4d8..587419b 100644 --- a/src/globals.c +++ b/src/globals.c @@ -79,7 +79,8 @@ bool set_state_dir(char *dir) bool init_globals(void) { if (format == -1) { - format = SWUPD_DEFAULT_FORMAT; + printf("Error: Missing format parameter. Please specify a format with -F.\n"); + return false; } if (!init_state_globals()) { diff --git a/src/main.c b/src/main.c index a23a05e..b479fc2 100644 --- a/src/main.c +++ b/src/main.c @@ -69,7 +69,7 @@ static void print_help(const char *name) printf("Application Options:\n"); printf(" -o, --osversion The OS version for which to create an update\n"); printf(" -m, --minversion Optional minimum file version to write into manifests per file\n"); - printf(" -F, --format Optional format string [ default:=%d ]\n", SWUPD_DEFAULT_FORMAT); + printf(" -F, --format Format number for the update\n"); printf(" -g, --getformat Print current format string and exit\n"); printf(" -S, --statedir Optional directory to use for state [ default:=%s ]\n", SWUPD_SERVER_STATE_DIR); printf(" -s, --signcontent Enables cryptographic signing of update content\n"); @@ -118,7 +118,7 @@ static bool parse_options(int argc, char **argv) break; case 'g': if (format == -1) { - printf("%d\n", SWUPD_DEFAULT_FORMAT); + printf("No format specified\n"); } else { printf("%llu\n", format); free_globals();