-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ksmbd-tools: handle unset ret #323
base: master
Are you sure you want to change the base?
Conversation
If g_mapped_file_get_length returns 0 or SIZE_MAX, the loop does not get executed and ret does not get set Move the assignment out of the loop and change to while loop. Found with GCC's -fanalyzer. Signed-off-by: Rosen Penev <[email protected]>
I assume CI fails now because ubuntu-latest was recently updated. |
len = g_mapped_file_get_length(file); | ||
if (len == 0 || len == SIZE_MAX) { | ||
ret = -EINVAL; | ||
goto out_close; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g_mapped_file_unref() is not called on error handling ?. So, should we use goto out_unref instead of out_close ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes you're right. copy/paste mistake looks like.
The purpose of the
Note that diff --git a/tools/config_parser.c b/tools/config_parser.c
index b890b96..0040061 100644
--- a/tools/config_parser.c
+++ b/tools/config_parser.c
@@ -238,7 +238,7 @@ static int __mmap_parse_file(const char *path, process_entry_fn *process_entry)
goto out_unref;
}
- for (len = g_mapped_file_get_length(file);
+ for (ret = -EINVAL, len = g_mapped_file_get_length(file);
len > 0 && len != (size_t)-1;
len -= delim - contents + 1, contents = delim + 1) {
g_autofree char *entry = NULL;
|
If g_mapped_file_get_length returns 0 or SIZE_MAX, the loop does not get executed and ret does not get set
Move the assignment out of the loop and change to while loop.
Found with GCC's -fanalyzer.