summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-10-15 15:00:03 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2021-10-15 23:40:56 +0200
commitc2be6c38d5d878861b7d4ce601a64bcb88bbe38e (patch)
treee003c059fcce589209ec68edf7f689656bd94c1a
parent882141eb8c1a9718652cd903e411b6876aff54ef (diff)
downloadlvm2-c2be6c38d5d878861b7d4ce601a64bcb88bbe38e.tar.gz
cov: ensure id is always initialize
Always resed sd_id128_t id and report warning in case sd_id128_get_machine_app_specific() does not exit with 0.
-rw-r--r--lib/commands/toolcontext.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index ab574fb55..105aecd5d 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -159,9 +159,11 @@ static const char *_system_id_from_source(struct cmd_context *cmd, const char *s
#ifdef APP_MACHINEID_SUPPORT
if (!strcasecmp(source, "appmachineid")) {
- sd_id128_t id;
+ sd_id128_t id = { 0 };
- sd_id128_get_machine_app_specific(LVM_APPLICATION_ID, &id);
+ if (sd_id128_get_machine_app_specific(LVM_APPLICATION_ID, &id) != 0)
+ log_warn("WARNING: sd_id128_get_machine_app_specific() failed %s (%d).",
+ strerror(errno), errno);
if (dm_snprintf(buf, PATH_MAX, SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(id)) < 0)
stack;