Add error return codes to libcare-ctl.#40
Add error return codes to libcare-ctl.#40rashchupkinr wants to merge 1 commit intocloudlinux:masterfrom
Conversation
src/kpatch_user.c
Outdated
| ret = -1; | ||
| if (rv == -2) | ||
| ret = rv; | ||
| if (rv == -2) { |
There was a problem hiding this comment.
rv=-1 is used to indicate that we found what we have been looking for. Please rename that to some define or constant and restore the old behavior.
| */ | ||
| ret = object_unapply_patch(o, /* check_flag */ 1); | ||
| if (ret < 0) { | ||
| if (object_unapply_patch(o, /* check_flag */ 1) < 0) { |
There was a problem hiding this comment.
Please, don't hesitate to use more lines. There is no need to short it like this, let's keep the code a single statement a line and let compiler do its job.
There was a problem hiding this comment.
This way value of 'ret' is not changed if object_unapply_patch was successful, and error code from object_apply_patch is returned. If object_unapply_patch returns error, ERROR_PATCH_UNPATCH will be returned to notify user.
src/kpatch_log.h
Outdated
| #include <stdio.h> | ||
|
|
||
| #define ERROR_SUCCESS 0 // exit code 0 | ||
| #define ERROR_GENERAL -255 // exit code 1 |
There was a problem hiding this comment.
Let's introduce a macro named ERR_CODE(x) (x - 256).
and use it here. For instance:
#define ERROR_GENERAL ERR_CODE(1) /* general error */
| if (ret == 0) { | ||
| ret = kpatch_process_attach(o->proc); | ||
| if (ret == ERROR_ACCESS) | ||
| return ret; |
src/kpatch_log.h
Outdated
| #define ERROR_NOPATCH -251 // exit code 5 | ||
| #define ERROR_PATCH -250 // exit code 6 | ||
| #define ERROR_UNPATCH -249 // exit code 7 | ||
| #define ERROR_PATCH_UNPATCH -248 // exit code 8 |
There was a problem hiding this comment.
This name is ambiguous. Please provide comments for all the error codes as shown above. We will later include these into man page.
src/kpatch_user.c
Outdated
| break; | ||
| case 'h': | ||
| return usage(NULL); | ||
| return usage(ERROR_SUCCESS); |
There was a problem hiding this comment.
The NULL here is the message usage should print.
fb4cd74 to
52cd14b
Compare
No description provided.