]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Fix a couple small static analysis findings for uninitialized structs 557/head
authorDavid Cantrell <dcantrell@redhat.com>
Tue, 26 Mar 2024 16:13:55 +0000 (12:13 -0400)
committerDavid Cantrell <dcantrell@redhat.com>
Tue, 26 Mar 2024 16:13:55 +0000 (12:13 -0400)
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
ext/repo_susetags.c
ext/testcase.c

index 1232e4337cfa04d6dad4e3323d164e1c5a6d7990..5d0f5fe7deab3bc61e97031ae92b1d832b5763cb 100644 (file)
@@ -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)
index dc60aa49ca47bb17eadae1bc80e1e98271370f87..544974be5cc7747065cee172dc03ff4eebe1c334 100644 (file)
@@ -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;
index f46f738d3f57a7a3e59e38c3909279bd574b148f..7b6179b5d13df3b83f73c946dc7a16bd4435f0e9 100644 (file)
@@ -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++)
        {