mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
refactor: remove (void) from dm_strncpy usage
Start to use dm_strncpy() as unchecked version within source tree.
This commit is contained in:
parent
295e632e81
commit
995ff58903
@ -1634,7 +1634,7 @@ int create_cluster_cpg(char *uuid, uint64_t luid)
|
|||||||
|
|
||||||
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
|
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
|
||||||
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
|
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
|
||||||
(void) dm_strncpy(new->name.value, uuid, size);
|
dm_strncpy(new->name.value, uuid, size);
|
||||||
new->name.length = (uint32_t)size;
|
new->name.length = (uint32_t)size;
|
||||||
new->luid = luid;
|
new->luid = luid;
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ int driver_version(char *version, size_t size)
|
|||||||
!dm_driver_version(_vsn, sizeof(_vsn)))
|
!dm_driver_version(_vsn, sizeof(_vsn)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
(void) dm_strncpy(version, _vsn, size);
|
dm_strncpy(version, _vsn, size);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ static int _info(struct cmd_context *cmd,
|
|||||||
if (strcmp(suffix_position + 1, suffix))
|
if (strcmp(suffix_position + 1, suffix))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(void) dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
||||||
if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
|
if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
|
||||||
name_check, with_open_count, with_read_ahead,
|
name_check, with_open_count, with_read_ahead,
|
||||||
0, 0))
|
0, 0))
|
||||||
@ -2315,7 +2315,7 @@ static int _check_holder(struct dev_manager *dm, struct dm_tree *dtree,
|
|||||||
if (!memcmp(uuid, &lv->vg->id, ID_LEN) &&
|
if (!memcmp(uuid, &lv->vg->id, ID_LEN) &&
|
||||||
!dm_tree_find_node_by_uuid(dtree, uuid)) {
|
!dm_tree_find_node_by_uuid(dtree, uuid)) {
|
||||||
/* trims any UUID suffix (i.e. -cow) */
|
/* trims any UUID suffix (i.e. -cow) */
|
||||||
(void) dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
|
dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
|
||||||
|
|
||||||
/* If UUID is not yet in dtree, look for matching LV */
|
/* If UUID is not yet in dtree, look for matching LV */
|
||||||
if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, &id))) {
|
if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, &id))) {
|
||||||
|
@ -252,7 +252,7 @@ static void _get_sysfs_dir(struct cmd_context *cmd, char *buf, size_t buf_size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) dm_strncpy(buf, sys_mnt, buf_size);
|
dm_strncpy(buf, sys_mnt, buf_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t _parse_debug_fields(struct cmd_context *cmd, int cfg, const char *cfgname)
|
static uint32_t _parse_debug_fields(struct cmd_context *cmd, int cfg, const char *cfgname)
|
||||||
|
@ -283,8 +283,8 @@ static int _compare_paths(const char *path0, const char *path1)
|
|||||||
if (slash1 < slash0)
|
if (slash1 < slash0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
(void) dm_strncpy(p0, path0, sizeof(p0));
|
dm_strncpy(p0, path0, sizeof(p0));
|
||||||
(void) dm_strncpy(p1, path1, sizeof(p1));
|
dm_strncpy(p1, path1, sizeof(p1));
|
||||||
s0 = p0 + 1;
|
s0 = p0 + 1;
|
||||||
s1 = p1 + 1;
|
s1 = p1 + 1;
|
||||||
|
|
||||||
@ -1810,7 +1810,7 @@ static int _setup_devices_file_dmeventd(struct cmd_context *cmd)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cmd->enable_devices_file = 1;
|
cmd->enable_devices_file = 1;
|
||||||
(void) dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path));
|
dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ char *strdup_pvid(char *pvid)
|
|||||||
char *buf;
|
char *buf;
|
||||||
if (!(buf = zalloc(ID_LEN + 1)))
|
if (!(buf = zalloc(ID_LEN + 1)))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
(void)dm_strncpy(buf, pvid, ID_LEN + 1);
|
dm_strncpy(buf, pvid, ID_LEN + 1);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1244,7 +1244,7 @@ int device_ids_read(struct cmd_context *cmd)
|
|||||||
|
|
||||||
/* Save original for lvmdevices output. */
|
/* Save original for lvmdevices output. */
|
||||||
if (!strcmp(cmd->name, "lvmdevices"))
|
if (!strcmp(cmd->name, "lvmdevices"))
|
||||||
(void)dm_strncpy(devices_file_hostname_orig, check_id, PATH_MAX);
|
dm_strncpy(devices_file_hostname_orig, check_id, sizeof(devices_file_hostname_orig));
|
||||||
|
|
||||||
if (!cmd->device_ids_check_hostname)
|
if (!cmd->device_ids_check_hostname)
|
||||||
continue;
|
continue;
|
||||||
@ -1264,7 +1264,7 @@ int device_ids_read(struct cmd_context *cmd)
|
|||||||
|
|
||||||
/* Save original for lvmdevices output. */
|
/* Save original for lvmdevices output. */
|
||||||
if (!strcmp(cmd->name, "lvmdevices"))
|
if (!strcmp(cmd->name, "lvmdevices"))
|
||||||
(void)dm_strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX);
|
dm_strncpy(devices_file_product_uuid_orig, check_id, sizeof(devices_file_product_uuid_orig));
|
||||||
|
|
||||||
if (!cmd->device_ids_check_product_uuid)
|
if (!cmd->device_ids_check_product_uuid)
|
||||||
continue;
|
continue;
|
||||||
@ -1487,7 +1487,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
|
|||||||
(de_date < low_date) ||
|
(de_date < low_date) ||
|
||||||
(de_date == low_date && de_time < low_time) ||
|
(de_date == low_date && de_time < low_time) ||
|
||||||
(de_date == low_date && de_time == low_time && de_count < low_count)) {
|
(de_date == low_date && de_time == low_time && de_count < low_count)) {
|
||||||
(void)dm_strncpy(low_name, de->d_name, sizeof(low_name));
|
dm_strncpy(low_name, de->d_name, sizeof(low_name));
|
||||||
low_date = de_date;
|
low_date = de_date;
|
||||||
low_time = de_time;
|
low_time = de_time;
|
||||||
low_count = de_count;
|
low_count = de_count;
|
||||||
|
@ -181,9 +181,9 @@ int get_pvs_online(struct dm_list *pvs_online, const char *vgname)
|
|||||||
if (file_major || file_minor)
|
if (file_major || file_minor)
|
||||||
po->devno = MKDEV(file_major, file_minor);
|
po->devno = MKDEV(file_major, file_minor);
|
||||||
if (file_vgname[0])
|
if (file_vgname[0])
|
||||||
(void)dm_strncpy(po->vgname, file_vgname, sizeof(po->vgname));
|
dm_strncpy(po->vgname, file_vgname, sizeof(po->vgname));
|
||||||
if (file_devname[0])
|
if (file_devname[0])
|
||||||
(void)dm_strncpy(po->devname, file_devname, sizeof(po->devname));
|
dm_strncpy(po->devname, file_devname, sizeof(po->devname));
|
||||||
|
|
||||||
log_debug("Found PV online %s for VG %s %s", path, vgname, file_devname);
|
log_debug("Found PV online %s for VG %s %s", path, vgname, file_devname);
|
||||||
dm_list_add(pvs_online, &po->list);
|
dm_list_add(pvs_online, &po->list);
|
||||||
|
@ -79,7 +79,7 @@ static int _split_vg(const char *filename, char *vgname, size_t vgsize,
|
|||||||
if (vg_len + 1 > vgsize)
|
if (vg_len + 1 > vgsize)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
(void) dm_strncpy(vgname, filename, vg_len + 1);
|
dm_strncpy(vgname, filename, vg_len + 1);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1305,7 +1305,7 @@ static int _vg_write_file(struct format_instance *fid __attribute__((unused)),
|
|||||||
if (slash == 0)
|
if (slash == 0)
|
||||||
strcpy(temp_dir, ".");
|
strcpy(temp_dir, ".");
|
||||||
else if (slash - tc->path_edit < PATH_MAX) {
|
else if (slash - tc->path_edit < PATH_MAX) {
|
||||||
(void) dm_strncpy(temp_dir, tc->path_edit,
|
dm_strncpy(temp_dir, tc->path_edit,
|
||||||
(size_t) (slash - tc->path_edit + 1));
|
(size_t) (slash - tc->path_edit + 1));
|
||||||
} else {
|
} else {
|
||||||
log_error("Text format failed to determine directory.");
|
log_error("Text format failed to determine directory.");
|
||||||
|
@ -886,7 +886,7 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
|
|||||||
if (!_dev_in_hint_hash(cmd, dev))
|
if (!_dev_in_hint_hash(cmd, dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(void) dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||||
calc_hash = calc_crc(calc_hash, (const uint8_t *)devpath, strlen(devpath));
|
calc_hash = calc_crc(calc_hash, (const uint8_t *)devpath, strlen(devpath));
|
||||||
calc_count++;
|
calc_count++;
|
||||||
}
|
}
|
||||||
@ -1077,7 +1077,7 @@ int write_hint_file(struct cmd_context *cmd, int newhints)
|
|||||||
* detect when the devices on the system change, which
|
* detect when the devices on the system change, which
|
||||||
* invalidates the existing hints.
|
* invalidates the existing hints.
|
||||||
*/
|
*/
|
||||||
(void) dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||||
hash = calc_crc(hash, (const uint8_t *)devpath, strlen(devpath));
|
hash = calc_crc(hash, (const uint8_t *)devpath, strlen(devpath));
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ void init_msg_prefix(const char *prefix)
|
|||||||
{
|
{
|
||||||
if (prefix)
|
if (prefix)
|
||||||
/* Cut away too long prefix */
|
/* Cut away too long prefix */
|
||||||
(void) dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
|
dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_indent(int indent)
|
void init_indent(int indent)
|
||||||
|
@ -681,7 +681,7 @@ static int _get_memory_info(uint64_t *total_mb, uint64_t *available_mb)
|
|||||||
if ((unsigned)(++e - line) > sizeof(namebuf))
|
if ((unsigned)(++e - line) > sizeof(namebuf))
|
||||||
continue; // something too long
|
continue; // something too long
|
||||||
|
|
||||||
(void)dm_strncpy((char*)findme.name, line, e - line);
|
dm_strncpy((char*)findme.name, line, e - line);
|
||||||
|
|
||||||
found = bsearch(&findme, mt, DM_ARRAY_SIZE(mt), sizeof(mem_table_t),
|
found = bsearch(&findme, mt, DM_ARRAY_SIZE(mt), sizeof(mem_table_t),
|
||||||
_compare_mem_table_s);
|
_compare_mem_table_s);
|
||||||
|
@ -164,7 +164,7 @@ void init_log_command(int log_name, int log_pid)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
else if (log_name && !log_pid)
|
else if (log_name && !log_pid)
|
||||||
(void) dm_strncpy(_log_command_info, _cmd_name, sizeof(_log_command_info));
|
dm_strncpy(_log_command_info, _cmd_name, sizeof(_log_command_info));
|
||||||
|
|
||||||
else if (!log_name && log_pid)
|
else if (!log_name && log_pid)
|
||||||
(void) dm_snprintf(_log_command_info, sizeof(_log_command_info), "%d", getpid());
|
(void) dm_snprintf(_log_command_info, sizeof(_log_command_info), "%d", getpid());
|
||||||
@ -212,7 +212,7 @@ void init_pv_min_size(uint64_t sectors)
|
|||||||
|
|
||||||
void set_cmd_name(const char *cmd)
|
void set_cmd_name(const char *cmd)
|
||||||
{
|
{
|
||||||
(void) dm_strncpy(_cmd_name, cmd, sizeof(_cmd_name));
|
dm_strncpy(_cmd_name, cmd, sizeof(_cmd_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *get_cmd_name(void)
|
const char *get_cmd_name(void)
|
||||||
@ -222,7 +222,7 @@ const char *get_cmd_name(void)
|
|||||||
|
|
||||||
void set_sysfs_dir_path(const char *path)
|
void set_sysfs_dir_path(const char *path)
|
||||||
{
|
{
|
||||||
(void) dm_strncpy(_sysfs_dir_path, path, sizeof(_sysfs_dir_path));
|
dm_strncpy(_sysfs_dir_path, path, sizeof(_sysfs_dir_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *log_command_info(void)
|
const char *log_command_info(void)
|
||||||
|
@ -37,6 +37,6 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,
|
|||||||
!(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
|
!(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
|
||||||
(dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
|
(dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
|
||||||
libname) == -1) || stat(path, &info) == -1) {
|
libname) == -1) || stat(path, &info) == -1) {
|
||||||
(void) dm_strncpy(path, libname, path_len);
|
dm_strncpy(path, libname, path_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ int id_write_format(const struct id *id, char *buffer, size_t size)
|
|||||||
assert(ID_LEN == 32);
|
assert(ID_LEN == 32);
|
||||||
|
|
||||||
if (id->uuid[0] == '#') {
|
if (id->uuid[0] == '#') {
|
||||||
(void) dm_strncpy(buffer, (char*)id->uuid, size);
|
dm_strncpy(buffer, (char*)id->uuid, size);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ static uint64_t _lv_to_bits(struct command *cmd, char *name)
|
|||||||
int argc;
|
int argc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void) dm_strncpy(buf, name, LVTYPE_LEN);
|
dm_strncpy(buf, name, sizeof(buf));
|
||||||
|
|
||||||
_split_line(buf, &argc, argv, '_');
|
_split_line(buf, &argc, argv, '_');
|
||||||
|
|
||||||
@ -853,7 +853,7 @@ static char *_get_oo_line(const char *str)
|
|||||||
char str2[OO_NAME_LEN];
|
char str2[OO_NAME_LEN];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void) dm_strncpy(str2, str, sizeof(str2));
|
dm_strncpy(str2, str, sizeof(str2));
|
||||||
if ((end = strchr(str2, ':')))
|
if ((end = strchr(str2, ':')))
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
if ((end = strchr(str2, ',')))
|
if ((end = strchr(str2, ',')))
|
||||||
|
@ -1170,7 +1170,7 @@ static int _raid_split_image_conversion(struct logical_volume *lv)
|
|||||||
|
|
||||||
if (lv_is_raid_image(lv) &&
|
if (lv_is_raid_image(lv) &&
|
||||||
(s = strstr(lv->name, "_rimage_"))) {
|
(s = strstr(lv->name, "_rimage_"))) {
|
||||||
(void) dm_strncpy(raidlv_name, lv->name, s - lv->name);
|
dm_strncpy(raidlv_name, lv->name, s - lv->name);
|
||||||
|
|
||||||
if (!(tmp_lv = find_lv(lv->vg, raidlv_name))) {
|
if (!(tmp_lv = find_lv(lv->vg, raidlv_name))) {
|
||||||
log_error("Failed to find RaidLV of RAID subvolume %s.",
|
log_error("Failed to find RaidLV of RAID subvolume %s.",
|
||||||
|
@ -408,7 +408,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (strcmp(vgname, vp.old_vgname)) {
|
if (strcmp(vgname, vp.old_vgname)) {
|
||||||
(void) dm_strncpy(tmp_vgname, base_vgname, NAME_LEN);
|
dm_strncpy(tmp_vgname, base_vgname, sizeof(tmp_vgname));
|
||||||
vgname_count = 0;
|
vgname_count = 0;
|
||||||
} else {
|
} else {
|
||||||
/* Needed when basename matches old name, and PV is not a duplicate
|
/* Needed when basename matches old name, and PV is not a duplicate
|
||||||
|
Loading…
Reference in New Issue
Block a user