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

gcc: clear some complains

Use dm_strncpy() were possible to get rid of gcc compile warnings.
This commit is contained in:
Zdenek Kabelac 2024-04-08 14:10:18 +02:00
parent aae27f6be6
commit d490572410
5 changed files with 13 additions and 14 deletions

View File

@ -2984,10 +2984,10 @@ static int add_lockspace_thread(const char *ls_name,
strncpy(ls->vg_uuid, vg_uuid, 64);
if (vg_name)
strncpy(ls->vg_name, vg_name, MAX_NAME);
dm_strncpy(ls->vg_name, vg_name, sizeof(ls->vg_name));
if (vg_args)
strncpy(ls->vg_args, vg_args, MAX_ARGS);
dm_strncpy(ls->vg_args, vg_args, sizeof(ls->vg_args));
if (act)
ls->host_id = act->host_id;
@ -4906,13 +4906,13 @@ static void client_recv_action(struct client *cl)
act->path = strdup(path);
if (vg_name && strcmp(vg_name, "none"))
strncpy(act->vg_name, vg_name, MAX_NAME);
dm_strncpy(act->vg_name, vg_name, sizeof(act->vg_name));
if (vg_uuid && strcmp(vg_uuid, "none"))
strncpy(act->vg_uuid, vg_uuid, 64);
if (vg_sysid && strcmp(vg_sysid, "none"))
strncpy(act->vg_sysid, vg_sysid, MAX_NAME);
dm_strncpy(act->vg_sysid, vg_sysid, sizeof(act->vg_sysid));
str = daemon_request_str(req, "lv_name", NULL);
if (str && strcmp(str, "none"))
@ -5627,7 +5627,7 @@ static void adopt_locks(void)
act->rt = LD_RT_VG;
act->lm_type = ls->lm_type;
act->client_id = INTERNAL_CLIENT_ID;
strncpy(act->vg_name, ls->vg_name, MAX_NAME);
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
memcpy(act->vg_uuid, ls->vg_uuid, 64);
memcpy(act->vg_args, ls->vg_args, MAX_ARGS);
act->host_id = ls->host_id;

View File

@ -1339,7 +1339,7 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
struct stat st;
struct lm_sanlock *lms = NULL;
char lock_lv_name[MAX_ARGS+1];
char lsname[SANLK_NAME_LEN + 1];
char lsname[SANLK_NAME_LEN + 1] = { 0 };
char disk_path[SANLK_PATH_LEN];
char killpath[SANLK_PATH_LEN];
char killargs[SANLK_PATH_LEN];
@ -1420,8 +1420,7 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
goto fail;
}
memset(lsname, 0, sizeof(lsname));
strncpy(lsname, ls->name, SANLK_NAME_LEN);
dm_strncpy(lsname, ls->name, sizeof(lsname));
memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);
lms->ss.host_id_disk.offset = 0;

View File

@ -598,7 +598,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char *default_uuid_prefix;
size_t default_uuid_prefix_len;
const char *suffix, *suffix_position;
char uuid_without_suffix[DM_UUID_LEN];
char uuid_without_suffix[DM_UUID_LEN + 1];
unsigned i = 0;
const char **suffix_list = dtree->optional_uuid_suffixes;
@ -612,7 +612,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
if (strcmp(suffix_position + 1, suffix))
continue;
(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
dm_strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
uuid_without_suffix[suffix_position - uuid] = '\0';
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {

View File

@ -432,9 +432,9 @@ int get_pvs_lookup(struct dm_list *pvs_online, const char *vgname)
if (file_major || file_minor)
po->devno = MKDEV(file_major, file_minor);
if (file_vgname[0])
strncpy(po->vgname, file_vgname, NAME_LEN-1);
dm_strncpy(po->vgname, file_vgname, sizeof(po->vgname));
if (file_devname[0])
strncpy(po->devname, file_devname, NAME_LEN-1);
dm_strncpy(po->devname, file_devname, sizeof(po->devname));
log_debug("Found PV online lookup %s for VG %s on %s.", path, vgname, file_devname);
dm_list_add(pvs_online, &po->list);

View File

@ -558,7 +558,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char *default_uuid_prefix;
size_t default_uuid_prefix_len;
const char *suffix, *suffix_position;
char uuid_without_suffix[DM_UUID_LEN];
char uuid_without_suffix[DM_UUID_LEN + 1];
unsigned i = 0;
const char **suffix_list = dtree->optional_uuid_suffixes;
@ -572,7 +572,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
if (strcmp(suffix_position + 1, suffix))
continue;
(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
dm_strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
uuid_without_suffix[suffix_position - uuid] = '\0';
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {