From 2c4ee52a948a9ccff2242cd02ac8ce81a0559deb Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Tue, 26 Mar 2024 12:13:55 -0400 Subject: [PATCH] Fix a couple small static analysis findings for uninitialized structs The memset() on the KeyValue is more explicit even though if you trace the code you will see it fills out the struct. However, it's possible that not every struct member will be initialized and adding the memset() makes things more obvious and appeases the static analyzer. The queue_init() appeared to just be missing. --- ext/repo_rpmmd.c | 2 ++ ext/repo_susetags.c | 1 + ext/testcase.c | 1 + 3 files changed, 4 insertions(+) diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c index 1232e433..5d0f5fe7 100644 --- a/ext/repo_rpmmd.c +++ b/ext/repo_rpmmd.c @@ -609,6 +609,8 @@ fill_cshash_from_new_solvables(struct parsedata *pd) KeyValue kv; Repokey *key; + memset(&kv, 0, sizeof(kv)); + for (i = pd->first; i < pool->nsolvables; i++) { if (pool->solvables[i].repo != pd->repo) diff --git a/ext/repo_susetags.c b/ext/repo_susetags.c index dc60aa49..544974be 100644 --- a/ext/repo_susetags.c +++ b/ext/repo_susetags.c @@ -339,6 +339,7 @@ lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized if (uninternalized) { KeyValue kv; + memset(&kv, 0, sizeof(kv)); Repokey *key = repodata_lookup_kv_uninternalized(data, p, keyname, &kv); if (!key) return 0; diff --git a/ext/testcase.c b/ext/testcase.c index f46f738d..7b6179b5 100644 --- a/ext/testcase.c +++ b/ext/testcase.c @@ -1497,6 +1497,7 @@ testcase_solverresult(Solver *solv, int resultflags) if ((resultflags & TESTCASE_RESULT_USERINSTALLED) != 0) { Queue q; + queue_init(&q); solver_get_userinstalled(solv, &q, 0); for (i = 0; i < q.count; i++) { -- 2.47.2