mirror of https://github.com/nirenjan/libx52.git
Fix error reporting in x52cli
Prior to this change, x52cli assumed that the return code from the handler was a standard error code, but negated. This is an incorrect assumption as the libx52 API returns a `libx52_error_code` enum, which is a positive integer. This change fixes the printing of the error message to call `libx52_strerror`, which translates it correctly. It also adds error printing to any failure of `libx52_init`, as well as explicitly specifying `LIBX52_SUCCESS` instead of `0`. Addresses #19.debian-packaging
parent
665dba187d
commit
16b4ad693b
|
@ -378,13 +378,13 @@ int main(int argc, char **argv)
|
|||
rc = libx52_init(&x52);
|
||||
|
||||
if (rc != LIBX52_SUCCESS) {
|
||||
fprintf(stderr, "Unable to find X52 joystick!\n");
|
||||
fprintf(stderr, "Error initializing X52 joystick: %s\n", libx52_strerror(rc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = (*(cmd->handler))(x52, args);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "Error: %s\n", strerror(-rc));
|
||||
if (rc != LIBX52_SUCCESS) {
|
||||
fprintf(stderr, "Error: %s\n", libx52_strerror(rc));
|
||||
}
|
||||
|
||||
libx52_update(x52);
|
||||
|
|
Loading…
Reference in New Issue