-
Notifications
You must be signed in to change notification settings - Fork 60
More static analysis issues fixes #1129
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
More static analysis issues fixes #1129
Conversation
Summary of ChangesHello @vojtechtrefny, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request continues the effort to resolve issues identified by static analysis, focusing on improving the robustness and maintainability of the codebase. It refactors error handling for file system unmount operations to ensure consistent behavior and better logging, and streamlines memory management within the LVM DBus plugin by adopting automatic resource deallocation, thereby removing redundant and potentially unreachable cleanup code. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request addresses issues found by static analysis. The changes in src/plugins/lvm/lvm-dbus.c correctly leverage g_autofree to simplify memory management and prevent potential leaks, which is a good improvement. The changes in src/plugins/fs/generic.c introduce a helper function to reduce code duplication for unmounting and also add checks for the return value of g_rmdir. However, I've found a few issues with the implementation in fs/generic.c: the logic for checking the g_rmdir return value is incorrect in two places, and there is a critical memory leak and an incorrect return type in an error handling path within btrfs_get_info.
f96a5f3 to
71422f2
Compare
|
/gemini review |
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.
Code Review
This pull request fixes issues found by static analysis. In src/plugins/fs/generic.c, the return value of g_rmdir is now checked, and duplicated unmount logic has been refactored into a new fs_unmount helper function. In src/plugins/lvm/lvm-dbus.c, memory management is simplified by using g_autofree, which removes the need for manual g_free calls. These changes improve code correctness and maintainability. I have one suggestion to further improve clarity in the new helper function.
71422f2 to
4e1ac41
Compare
|
/gemini review |
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.
Code Review
This pull request addresses several issues found by static analysis, improving code robustness and maintainability. The changes in src/plugins/fs/generic.c correctly handle the return value of g_rmdir and refactor duplicated unmount logic into a new helper function, which is a good improvement. However, I've identified a potential null pointer dereference in this new function. In src/plugins/lvm/lvm-dbus.c, the use of g_autofree and the removal of unreachable code are positive changes. I've added a couple of suggestions to further improve the code quality in that file. Overall, these are valuable fixes.
| g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UNMOUNT_FAIL, | ||
| "Failed to unmount '%s' after %s it: %s", | ||
| device, operation, local_error->message); |
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.
There's a potential NULL pointer dereference here. If bd_fs_unmount() returns FALSE but fails to set local_error (which would be a bug in bd_fs_unmount, but defensive coding is good practice), accessing local_error->message will cause a crash. It's safer to check if local_error is NULL before dereferencing it.
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UNMOUNT_FAIL,
"Failed to unmount '%s' after %s it: %s",
device, operation, local_error ? local_error->message : "Unknown error");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.
BS! There's the code style and a certain trust in the code.
| GVariant *ret = NULL; | ||
| gchar *obj_path = NULL; | ||
| gchar *task_path = NULL; | ||
| g_autofree gchar *task_path = NULL; |
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.
Second batch of issues found by static analysis -- unreachable code in LVM DBus and checked return in FS plugin.
4e1ac41 to
6489761
Compare
| g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_UNMOUNT_FAIL, | ||
| "Failed to unmount '%s' after %s it: %s", | ||
| device, operation, local_error->message); |
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.
BS! There's the code style and a certain trust in the code.
13b8f1f
into
storaged-project:master
Second batch of issues found by static analysis -- unreachable code in LVM DBus and checked return in FS plugin.