mirror of
https://github.com/openwrt/openwrt.git
synced 2025-03-11 15:04:26 +00:00
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> (cherry picked from commit c7e2a6fe923dc86bab14d94ead322a045efca4c9)
This commit is contained in:
parent
c446ee4ad4
commit
118a2ea0bc
@ -155,15 +155,16 @@ int main( int argc, const char *argv[] )
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if( argc < 2 ) {
|
||||||
|
usage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ugly... iterate over arguments to see whether we can expect a write */
|
/* Ugly... iterate over arguments to see whether we can expect a write */
|
||||||
for( i = 1; i < argc; i++ )
|
if( ( !strcmp(argv[1], "set") && 2 < argc ) ||
|
||||||
if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
|
( !strcmp(argv[1], "unset") && 2 < argc ) ||
|
||||||
( !strcmp(argv[i], "unset") && ++i < argc ) ||
|
!strcmp(argv[1], "commit") )
|
||||||
!strcmp(argv[i], "commit") )
|
write = 1;
|
||||||
{
|
|
||||||
write = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nvram = write ? nvram_open_staging() : nvram_open_rdonly();
|
nvram = write ? nvram_open_staging() : nvram_open_rdonly();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user