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

Improve error condition handling.

This commit is contained in:
Peter Zotov 2010-12-04 04:46:29 +03:00
parent 5cc2d7446f
commit 5639e64034
3 changed files with 34 additions and 3 deletions

View File

@ -253,8 +253,11 @@ int ingenic_loadstage(void *hndl, int id, const char *file) {
FILE *fd = fopen(file, "rb");
if(fd == NULL)
if(fd == NULL) {
debug(LEVEL_ERROR, "Ingenic: cannot load file `%s'\n", file);
return -1;
}
fseek(fd, 0, SEEK_END);
int size = ftell(fd);

20
shell.c
View File

@ -292,7 +292,7 @@ static int builtin_exit(int argc, char *argv[]) {
}
static int builtin_source(int argc, char *argv[]) {
if(argc < 2) {
if(argc != 2) {
printf("Usage: %s <FILENAME>\n", argv[0]);
return -1;
@ -322,6 +322,12 @@ static int builtin_echo(int argc, char *argv[]) {
}
static int builtin_redetect(int argc, char *argv[]) {
if(argc != 1) {
printf("Usage: %s\n", argv[0]);
return -1;
}
if(ingenic_redetect(device) == -1) {
perror("ingenic_redetect");
@ -339,9 +345,13 @@ static int builtin_set(int argc, char *argv[]) {
} else if(argc == 2) {
cfg_unsetenv(argv[1]);
} else if(argc >= 3) {
} else if(argc == 3) {
cfg_setenv(argv[1], argv[2]);
} else {
printf("Usage: %s [VARIABLE] [VALUE]\n", argv[0]);
return -1;
}
return 0;
@ -349,6 +359,12 @@ static int builtin_set(int argc, char *argv[]) {
static int builtin_rebuildcfg(int argc, char *argv[]) {
if(argc != 1) {
printf("Usage: %s\n", argv[0]);
return -1;
}
return ingenic_rebuild(device);
}

View File

@ -34,6 +34,12 @@ const shell_command_t spl_cmdset[] = {
};
static int spl_load_stage1() {
if(cfg_getenv("STAGE1_FILE") == NULL) {
printf("Variable STAGE1_FILE is not set\n");
return -1;
}
return ingenic_loadstage(shell_device(), INGENIC_STAGE1, cfg_getenv("STAGE1_FILE"));
}
@ -57,5 +63,11 @@ static int spl_boot(int argc, char *argv[]) {
if(ret == -1)
return -1;
if(cfg_getenv("STAGE2_FILE") == NULL) {
printf("Variable STAGE2_FILE is not set\n");
return -1;
}
return ingenic_loadstage(shell_device(), INGENIC_STAGE2, cfg_getenv("STAGE2_FILE"));
}