fixed getopt exitcode with invalid parameters

This commit is contained in:
Blaise Tine 2024-09-07 03:42:46 -07:00
parent 2041a4ad4a
commit a75ed78bf2
26 changed files with 57 additions and 86 deletions

View file

@ -33,13 +33,11 @@ const char* program = nullptr;
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "rh?")) != -1) {
while ((c = getopt(argc, argv, "rh")) != -1) {
switch (c) {
case 'h':
case '?':
show_usage();
exit(0);
break;
show_usage();
exit(0);
default:
show_usage();
exit(-1);

View file

@ -40,7 +40,7 @@ const char* program = nullptr;
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "t:w:c:rsh?")) != -1) {
while ((c = getopt(argc, argv, "t:w:c:rsh")) != -1) {
switch (c) {
case 't':
num_threads = atoi(optarg);
@ -55,13 +55,12 @@ static void parse_args(int argc, char **argv) {
showStats = true;
break;
case 'h':
case '?':
show_usage();
exit(0);
show_usage();
exit(0);
break;
default:
show_usage();
exit(-1);
show_usage();
exit(-1);
}
}

View file

@ -116,16 +116,15 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -81,16 +81,15 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -87,7 +87,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "fn:h?")) != -1) {
while ((c = getopt(argc, argv, "fn:h")) != -1) {
switch (c) {
case 'f':
float_enable = 1;
@ -96,10 +96,9 @@ static void parse_args(int argc, char **argv) {
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -104,7 +104,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:l:h?")) != -1) {
while ((c = getopt(argc, argv, "n:l:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -113,10 +113,9 @@ static void parse_args(int argc, char **argv) {
local_size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -126,13 +126,12 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
case 'h':{
show_usage();
exit(0);
} break;

View file

@ -124,16 +124,15 @@ int size = 16;
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -147,16 +147,15 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -147,16 +147,15 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -148,7 +148,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:t:h?")) != -1) {
while ((c = getopt(argc, argv, "n:t:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -157,10 +157,9 @@ static void parse_args(int argc, char **argv) {
tile_size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -141,16 +141,15 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:h?")) != -1) {
while ((c = getopt(argc, argv, "n:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -38,7 +38,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:t:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:t:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -50,10 +50,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -109,7 +109,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:lh?")) != -1) {
while ((c = getopt(argc, argv, "n:k:lh")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -121,10 +121,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -87,7 +87,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -95,8 +95,7 @@ static void parse_args(int argc, char **argv) {
case 'k':
kernel_file = optarg;
break;
case 'h':
case '?': {
case 'h':{
show_usage();
exit(0);
} break;

View file

@ -35,7 +35,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -44,10 +44,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -35,7 +35,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:t:x:s:e:k:ch?")) != -1) {
while ((c = getopt(argc, argv, "n:t:x:s:e:k:ch")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -59,10 +59,9 @@ static void parse_args(int argc, char **argv) {
stop_on_error = false;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -35,7 +35,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -44,10 +44,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -42,7 +42,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -51,10 +51,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -83,7 +83,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -92,10 +92,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -33,7 +33,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -42,10 +42,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -103,7 +103,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:t:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:t:k:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -115,10 +115,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -99,7 +99,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -108,10 +108,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -34,7 +34,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
count = atoi(optarg);
@ -43,10 +43,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);

View file

@ -128,7 +128,7 @@ static void stencil_cpu(TYPE *out, const TYPE *in, uint32_t width, uint32_t heig
{ny = 0;}
else if (ny >= (int)height)
{ny = height - 1;}
if (nz < 0)
{nz = 0;}
else if (nz >= (int)depth)
@ -168,7 +168,7 @@ static void show_usage()
static void parse_args(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, "n:t:k:h?")) != -1)
while ((c = getopt(argc, argv, "n:t:k:h")) != -1)
{
switch (c)
{
@ -182,12 +182,9 @@ static void parse_args(int argc, char **argv)
kernel_file = optarg;
break;
case 'h':
case '?':
{
show_usage();
exit(0);
}
break;
break;
default:
show_usage();
exit(-1);

View file

@ -87,7 +87,7 @@ static void show_usage() {
static void parse_args(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "n:k:h?")) != -1) {
while ((c = getopt(argc, argv, "n:k:h")) != -1) {
switch (c) {
case 'n':
size = atoi(optarg);
@ -96,10 +96,9 @@ static void parse_args(int argc, char **argv) {
kernel_file = optarg;
break;
case 'h':
case '?': {
show_usage();
exit(0);
} break;
break;
default:
show_usage();
exit(-1);