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:
parent
b8d5744c6e
commit
d65a428f2d
@ -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 *dev_add_wwid(char *id, int id_type, struct dm_list *ids)
|
||||||
{
|
{
|
||||||
struct dev_wwid *dw;
|
struct dev_wwid *dw;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!id_type)
|
if (!id_type)
|
||||||
id_type = _wwid_type_num(id);
|
id_type = _wwid_type_num(id);
|
||||||
|
|
||||||
if (!(dw = zalloc(sizeof(struct dev_wwid))))
|
if (!(dw = zalloc(sizeof(*dw))))
|
||||||
return NULL;
|
return_NULL;
|
||||||
len = strlen(id);
|
(void)dm_strncpy(dw->id, id, sizeof(dw->id));
|
||||||
if (len >= DEV_WWID_SIZE)
|
|
||||||
len = DEV_WWID_SIZE - 1;
|
|
||||||
memcpy(dw->id, id, len);
|
|
||||||
dw->type = id_type;
|
dw->type = id_type;
|
||||||
dm_list_add(ids, &dw->list);
|
dm_list_add(ids, &dw->list);
|
||||||
return dw;
|
return dw;
|
||||||
|
Loading…
Reference in New Issue
Block a user