mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
coverity: missing check for id_write_format return value
This commit is contained in:
parent
5b3a4a9595
commit
48877e215d
@ -75,7 +75,10 @@ int scan(daemon_handle h, char *fn) {
|
||||
}
|
||||
|
||||
char uuid[64];
|
||||
id_write_format(dev->pvid, uuid, 64);
|
||||
if (!id_write_format(dev->pvid, uuid, 64)) {
|
||||
fprintf(stderr, "[C] Failed to format PV UUID for %s", dev_name(dev));
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "[C] found PV: %s\n", uuid);
|
||||
struct lvmcache_info *info = (struct lvmcache_info *) label->info;
|
||||
struct physical_volume pv = { 0, };
|
||||
|
6
lib/cache/lvmcache.c
vendored
6
lib/cache/lvmcache.c
vendored
@ -995,7 +995,8 @@ next:
|
||||
alt = devl;
|
||||
}
|
||||
|
||||
id_write_format((const struct id *)dev1->pvid, uuid, sizeof(uuid));
|
||||
if (!id_write_format((const struct id *)dev1->pvid, uuid, sizeof(uuid)))
|
||||
stack;
|
||||
log_warn("WARNING: PV %s prefers device %s because %s.", uuid, dev_name(dev1), reason);
|
||||
}
|
||||
|
||||
@ -2066,7 +2067,8 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller,
|
||||
|
||||
strncpy(pvid_s, pvid, sizeof(pvid_s) - 1);
|
||||
pvid_s[sizeof(pvid_s) - 1] = '\0';
|
||||
id_write_format((const struct id *)&pvid_s, uuid, sizeof(uuid));
|
||||
if (!id_write_format((const struct id *)&pvid_s, uuid, sizeof(uuid)))
|
||||
stack;
|
||||
|
||||
/*
|
||||
* Find existing info struct in _pvid_hash or create a new one.
|
||||
|
@ -60,7 +60,8 @@ static void _add_pl_to_list(struct cmd_context *cmd, struct dm_list *head, struc
|
||||
if (id_equal(&data->pv_uuid, &pl->pv_uuid)) {
|
||||
char uuid[ID_LEN + 7] __attribute__((aligned(8)));
|
||||
|
||||
id_write_format(&pl->pv_uuid, uuid, ID_LEN + 7);
|
||||
if (!id_write_format(&pl->pv_uuid, uuid, ID_LEN + 7))
|
||||
stack;
|
||||
|
||||
if (!dev_subsystem_part_major(cmd->dev_types, data->dev)) {
|
||||
log_very_verbose("Ignoring duplicate PV %s on "
|
||||
@ -90,11 +91,13 @@ int read_pool_label(struct pool_list *pl, struct labeller *l,
|
||||
pool_label_in(pd, buf);
|
||||
|
||||
get_pool_pv_uuid(&pvid, pd);
|
||||
id_write_format(&pvid, uuid, ID_LEN + 7);
|
||||
if (!id_write_format(&pvid, uuid, ID_LEN + 7))
|
||||
stack;
|
||||
log_debug_metadata("Calculated uuid %s for %s", uuid, dev_name(dev));
|
||||
|
||||
get_pool_vg_uuid(&vgid, pd);
|
||||
id_write_format(&vgid, uuid, ID_LEN + 7);
|
||||
if (!id_write_format(&vgid, uuid, ID_LEN + 7))
|
||||
stack;
|
||||
log_debug_metadata("Calculated uuid %s for %s", uuid, pd->pl_pool_name);
|
||||
|
||||
if (!(info = lvmcache_add(l, (char *) &pvid, dev, pd->pl_pool_name,
|
||||
|
@ -171,6 +171,8 @@ int id_write_format(const struct id *id, char *buffer, size_t size)
|
||||
|
||||
/* split into groups separated by dashes */
|
||||
if (size < (32 + 6 + 1)) {
|
||||
if (size > 0)
|
||||
buffer[0] = '\0';
|
||||
log_error("Couldn't write uuid, buffer too small.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1858,8 +1858,8 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t read_flags,
|
||||
skip = 0;
|
||||
notfound = 0;
|
||||
|
||||
if (vg_uuid)
|
||||
id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid));
|
||||
if (vg_uuid && !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid)))
|
||||
stack;
|
||||
|
||||
log_very_verbose("Processing VG %s %s", vg_name, vg_uuid ? uuid : "");
|
||||
|
||||
@ -1954,7 +1954,8 @@ static int _resolve_duplicate_vgnames(struct cmd_context *cmd,
|
||||
* name/vgid and checks system_id in the metadata.
|
||||
*/
|
||||
if (lvmcache_vg_is_foreign(cmd, vgnl->vg_name, vgnl->vgid)) {
|
||||
id_write_format((const struct id*)vgnl->vgid, uuid, sizeof(uuid));
|
||||
if (!id_write_format((const struct id*)vgnl->vgid, uuid, sizeof(uuid)))
|
||||
stack;
|
||||
log_warn("WARNING: Ignoring foreign VG with matching name %s UUID %s.",
|
||||
vgnl->vg_name, uuid);
|
||||
dm_list_del(&vgnl->list);
|
||||
@ -2659,8 +2660,8 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t read_flag
|
||||
}
|
||||
}
|
||||
|
||||
if (vg_uuid)
|
||||
id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid));
|
||||
if (vg_uuid && !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid)))
|
||||
stack;
|
||||
|
||||
log_very_verbose("Processing VG %s %s", vg_name, vg_uuid ? uuid : "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user