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>
This commit is contained in:
parent
2a253e7cdb
commit
c7e2a6fe92
1 changed files with 9 additions and 8 deletions
|
@ -155,16 +155,17 @@ int main( int argc, const char *argv[] )
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Ugly... iterate over arguments to see whether we can expect a write */
|
if( argc < 2 ) {
|
||||||
for( i = 1; i < argc; i++ )
|
usage();
|
||||||
if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
|
return 1;
|
||||||
( !strcmp(argv[i], "unset") && ++i < argc ) ||
|
|
||||||
!strcmp(argv[i], "commit") )
|
|
||||||
{
|
|
||||||
write = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ugly... iterate over arguments to see whether we can expect a write */
|
||||||
|
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();
|
nvram = write ? nvram_open_staging() : nvram_open_rdonly();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue