Skip to content

Commit

Permalink
swtpm: Join parameters for string formatting
Browse files Browse the repository at this point in the history
Since 'comma1' will always be true combine it with cmdarg_profile into one
string formatting parameter following the same formatting as further above.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Jul 23, 2024
1 parent 415700e commit 88a89f4
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/swtpm/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ int capabilities_print_json(bool cusetpm, TPMLIB_TPMVersion tpmversion)
char *keysizecaps = NULL;
const char *nvram_backend_dir = "\"nvram-backend-dir\", ";
const char *nvram_backend_file = "\"nvram-backend-file\"";
const char *cmdarg_profile = "\"cmdarg-profile\"";
g_autofree gchar *profiles = NULL;
bool comma1;

/* ignore errors */
TPMLIB_ChooseTPMVersion(tpmversion);
Expand All @@ -267,13 +265,11 @@ int capabilities_print_json(bool cusetpm, TPMLIB_TPMVersion tpmversion)
if (TPMLIB_ChooseTPMVersion(TPMLIB_TPM_VERSION_2) == TPM_SUCCESS)
with_tpm2 = "\"tpm-2.0\", ";

comma1 = cmdarg_profile || profiles;

n = asprintf(&string,
"{ "
"\"type\": \"swtpm\", "
"\"features\": [ "
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
" ], "
"\"profiles\": { %s}, "
"\"version\": \"" VERSION "\" "
Expand All @@ -293,8 +289,7 @@ int capabilities_print_json(bool cusetpm, TPMLIB_TPMVersion tpmversion)
nvram_backend_dir,
nvram_backend_file,
keysizecaps ? keysizecaps : "",
comma1 ? ", " : "",
cmdarg_profile ? cmdarg_profile : "",
true ? ", \"cmdarg-profile\"" : "",
profiles ? profiles : ""
);

Expand Down

0 comments on commit 88a89f4

Please sign in to comment.