Simplify the error handling for missing actions.
This commit is contained in:
parent
dc830434bf
commit
c5cc730fb8
37
p1load.c
37
p1load.c
@ -168,27 +168,26 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file || terminalMode) {
|
/* complain about nothing to do */
|
||||||
switch (InitPort(&state, PORT_PREFIX, port, baudRate, verbose, actualPort)) {
|
if (!file && !terminalMode) {
|
||||||
case CHECK_PORT_OK:
|
printf("error: must specify either a file to load or -t\n");
|
||||||
printf("Found propeller version %d on %s\n", state.version, actualPort);
|
return 1;
|
||||||
break;
|
|
||||||
case CHECK_PORT_OPEN_FAILED:
|
|
||||||
printf("error: opening serial port '%s'\n", port);
|
|
||||||
perror("Error is ");
|
|
||||||
return 1;
|
|
||||||
case CHECK_PORT_NO_PROPELLER:
|
|
||||||
if (port)
|
|
||||||
printf("error: no propeller chip on port '%s'\n", port);
|
|
||||||
else
|
|
||||||
printf("error: can't find a port with a propeller chip\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complain about nothing to do */
|
/* open the serial port */
|
||||||
else {
|
switch (InitPort(&state, PORT_PREFIX, port, baudRate, verbose, actualPort)) {
|
||||||
printf("error: must specify either a file to load or -t\n");
|
case CHECK_PORT_OK:
|
||||||
|
printf("Found propeller version %d on %s\n", state.version, actualPort);
|
||||||
|
break;
|
||||||
|
case CHECK_PORT_OPEN_FAILED:
|
||||||
|
printf("error: opening serial port '%s'\n", port);
|
||||||
|
perror("Error is ");
|
||||||
|
return 1;
|
||||||
|
case CHECK_PORT_NO_PROPELLER:
|
||||||
|
if (port)
|
||||||
|
printf("error: no propeller chip on port '%s'\n", port);
|
||||||
|
else
|
||||||
|
printf("error: can't find a port with a propeller chip\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user