-
Notifications
You must be signed in to change notification settings - Fork 231
src/bundle: add g_auto-based helper for temporary files and use it to simplify control flow #1746
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1746 +/- ##
==========================================
+ Coverage 84.51% 84.54% +0.03%
==========================================
Files 76 76
Lines 22385 22357 -28
==========================================
- Hits 18918 18902 -16
+ Misses 3467 3455 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Looks like a good simplification of the code 👍
@@ -1273,6 +1251,8 @@ gboolean create_bundle(const gchar *bundlename, const gchar *contentdir, GError | |||
return FALSE; | |||
} | |||
|
|||
g_auto(RTempFile) bundletmp = g_strdup(bundlename); |
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.
Not sure if defining bundletmp
here isn't too confusing if we continue using bundlename
for writing..
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.
This is just to keep the resource open, so we keep the existing code the same.
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.
It's clear to me what the intention is.
Exactly because it has no other meaning than implicit refcounting, I say this might be confusing. At least when reading this out of this PRs context.
I'd be fine with a comment. (As you already did for the g_clear_pointer()
calls, where you already seemed to have the impression that this might be too implicit. 😏 )
In several places, removing an output file on error is the only reason why we still use 'goto out'. So, add a helper to handle this via g_auto. If the file should not be removed simply use g_clear_pointer(&filename, g_free), so that the cleanup is not triggered. Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
This only moves the declarations and no behaviour change is intended. Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
No description provided.