Skip to contentSkip to conversation

master - dmsetup: always initialise 'mode' in filemap create functions

PATCH Bryn Reeves 1 participant 1 message Mar 10, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1659be588d6d077ddd4d9d095cfb336520898975
Commit:        1659be588d6d077ddd4d9d095cfb336520898975
Parent:        146b2582b05b3b4b0f25296620ed2c2ca9e0f467
Author:        Bryn M. Reeves <[email protected]>
AuthorDate:    Fri Mar 10 12:04:02 2017 +0000
Committer:     Bryn M. Reeves <[email protected]>
CommitterDate: Fri Mar 10 12:04:02 2017 +0000

dmsetup: always initialise 'mode' in filemap create functions

Older compilers cannot tell that the 'mode' variable is only used in branches in which it is assigned:

dmsetup.c:5651: warning: "mode" may be used uninitialized in this function dmsetup.c:5023: warning: "mode" may be used uninitialized in this function

Avoid this by always assigning the variable a value.

---
 tools/cmds.h                |  143 +++++++
 tools/command-count.h       |   16 +
 tools/command-lines-input.h |  965 +++++++++++++++++++++++++++++++++++++++++++
 tools/dmsetup.c             |   14 +-
 4 files changed, 1132 insertions(+), 6 deletions(-)
tools/cmds.h new file +143 -0
new file mode 100644
index 0000000..fe42140
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
+ * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/* Do not edit. This file is generated by the Makefile. */
+cmd(CMD_NONE, none)
+cmd(devtypes_general_CMD, devtypes_general)
+cmd(formats_general_CMD, formats_general)
+cmd(fullreport_general_CMD, fullreport_general)
+cmd(help_general_CMD, help_general)
+cmd(lastlog_general_CMD, lastlog_general)
+cmd(lvchange_activate_CMD, lvchange_activate)
+cmd(lvchange_monitor_CMD, lvchange_monitor)
+cmd(lvchange_persistent_CMD, lvchange_persistent)
+cmd(lvchange_poll_CMD, lvchange_poll)
+cmd(lvchange_properties_CMD, lvchange_properties)
+cmd(lvchange_rebuild_CMD, lvchange_rebuild)
+cmd(lvchange_refresh_CMD, lvchange_refresh)
+cmd(lvchange_resync_CMD, lvchange_resync)
+cmd(lvchange_syncaction_CMD, lvchange_syncaction)
+cmd(lvconvert_change_mirrorlog_CMD, lvconvert_change_mirrorlog)
+cmd(lvconvert_change_region_size_CMD, lvconvert_change_region_size)
+cmd(lvconvert_combine_split_snapshot_CMD, lvconvert_combine_split_snapshot)
+cmd(lvconvert_merge_CMD, lvconvert_merge)
+cmd(lvconvert_merge_mirror_images_CMD, lvconvert_merge_mirror_images)
+cmd(lvconvert_merge_snapshot_CMD, lvconvert_merge_snapshot)
+cmd(lvconvert_merge_thin_CMD, lvconvert_merge_thin)
+cmd(lvconvert_raid_types_CMD, lvconvert_raid_types)
+cmd(lvconvert_repair_pvs_or_thinpool_CMD, lvconvert_repair_pvs_or_thinpool)
+cmd(lvconvert_replace_pv_CMD, lvconvert_replace_pv)
+cmd(lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_and_keep_cachepool)
+cmd(lvconvert_split_and_remove_cachepool_CMD, lvconvert_split_and_remove_cachepool)
+cmd(lvconvert_split_cow_snapshot_CMD, lvconvert_split_cow_snapshot)
+cmd(lvconvert_split_mirror_images_CMD, lvconvert_split_mirror_images)
+cmd(lvconvert_start_poll_CMD, lvconvert_start_poll)
+cmd(lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata)
+cmd(lvconvert_to_cachepool_CMD, lvconvert_to_cachepool)
+cmd(lvconvert_to_cachepool_or_swap_metadata_CMD, lvconvert_to_cachepool_or_swap_metadata)
+cmd(lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol)
+cmd(lvconvert_to_thinpool_CMD, lvconvert_to_thinpool)
+cmd(lvconvert_to_thinpool_or_swap_metadata_CMD, lvconvert_to_thinpool_or_swap_metadata)
+cmd(lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external)
+cmd(lvcreate_cachepool_CMD, lvcreate_cachepool)
+cmd(lvcreate_cache_vol_with_new_origin_CMD, lvcreate_cache_vol_with_new_origin)
+cmd(lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD, lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool)
+cmd(lvcreate_cow_snapshot_CMD, lvcreate_cow_snapshot)
+cmd(lvcreate_cow_snapshot_with_virtual_origin_CMD, lvcreate_cow_snapshot_with_virtual_origin)
+cmd(lvcreate_error_vol_CMD, lvcreate_error_vol)
+cmd(lvcreate_linear_CMD, lvcreate_linear)
+cmd(lvcreate_mirror_CMD, lvcreate_mirror)
+cmd(lvcreate_mirror_or_raid1_CMD, lvcreate_mirror_or_raid1)
+cmd(lvcreate_raid_any_CMD, lvcreate_raid_any)
+cmd(lvcreate_striped_CMD, lvcreate_striped)
+cmd(lvcreate_thinpool_CMD, lvcreate_thinpool)
+cmd(lvcreate_thin_snapshot_CMD, lvcreate_thin_snapshot)
+cmd(lvcreate_thin_snapshot_of_external_CMD, lvcreate_thin_snapshot_of_external)
+cmd(lvcreate_thin_vol_CMD, lvcreate_thin_vol)
+cmd(lvcreate_thin_vol_and_thinpool_CMD, lvcreate_thin_vol_and_thinpool)
+cmd(lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD, lvcreate_thin_vol_with_thinpool_or_sparse_snapshot)
+cmd(lvcreate_zero_vol_CMD, lvcreate_zero_vol)
+cmd(lvdisplay_general_CMD, lvdisplay_general)
+cmd(lvextend_by_policy_CMD, lvextend_by_policy)
+cmd(lvextend_by_pv_CMD, lvextend_by_pv)
+cmd(lvextend_by_size_CMD, lvextend_by_size)
+cmd(lvextend_pool_metadata_by_size_CMD, lvextend_pool_metadata_by_size)
+cmd(lvmchange_general_CMD, lvmchange_general)
+cmd(lvmconfig_general_CMD, lvmconfig_general)
+cmd(lvmdiskscan_general_CMD, lvmdiskscan_general)
+cmd(lvmsadc_general_CMD, lvmsadc_general)
+cmd(lvmsar_general_CMD, lvmsar_general)
+cmd(lvpoll_general_CMD, lvpoll_general)
+cmd(lvreduce_general_CMD, lvreduce_general)
+cmd(lvremove_general_CMD, lvremove_general)
+cmd(lvrename_lv_lv_CMD, lvrename_lv_lv)
+cmd(lvrename_vg_lv_lv_CMD, lvrename_vg_lv_lv)
+cmd(lvresize_by_pv_CMD, lvresize_by_pv)
+cmd(lvresize_by_size_CMD, lvresize_by_size)
+cmd(lvresize_pool_metadata_by_size_CMD, lvresize_pool_metadata_by_size)
+cmd(lvscan_cache_CMD, lvscan_cache)
+cmd(lvscan_general_CMD, lvscan_general)
+cmd(lvs_general_CMD, lvs_general)
+cmd(pvchange_properties_all_CMD, pvchange_properties_all)
+cmd(pvchange_properties_some_CMD, pvchange_properties_some)
+cmd(pvck_general_CMD, pvck_general)
+cmd(pvcreate_general_CMD, pvcreate_general)
+cmd(pvdata_general_CMD, pvdata_general)
+cmd(pvdisplay_general_CMD, pvdisplay_general)
+cmd(pvmove_any_CMD, pvmove_any)
+cmd(pvmove_one_CMD, pvmove_one)
+cmd(pvremove_general_CMD, pvremove_general)
+cmd(pvresize_general_CMD, pvresize_general)
+cmd(pvscan_cache_CMD, pvscan_cache)
+cmd(pvscan_show_CMD, pvscan_show)
+cmd(pvs_general_CMD, pvs_general)
+cmd(segtypes_general_CMD, segtypes_general)
+cmd(systemid_general_CMD, systemid_general)
+cmd(tags_general_CMD, tags_general)
+cmd(version_general_CMD, version_general)
+cmd(vgcfgbackup_general_CMD, vgcfgbackup_general)
+cmd(vgcfgrestore_by_file_CMD, vgcfgrestore_by_file)
+cmd(vgcfgrestore_by_vg_CMD, vgcfgrestore_by_vg)
+cmd(vgcfgrestore_list_by_file_CMD, vgcfgrestore_list_by_file)
+cmd(vgcfgrestore_list_by_vg_CMD, vgcfgrestore_list_by_vg)
+cmd(vgchange_activate_CMD, vgchange_activate)
+cmd(vgchange_lockstart_CMD, vgchange_lockstart)
+cmd(vgchange_lockstop_CMD, vgchange_lockstop)
+cmd(vgchange_monitor_CMD, vgchange_monitor)
+cmd(vgchange_poll_CMD, vgchange_poll)
+cmd(vgchange_properties_CMD, vgchange_properties)
+cmd(vgchange_refresh_CMD, vgchange_refresh)
+cmd(vgck_general_CMD, vgck_general)
+cmd(vgconvert_general_CMD, vgconvert_general)
+cmd(vgcreate_general_CMD, vgcreate_general)
+cmd(vgdisplay_general_CMD, vgdisplay_general)
+cmd(vgexport_all_CMD, vgexport_all)
+cmd(vgexport_some_CMD, vgexport_some)
+cmd(vgextend_general_CMD, vgextend_general)
+cmd(vgimport_all_CMD, vgimport_all)
+cmd(vgimportclone_general_CMD, vgimportclone_general)
+cmd(vgimport_some_CMD, vgimport_some)
+cmd(vgmerge_general_CMD, vgmerge_general)
+cmd(vgmknodes_general_CMD, vgmknodes_general)
+cmd(vgreduce_all_CMD, vgreduce_all)
+cmd(vgreduce_by_pv_CMD, vgreduce_by_pv)
+cmd(vgreduce_missing_CMD, vgreduce_missing)
+cmd(vgremove_general_CMD, vgremove_general)
+cmd(vgrename_by_name_CMD, vgrename_by_name)
+cmd(vgrename_by_uuid_CMD, vgrename_by_uuid)
+cmd(vgscan_general_CMD, vgscan_general)
+cmd(vgs_general_CMD, vgs_general)
+cmd(vgsplit_by_lv_CMD, vgsplit_by_lv)
+cmd(vgsplit_by_pv_CMD, vgsplit_by_pv)
+cmd(CMD_COUNT, count)
tools/command-count.h new file +16 -0
new file mode 100644
index 0000000..69b8dc2
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
+ * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/* Do not edit. This file is generated by the Makefile. */
+#define COMMAND_COUNT 157
tools/command-lines-input.h new file +965 -0

