Make symupload exit with an error code when command-line parsing fails.

This should address the issue where some Chrome builds were failing to
upload symbols due to a bad command-line flag, but there was no
indication of a problem, and no build failure, because symupload was
exiting with a success code.

BUG=1091387
R=nbilling@google.com, wuwang@google.com

Change-Id: I0d7f1a6d689ca5fd37be3abad4c5ebc97f108e50
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2231574
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Michael Moss 2020-06-04 23:28:44 +00:00 committed by Nelson Billing
parent f2679262ac
commit 2757a2c9c8

View file

@ -111,7 +111,7 @@ Usage(int argc, const char *argv[]) {
//=============================================================================
static void
SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind;
extern int optind, optopt;
int ch;
constexpr char flag_pattern[] = "u:v:x:p:k:t:c:i:hf?";
@ -120,7 +120,11 @@ SetupOptions(int argc, const char *argv[], Options *options) {
case 'h':
case '?':
Usage(argc, argv);
exit(0);
// ch might be '?' because getopt found an error while parsing args (as
// opposed to finding "-?" as an arg), in which case optopt is set to
// the bad arg value, so return an error code if optopt is set,
// otherwise exit cleanly.
exit(optopt == 0 ? 0 : 1);
break;
case 'u':
options->proxy_user_pwd = optarg;