Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jluebbe
Copy link
Member

@jluebbe jluebbe commented Jun 26, 2025

No description provided.

Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 87.23404% with 12 lines in your changes missing coverage. Please review.

Project coverage is 84.54%. Comparing base (9c5cd7b) to head (75cf16a).

Files with missing lines Patch % Lines
src/bundle.c 83.82% 11 Missing ⚠️
src/utils.c 85.71% 1 Missing ⚠️
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     
Flag Coverage Δ
service=false 81.04% <87.09%> (+0.03%) ⬆️
service=true 84.50% <87.23%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@ejoerns ejoerns left a 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);
Copy link
Member

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..

Copy link
Member Author

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.

Copy link
Member

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. 😏 )

jluebbe added 4 commits June 26, 2025 14:42
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>
@jluebbe jluebbe requested a review from ejoerns June 26, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants