fastboot should return non-zero exit code on error
When using fastboot in scripts, it currently is necessary to parse the output for FAILED messages and possible other indications of error. This happens relatively often, for example when there are radio update issues. Fortunately, fb_execute_queue already has a notion that an error has occured which is used to abort the queue execution. This change makes the status value be returned from fb_execute_queue to main which can then return it as an exit status. usage cases were also changed to return 1. Note the code already returned 1 for error in one other case when there was a problem with boot, so there is a precedent for return 1 on error in this program. Change-Id: Ib0463b08c8f2569495e248dd84e331f7e3691039
This commit is contained in:
parent
f538d8c76b
commit
eb31c0bdc0
|
@ -271,11 +271,11 @@ void fb_queue_notice(const char *notice)
|
|||
a->data = (void*) notice;
|
||||
}
|
||||
|
||||
void fb_execute_queue(usb_handle *usb)
|
||||
int fb_execute_queue(usb_handle *usb)
|
||||
{
|
||||
Action *a;
|
||||
char resp[FB_RESPONSE_SZ+1];
|
||||
int status;
|
||||
int status = 0;
|
||||
|
||||
a = action_list;
|
||||
resp[FB_RESPONSE_SZ] = 0;
|
||||
|
@ -307,5 +307,5 @@ void fb_execute_queue(usb_handle *usb)
|
|||
}
|
||||
|
||||
fprintf(stderr,"finished. total time: %.3fs\n", (now() - start));
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -550,11 +550,12 @@ int main(int argc, char **argv)
|
|||
void *data;
|
||||
unsigned sz;
|
||||
unsigned page_size = 2048;
|
||||
int status;
|
||||
|
||||
skip(1);
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(*argv, "devices")) {
|
||||
|
@ -686,6 +687,7 @@ int main(int argc, char **argv)
|
|||
argc = do_oem_command(argc, argv);
|
||||
} else {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,6 +703,6 @@ int main(int argc, char **argv)
|
|||
|
||||
usb = open_device();
|
||||
|
||||
fb_execute_queue(usb);
|
||||
return 0;
|
||||
status = fb_execute_queue(usb);
|
||||
return (status) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ void fb_queue_reboot(void);
|
|||
void fb_queue_command(const char *cmd, const char *msg);
|
||||
void fb_queue_download(const char *name, void *data, unsigned size);
|
||||
void fb_queue_notice(const char *notice);
|
||||
void fb_execute_queue(usb_handle *usb);
|
||||
int fb_execute_queue(usb_handle *usb);
|
||||
|
||||
/* util stuff */
|
||||
void die(const char *fmt, ...);
|
||||
|
|
Loading…
Reference in New Issue