summaryrefslogtreecommitdiff
path: root/package/utils/nvram
diff options
context:
space:
mode:
authorBangLang Huang <banglang.huang@foxmail.com>2017-02-24 10:52:52 +0800
committerAlexander Couzens <lynxis@fe80.eu>2017-08-22 14:31:32 +0200
commitc7e2a6fe923dc86bab14d94ead322a045efca4c9 (patch)
tree8023ba0385625ed38eefc10a81d6a498cc433204 /package/utils/nvram
parent2a253e7cdbacd1bd19da80ea6f35a93b42655c3b (diff)
downloadmtk-20170518-c7e2a6fe923dc86bab14d94ead322a045efca4c9.zip
mtk-20170518-c7e2a6fe923dc86bab14d94ead322a045efca4c9.tar.gz
mtk-20170518-c7e2a6fe923dc86bab14d94ead322a045efca4c9.tar.bz2
nvram: improve argument check when program start
print help message when argument count is less than 2. Signed-off-by: BangLang Huang <banglang.huang@foxmail.com>
Diffstat (limited to 'package/utils/nvram')
-rw-r--r--package/utils/nvram/src/cli.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/package/utils/nvram/src/cli.c b/package/utils/nvram/src/cli.c
index 149d307..538bdce 100644
--- a/package/utils/nvram/src/cli.c
+++ b/package/utils/nvram/src/cli.c
@@ -155,15 +155,16 @@ int main( int argc, const char *argv[] )
int done = 0;
int i;
+ if( argc < 2 ) {
+ usage();
+ return 1;
+ }
+
/* Ugly... iterate over arguments to see whether we can expect a write */
- for( i = 1; i < argc; i++ )
- if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
- ( !strcmp(argv[i], "unset") && ++i < argc ) ||
- !strcmp(argv[i], "commit") )
- {
- write = 1;
- break;
- }
+ if( ( !strcmp(argv[1], "set") && 2 < argc ) ||
+ ( !strcmp(argv[1], "unset") && 2 < argc ) ||
+ !strcmp(argv[1], "commit") )
+ write = 1;
nvram = write ? nvram_open_staging() : nvram_open_rdonly();