Skip to content
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

2023.6 coverity minor fixes #3013

Merged
merged 4 commits into from
Aug 26, 2023
Merged

Conversation

cgwalters
Copy link
Member

switchroot: Lower config parser to otcore, add unit tests

Part of the continuation of unit testing coverage.


commit: Drop dead code

Coverity points out that since we're now always initializing
metadata, the create_empty_gvariant_dict() is unreachable.


sign/ed25519: Fix two memory leaks

Spotted by coverity.


switchroot: Use g_new/g_free consistently

Coverity complains about this, even though they're the same thing.


Part of the continuation of unit testing coverage.
Coverity points out that since we're now *always* initializing
metadata, the `create_empty_gvariant_dict()` is unreachable.
Coverity complains about this, even though they're the same thing.
@@ -415,17 +415,18 @@ ostree_sign_ed25519_add_pk (OstreeSign *self, GVariant *public_key, GError **err
if (!_ostree_sign_ed25519_is_initialized (sign, error))
return FALSE;

gpointer key = NULL;
g_autofree guint8 *key_owned = NULL;
const guint8 *key = NULL;
Copy link
Collaborator

@ericcurtin ericcurtin Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

g_autofree const guint8 *key = NULL;

key_owned is unused, just set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because g_variant_get_fixed_array() returns a const pointer into its data, whereas g_base64_decode returns a new value. Notice that we do set key_owned only in the latter case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, so you want it free'd at the end of scope in one case but not the other... Makes sense

Copy link
Collaborator

@ericcurtin ericcurtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cgwalters cgwalters merged commit f8549a9 into ostreedev:main Aug 26, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants