]> git.proxmox.com Git - swtpm.git/commitdiff
swtpm_setup: Initialize variables to avoid compiler warnings
authorStefan Berger <stefanb@linux.ibm.com>
Fri, 15 Oct 2021 11:44:53 +0000 (07:44 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Fri, 15 Oct 2021 12:44:14 +0000 (08:44 -0400)
Fix issue #591 by initializing the variables swtpm_has_tpm2 and
swtpm_has_tpm12.

swtpm_setup.c:1178:31: note: 'swtpm_has_tpm2' was declared here
     gboolean swtpm_has_tpm12, swtpm_has_tpm2;
                               ^~~~~~~~~~~~~~
swtpm_setup.c:1019:5: error: 'swtpm_has_tpm12' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     printf("{ \"type\": \"swtpm_setup\", "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            "\"features\": [ %s%s\"cmdarg-keyfile-fd\", \"cmdarg-pwdfile-fd\", \"tpm12-not-need-root\""

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
src/swtpm_setup/swtpm_setup.c

index d750f8be0d27a08696531f7a22670021cc8eb83e..9e5563168214e7a39b2e43c25a9e65534824379a 100644 (file)
@@ -1175,7 +1175,8 @@ int main(int argc, char *argv[])
     const struct passwd *curr_user;
     struct group *curr_grp;
     char *endptr;
-    gboolean swtpm_has_tpm12, swtpm_has_tpm2;
+    gboolean swtpm_has_tpm12 = FALSE;
+    gboolean swtpm_has_tpm2 = FALSE;
     int fds_to_pass[1] = { -1 };
     unsigned n_fds_to_pass = 0;
     char tmpbuffer[200];