]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: initialize a couple of values explicitly
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 4 Jan 2024 16:50:13 +0000 (17:50 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 4 Jan 2024 19:57:03 +0000 (20:57 +0100)
As gcc has trouble figuring this itself with -O2 and -Wmaybe-initialized.

src/libsystemd/sd-journal/journal-file.c
src/login/logind.c
src/shared/pkcs11-util.c
src/shared/tpm2-util.c

index 5e6ff66e3c5732814a734f8043d66f79fbcd4889..c9ff6abca657330d95c27b347dd0d1bdc8ff6074 100644 (file)
@@ -2757,7 +2757,7 @@ static int generic_array_get(
                 Object **ret_object,    /* The found object. */
                 uint64_t *ret_offset) { /* The offset of the found object. */
 
-        uint64_t a, t = 0, k;
+        uint64_t a, t = 0, k = 0; /* Explicit initialization of k to appease gcc */
         ChainCacheItem *ci;
         Object *o = NULL;
         int r;
index 030f65da088a32411daa2962dd0bf62dfc738ddb..4dd89288e706c9be7086a63405263315d7e7c238 100644 (file)
@@ -470,7 +470,7 @@ static int deliver_session_leader_fd_consume(Session *s, const char *fdname, int
 
 static int manager_attach_session_fd_one_consume(Manager *m, const char *fdname, int fd) {
         _cleanup_free_ char *id = NULL;
-        dev_t devno;
+        dev_t devno = 0; /* Explicit initialization to appease gcc */
         Session *s;
         int r;
 
index 9792f70d42202624eca85fc1eee1abe0afa339f0..3ff2e92b01e85bd5795625af0074a0a09f825493 100644 (file)
@@ -948,7 +948,7 @@ static int pkcs11_token_decrypt_data_ecc(
                 if (mechanism_info.flags & CKF_EC_COMPRESS) {
 #if HAVE_OPENSSL
                         log_debug("CKM_ECDH1_DERIVE accepts compressed EC points only, trying to convert.");
-                        size_t compressed_point_size;
+                        size_t compressed_point_size = 0; /* Explicit initialization to appease gcc */
                         r = ecc_convert_to_compressed(m, session, object, encrypted_data, encrypted_data_size, &compressed_point, &compressed_point_size);
                         if (r < 0)
                                 return r;
index 8c683254a2a7098cfacc99aab6952425cea8f2c2..068921a84c668b044913386fb41f3877216e1660 100644 (file)
@@ -5007,7 +5007,7 @@ static int tpm2_calculate_seal_ecc_seed(
         size_t bits = (size_t) r * 8;
 
         _cleanup_free_ void *seed = NULL;
-        size_t seed_size;
+        size_t seed_size = 0; /* Explicit initialization to appease gcc */
         r = tpm2_kdfe(parent->publicArea.nameAlg,
                       shared_secret,
                       shared_secret_size,
@@ -5044,7 +5044,7 @@ static int tpm2_calculate_seal_seed(
         log_debug("Calculating encrypted seed for sealed object.");
 
         _cleanup_free_ void *seed = NULL, *encrypted_seed = NULL;
-        size_t seed_size, encrypted_seed_size;
+        size_t seed_size = 0, encrypted_seed_size = 0; /* Explicit initialization to appease gcc */
         if (parent->publicArea.type == TPM2_ALG_RSA)
                 r = tpm2_calculate_seal_rsa_seed(parent, &seed, &seed_size, &encrypted_seed, &encrypted_seed_size);
         else if (parent->publicArea.type == TPM2_ALG_ECC)