1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 18:22:28 +02:00

cleanup the code

change all the function return 1 for success
This commit is contained in:
xiangfu 2009-04-28 18:13:19 +00:00
parent 1275a789b7
commit e0de52c28c
3 changed files with 21 additions and 25 deletions

View File

@ -212,7 +212,7 @@ out:
int boot(char *stage1_path, char *stage2_path, char *config_path ){ int boot(char *stage1_path, char *stage2_path, char *config_path ){
struct ingenic_dev ingenic_dev; struct ingenic_dev ingenic_dev;
int res = EXIT_FAILURE; int res = 0;
int status; int status;
memset(&ingenic_dev, 0, sizeof(struct ingenic_dev)); memset(&ingenic_dev, 0, sizeof(struct ingenic_dev));
@ -272,7 +272,7 @@ int boot(char *stage1_path, char *stage2_path, char *config_path ){
check_dump_cfg(); check_dump_cfg();
} }
res = EXIT_SUCCESS; res = 1;
cleanup: cleanup:
if (ingenic_dev.file_buff) if (ingenic_dev.file_buff)

View File

@ -28,7 +28,7 @@
#include "config.h" #include "config.h"
static int com_argc; static int com_argc;
static char com_argv[20][50]; static char com_argv[9][100];
static const char COMMAND[][30]= static const char COMMAND[][30]=
{ {
@ -133,8 +133,8 @@ int command_input(char *buf)
cptr = fgets(buf, 256, stdin); cptr = fgets(buf, 256, stdin);
if (cptr != NULL) if (cptr != NULL)
return 0;
return 1; return 1;
return 0;
} }
int command_interpret(char * com_buf) int command_interpret(char * com_buf)
@ -158,8 +158,7 @@ int command_interpret(char * com_buf)
} else { } else {
com_argv[i][j] = *buf; com_argv[i][j] = *buf;
j++; j++;
if (j>100) if (j > 100) {
{
printf("\n Para is too long! About!"); printf("\n Para is too long! About!");
return 0; return 0;
} }
@ -178,9 +177,8 @@ int command_interpret(char * com_buf)
int command_handle(char *buf) int command_handle(char *buf)
{ {
int cmd = command_interpret(buf); int cmd = command_interpret(buf);
int result = 0;
if (!cmd) return 1; if (!cmd) return -1;
switch (cmd) { switch (cmd) {
case 11: case 11:
handle_nprog(); handle_nprog();
@ -199,9 +197,9 @@ int command_handle(char *buf)
break; break;
default: default:
printf("\n Command not support!"); printf("\n Command not support!");
result = 1; result = -1;
break; break;
} }
return result; return 1;
} }

View File

@ -70,12 +70,10 @@ int main(int argc, char **argv)
switch (c) { switch (c) {
case 'h': case 'h':
help(); help();
exit(0); exit(EXIT_SUCCESS);
break;
case 'v': case 'v':
print_version(); print_version();
exit(0); exit(EXIT_SUCCESS);
break;
default: default:
help(); help();
exit(2); exit(2);
@ -88,11 +86,11 @@ int main(int argc, char **argv)
while (1) { while (1) {
printf("\n inflash :> "); printf("\n inflash :> ");
if (command_input(com_buf)) if (!command_input(com_buf))
continue; continue;
command_handle(com_buf); command_handle(com_buf);
} }
return 0; return EXIT_SUCCESS;
} }