lib: misc static analysis fixes
authorLuca BRUNO <luca.bruno@coreos.com>
Thu, 25 Nov 2021 15:04:09 +0000 (15:04 +0000)
committerLuca BRUNO <luca.bruno@coreos.com>
Fri, 26 Nov 2021 15:11:00 +0000 (15:11 +0000)
This fixes a few warnings from coverity, none of which really
interesting.

src/libostree/ostree-fetcher-curl.c
src/libostree/ostree-repo-commit.c
tests/test-commit-sign-sh-ext.c

index d6534b463ef1a004376022880e53115a1433f188..96f137dfc8c579485c21aed348ce77b26fb79b9e 100644 (file)
@@ -770,8 +770,8 @@ initiate_next_curl_request (FetcherRequest *req,
     curl_easy_setopt (req->easy, CURLOPT_URL, uri);
   }
 
-  curl_easy_setopt (req->easy, CURLOPT_USERAGENT,
-                    self->custom_user_agent ?: OSTREE_FETCHER_USERAGENT_STRING);
+  (void) curl_easy_setopt (req->easy, CURLOPT_USERAGENT,
+                           self->custom_user_agent ?: OSTREE_FETCHER_USERAGENT_STRING);
 
   /* Set caching request headers */
   if (req->if_none_match != NULL)
index 8ac963e746b44d77e51efebb9334b3737272563a..0e830a6fbde09574a8033db5e3f6245c5a880197 100644 (file)
@@ -1683,8 +1683,8 @@ ostree_repo_prepare_transaction (OstreeRepo     *self,
   /* Set up to abort the transaction if we return early from this function.
    * This needs to be manually built here due to a circular dependency. */
   g_autoptr(OstreeRepoAutoTransaction) txn = g_malloc(sizeof(OstreeRepoAutoTransaction));
+  g_assert (txn != NULL);
   txn->repo = self;
-  (void) txn; /* Add use to silence static analysis */
 
   memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));
 
index b5c5dcc65f8f9124a94a1cdc3914708ed3bc4402..173a0c6d4781961ca56c009ca18c08c25fd4949e 100644 (file)
@@ -44,6 +44,7 @@ corrupt (GBytes *input)
   g_assert_cmpint (len, >, 0);
   g_assert_cmpint (len, <, G_MAXINT);
   g_autofree char *newbuf = g_memdup (buf, len);
+  g_assert (newbuf != NULL);
   int o = g_random_int_range (0, len);
   newbuf[o] = (newbuf[0] + 1);