1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-22 20:28:25 +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 ){
struct ingenic_dev ingenic_dev;
int res = EXIT_FAILURE;
int res = 0;
int status;
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();
}
res = EXIT_SUCCESS;
res = 1;
cleanup:
if (ingenic_dev.file_buff)

View File

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

View File

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