965 lines not on this page · raw message

tools/dmsetup.c +8 -6
index eaeb1ce..945557f 100644
@@ -5004,6 +5004,8 @@ static int _stats_check_filemap_switches(void)
 
 static dm_filemapd_mode_t _stats_get_filemapd_mode(void)
 {
+	if (_switches[NOMONITOR_ARG] || _switches[NOGROUP_ARG])
+		return DM_FILEMAPD_FOLLOW_NONE;
 	if (!_switches[FOLLOW_ARG])
 		return DM_FILEMAPD_FOLLOW_INODE;
 	return dm_filemapd_mode_from_string(_string_args[FOLLOW_ARG]);
@@ -5073,9 +5075,9 @@ static int _stats_create_file(CMD_ARGS)
 	precise = _int_args[PRECISE_ARG];
 	group = !_switches[NOGROUP_ARG];
 
-	if (!_switches[NOMONITOR_ARG] && group)
-		if ((mode = _stats_get_filemapd_mode()) == -1)
-			goto bad;
+	mode = _stats_get_filemapd_mode();
+	if (!_switches[NOMONITOR_ARG] && (mode == DM_FILEMAPD_FOLLOW_NONE))
+		goto bad;
 
 	if (!(dms = dm_stats_create(DM_STATS_PROGRAM_ID)))
 		goto_bad;
@@ -5681,9 +5683,9 @@ static int _stats_update_file(CMD_ARGS)
 
 	group_id = (uint64_t) _int_args[GROUP_ID_ARG];
 
-	if (!_switches[NOMONITOR_ARG])
-		if ((mode = _stats_get_filemapd_mode()) < 0)
-			goto bad;
+	mode = _stats_get_filemapd_mode();
+	if (!_switches[NOMONITOR_ARG] && (mode == DM_FILEMAPD_FOLLOW_NONE))
+		goto bad;
 
 	if (_switches[PROGRAM_ID_ARG])
 		program_id = _string_args[PROGRAM_ID_ARG];