1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

device_id: use dm_strncpy

Simplify code.
This commit is contained in:
Zdenek Kabelac 2024-03-29 22:43:48 +01:00
parent b8d5744c6e
commit d65a428f2d

View File

@ -620,17 +620,13 @@ void free_wwids(struct dm_list *ids)
struct dev_wwid *dev_add_wwid(char *id, int id_type, struct dm_list *ids)
{
struct dev_wwid *dw;
int len;
if (!id_type)
id_type = _wwid_type_num(id);
if (!(dw = zalloc(sizeof(struct dev_wwid))))
return NULL;
len = strlen(id);
if (len >= DEV_WWID_SIZE)
len = DEV_WWID_SIZE - 1;
memcpy(dw->id, id, len);
if (!(dw = zalloc(sizeof(*dw))))
return_NULL;
(void)dm_strncpy(dw->id, id, sizeof(dw->id));
dw->type = id_type;
dm_list_add(ids, &dw->list);
return dw;