xgetXXbyYY: Improve error handling#729
Conversation
ferivoz
commented
May 15, 2023
- Treat another out of memory condition and fail with exit(13) consistently within the file.
- Avoid duplicated code in error handling
A failure of DUP_FUNCTION is already handled for non-reentrant function wrapper. Perform the check for reentrant version as well. Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
The error handling is performed after the loop. By just calling break it is possible to reuse the error handling if status is not ERANGE. Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
|
Hi, what do you think about this instead? : |
|
(The reason for my suggestion is that IMO it simplifies the success and failure exit cases) |
|
In general I would agree but one commit is about unifying the error handling between reentrant and non-reentrant versions (the else block of the preprocessor if). If we use your code, we should do the same in the else block, i.e. no exit if memory exhaustion occurred. Do you want me to modify that code as well? Or do you prefer the exit version in this pull request? |
yeah, you're right, if we run out of memory we should exit, no sense going on after that. |
|
Jinkey, the codeql job is pretty fragile |
| LOOKUP_TYPE *ret_result = DUP_FUNCTION(result); | ||
| if (NULL == result) { | ||
| fprintf (log_get_logfd(), | ||
| _("%s: out of memory\n"), | ||
| "x" STRINGIZE(FUNCTION_NAME)); | ||
| exit (13); | ||
| } |
There was a problem hiding this comment.
This looks like a typo in the NULL check. You probably meant ret_result == NULL, right?
It seems obvious that it was a typo. Link: <shadow-maint#729 (comment)> Fixes: e73a219 ("xgetXXbyYY: Handle DUP_FUNCTION failure") Cc: Samanta Navarro <ferivoz@riseup.net> Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
It seems obvious that it was a typo. Link: <#729 (comment)> Fixes: e73a219 ("xgetXXbyYY: Handle DUP_FUNCTION failure") Cc: Samanta Navarro <ferivoz@riseup.net> Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>