master - tidy: else after continue
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4ef6cfc882fd89ee23a...
Commit: 4ef6cfc882fd89ee23a12be11d631b691f7e8ddf
Parent: 0bf836aa14f98eb83969a6e81695a024f56a5eb5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 23:12:48 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 20 11:18:29 2017 +0200
tidy: else after continue
Similar as with 'else' after 'return' unindent whole block
for better readability of code.
---
lib/activate/activate.c | 8 ++--
lib/format1/import-extents.c | 58 +++++++++++++++++------------------
lib/metadata/lv_manip.c | 69 +++++++++++++++++++++--------------------
3 files changed, 67 insertions(+), 68 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 1bbd1b5..d00e61e 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -150,15 +150,15 @@ static int _lv_passes_volumes_filter(struct cmd_context *cmd, const struct logic
|| str_list_match_list(&cmd->tags,
&lv->vg->tags, NULL))
return 1;
- else
- continue;
+
+ continue;
}
/* If supplied tag matches LV or VG tag, activate */
if (str_list_match_item(&lv->tags, str) ||
str_list_match_item(&lv->vg->tags, str))
return 1;
- else
- continue;
+
+ continue;
}
/* If supplied name is vgname[/lvname] */
diff --git a/lib/format1/import-extents.c b/lib/format1/import-extents.c
index 4c259c1..c583741 100644
--- a/lib/format1/import-extents.c
+++ b/lib/format1/import-extents.c
@@ -134,37 +134,35 @@ static int _fill_maps(struct dm_hash_table *maps, struct volume_group *vg,
if (lv_num == UNMAPPED_EXTENT)
continue;
- else {
- lv_num--;
- lvm = lvms[lv_num];
-
- if (!lvm) {
- log_error("Invalid LV in extent map "
- "(PV %s, PE %" PRIu32
- ", LV %" PRIu32
- ", LE %" PRIu32 ")",
- dev_name(pv->dev), i,
- lv_num, e[i].le_num);
- return 0;
- }
-
- le = e[i].le_num;
-
- if (le >= lvm->lv->le_count) {
- log_error("logical extent number "
- "out of bounds");
- return 0;
- }
-
- if (lvm->map[le].pv) {
- log_error("logical extent (%u) "
- "already mapped.", le);
- return 0;
- }
-
- lvm->map[le].pv = pv;
- lvm->map[le].pe = i;
+ lv_num--;
+ lvm = lvms[lv_num];
+
+ if (!lvm) {
+ log_error("Invalid LV in extent map "
+ "(PV %s, PE %" PRIu32
+ ", LV %" PRIu32
+ ", LE %" PRIu32 ")",
+ dev_name(pv->dev), i,
+ lv_num, e[i].le_num);
+ return 0;
}
+
+ le = e[i].le_num;
+
+ if (le >= lvm->lv->le_count) {
+ log_error("logical extent number "
+ "out of bounds");
+ return 0;
+ }
+
+ if (lvm->map[le].pv) {
+ log_error("logical extent (%u) "
+ "already mapped.", le);
+ return 0;
+ }
+
+ lvm->map[le].pv = pv;
+ lvm->map[le].pe = i;
}
}
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5c2e722..1851783 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2155,53 +2155,54 @@ static int _match_pv_tags(const struct dm_config_node *cling_tag_list_cn,
}
continue;
}
+
if (!str_list_match_list(&pv1->tags, tags_to_match, &tag_matched))
continue;
- else {
- if (!pv_tags) {
- if (parallel_pv)
- log_debug_alloc("Not using free space on %s: Matched allocation PV tag %s on existing parallel PV %s.",
- pv_dev_name(pv1), tag_matched, pv2 ? pv_dev_name(pv2) : "-");
- else
- log_debug_alloc("Matched allocation PV tag %s on existing %s with free space on %s.",
- tag_matched, pv_dev_name(pv1), pv2 ? pv_dev_name(pv2) : "-");
- } else
- log_debug_alloc("Eliminating allocation area %" PRIu32 " at PV %s start PE %" PRIu32
- " from consideration: PV tag %s already used.",
- area_num, pv_dev_name(pv1), pv1_start_pe, tag_matched);
- return 1;
- }
- }
- if (!str_list_match_item(&pv1->tags, str) ||
- (tags_to_match && !str_list_match_item(tags_to_match, str)))
- continue;
- else {
- if (mem) {
- if (!first_tag && !dm_pool_grow_object(mem, ",", 0)) {
- log_error("PV tags string extension failed.");
- return 0;
- }
- first_tag = 0;
- if (!dm_pool_grow_object(mem, str, 0)) {
- log_error("PV tags string extension failed.");
- return 0;
- }
- continue;
- }
if (!pv_tags) {
if (parallel_pv)
log_debug_alloc("Not using free space on %s: Matched allocation PV tag %s on existing parallel PV %s.",
- pv2 ? pv_dev_name(pv2) : "-", str, pv_dev_name(pv1));
+ pv_dev_name(pv1), tag_matched, pv2 ? pv_dev_name(pv2) : "-");
else
log_debug_alloc("Matched allocation PV tag %s on existing %s with free space on %s.",
- str, pv_dev_name(pv1), pv2 ? pv_dev_name(pv2) : "-");
+ tag_matched, pv_dev_name(pv1), pv2 ? pv_dev_name(pv2) : "-");
} else
log_debug_alloc("Eliminating allocation area %" PRIu32 " at PV %s start PE %" PRIu32
" from consideration: PV tag %s already used.",
- area_num, pv_dev_name(pv1), pv1_start_pe, str);
+ area_num, pv_dev_name(pv1), pv1_start_pe, tag_matched);
return 1;
}
+
+ if (!str_list_match_item(&pv1->tags, str) ||
+ (tags_to_match && !str_list_match_item(tags_to_match, str)))
+ continue;
+
+ if (mem) {
+ if (!first_tag && !dm_pool_grow_object(mem, ",", 0)) {
+ log_error("PV tags string extension failed.");
+ return 0;
+ }
+ first_tag = 0;
+ if (!dm_pool_grow_object(mem, str, 0)) {
+ log_error("PV tags string extension failed.");
+ return 0;
+ }
+ continue;
+ }
+
+ if (!pv_tags) {
+ if (parallel_pv)
+ log_debug_alloc("Not using free space on %s: Matched allocation PV tag %s on existing parallel PV %s.",
+ pv2 ? pv_dev_name(pv2) : "-", str, pv_dev_name(pv1));
+ else
+ log_debug_alloc("Matched allocation PV tag %s on existing %s with free space on %s.",
+ str, pv_dev_name(pv1), pv2 ? pv_dev_name(pv2) : "-");
+ } else
+ log_debug_alloc("Eliminating allocation area %" PRIu32 " at PV %s start PE %" PRIu32
+ " from consideration: PV tag %s already used.",
+ area_num, pv_dev_name(pv1), pv1_start_pe, str);
+
+ return 1;
}
if (mem)
6 years, 9 months
master - tidy: prefer not using else after return
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0bf836aa14f98eb8396...
Commit: 0bf836aa14f98eb83969a6e81695a024f56a5eb5
Parent: 0d0a3397c22b9d5342584299acd814f6c8221c18
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 16:16:12 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 20 11:18:29 2017 +0200
tidy: prefer not using else after return
clang-tidy: avoid using 'else' after return - give more readable code,
and also saves indention level.
---
daemons/dmeventd/dmeventd.c | 3 +-
daemons/dmeventd/libdevmapper-event.c | 17 +++++-----
lib/activate/activate.c | 12 +++++--
lib/activate/dev_manager.c | 9 +++--
lib/activate/fs.c | 20 ++++++-----
lib/cache/lvmetad.c | 13 ++++---
lib/config/config.c | 3 +-
lib/device/dev-cache.c | 10 +++---
lib/device/dev-io.c | 4 +-
lib/device/dev-type.c | 24 +++++++-------
lib/filters/filter-sysfs.c | 5 ++-
lib/format_text/format-text.c | 21 ++++++------
lib/locking/cluster_locking.c | 9 +++--
lib/locking/locking.c | 10 +++--
lib/locking/lvmlockd.c | 43 +++++++++++++------------
lib/metadata/lv.c | 40 +++++++++++------------
lib/metadata/lv_manip.c | 42 ++++++++++++++----------
lib/metadata/metadata.c | 14 +++++---
lib/metadata/mirror.c | 12 +++++--
lib/metadata/pv_manip.c | 9 +++--
lib/metadata/raid_manip.c | 48 +++++++++++++++++++---------
lib/replicator/replicator.c | 4 ++-
lib/report/report.c | 56 +++++++++++++++++---------------
libdm/ioctl/libdm-iface.c | 19 ++++++-----
libdm/libdm-common.c | 13 +++----
libdm/libdm-report.c | 10 +++--
tools/dmsetup.c | 7 ++--
tools/lvconvert.c | 17 ++++++----
tools/lvcreate.c | 4 ++-
tools/polldaemon.c | 33 ++++++++++---------
tools/toollib.c | 14 +++++---
tools/vgdisplay.c | 17 ++++++----
32 files changed, 318 insertions(+), 244 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index a2883a1..3a92ab6 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -2252,7 +2252,8 @@ int main(int argc, char *argv[])
"for %ld second(s), exiting.",
(long) (time(NULL) - _idle_since));
break;
- } else if (idle_exit_timeout) {
+ }
+ if (idle_exit_timeout) {
now = time(NULL);
if (now < _idle_since)
_idle_since = now; /* clock change? */
diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c
index b23b6c1..210e384 100644
--- a/daemons/dmeventd/libdevmapper-event.c
+++ b/daemons/dmeventd/libdevmapper-event.c
@@ -250,10 +250,9 @@ static int _daemon_read(struct dm_event_fifos *fifos,
if (ret < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- else {
- log_error("Unable to read from event server.");
- return 0;
- }
+
+ log_error("Unable to read from event server.");
+ return 0;
}
bytes += ret;
@@ -329,10 +328,9 @@ static int _daemon_write(struct dm_event_fifos *fifos,
if (ret < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- else {
- log_error("Unable to talk to event daemon.");
- return 0;
- }
+
+ log_error("Unable to talk to event daemon.");
+ return 0;
}
bytes += ret;
@@ -454,7 +452,8 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
if (close(fifos->client))
log_sys_debug("close", fifos->client_path);
return 1;
- } else if (errno != ENXIO && errno != ENOENT) {
+ }
+ if (errno != ENXIO && errno != ENOENT) {
/* problem */
log_sys_error("open", fifos->client_path);
return 0;
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index d73e8b1..1bbd1b5 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -797,14 +797,18 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
status->info.exists = 0; /* So pool LV is not active */
}
return 1;
- } else if (lv_is_external_origin(lv)) {
+ }
+
+ if (lv_is_external_origin(lv)) {
if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
with_open_count, with_read_ahead))
return_0;
(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
return 1;
- } else if (lv_is_origin(lv)) {
+ }
+
+ if (lv_is_origin(lv)) {
/* Query segment status for 'layered' (-real) device most of the time,
* only for merging snapshot, query its progress.
* TODO: single LV may need couple status to be exposed at once....
@@ -821,7 +825,9 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
/* Grab STATUS from layered -real */
(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
return 1;
- } else if (lv_is_cow(lv)) {
+ }
+
+ if (lv_is_cow(lv)) {
if (lv_is_merging_cow(lv)) {
olv = origin_from_cow(lv);
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index daddfc8..8d96259 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1056,10 +1056,11 @@ static int _percent(struct dev_manager *dm, const char *name, const char *dlid,
if (_percent_run(dm, NULL, dlid, target_type, wait, lv, percent,
event_nr, fail_if_percent_unsupported))
return 1;
- else if (_original_uuid_format_check_required(dm->cmd) &&
- _percent_run(dm, NULL, dlid + sizeof(UUID_PREFIX) - 1,
- target_type, wait, lv, percent,
- event_nr, fail_if_percent_unsupported))
+
+ if (_original_uuid_format_check_required(dm->cmd) &&
+ _percent_run(dm, NULL, dlid + sizeof(UUID_PREFIX) - 1,
+ target_type, wait, lv, percent,
+ event_nr, fail_if_percent_unsupported))
return 1;
}
diff --git a/lib/activate/fs.c b/lib/activate/fs.c
index 2f455ba..a0b8bff 100644
--- a/lib/activate/fs.c
+++ b/lib/activate/fs.c
@@ -186,11 +186,11 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
!stat(lv_path, &buf)) {
if (buf_lp.st_rdev == buf.st_rdev)
return 1;
- else
- log_warn("Symlink %s that should have been "
- "created by udev does not have "
- "correct target. Falling back to "
- "direct link creation", lv_path);
+
+ log_warn("Symlink %s that should have been "
+ "created by udev does not have "
+ "correct target. Falling back to "
+ "direct link creation", lv_path);
} else
log_warn("Symlink %s that should have been "
"created by udev could not be checked "
@@ -239,7 +239,9 @@ static int _rm_link(const char *dev_dir, const char *vg_name,
return 1;
log_sys_error("lstat", lv_path);
return 0;
- } else if (dm_udev_get_sync_support() && udev_checking() && check_udev)
+ }
+
+ if (dm_udev_get_sync_support() && udev_checking() && check_udev)
log_warn("The link %s should have been removed by udev "
"but it is still present. Falling back to "
"direct link removal.", lv_path);
@@ -478,9 +480,9 @@ int fs_rename_lv(const struct logical_volume *lv, const char *dev,
_fs_op(FS_ADD, lv->vg->cmd->dev_dir, lv->vg->name,
lv->name, dev, "", lv->vg->cmd->current_settings.udev_rules));
}
- else
- return _fs_op(FS_RENAME, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
- dev, old_lvname, lv->vg->cmd->current_settings.udev_rules);
+
+ return _fs_op(FS_RENAME, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
+ dev, old_lvname, lv->vg->cmd->current_settings.udev_rules);
}
void fs_unlock(void)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 5490675..2e0ee51 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -145,13 +145,14 @@ int lvmetad_connect(struct cmd_context *cmd)
_lvmetad_use = 1;
_lvmetad_cmd = cmd;
return 1;
- } else {
- log_debug_lvmetad("Failed to connect to lvmetad: %s", strerror(_lvmetad.error));
- _lvmetad_connected = 0;
- _lvmetad_use = 0;
- _lvmetad_cmd = NULL;
- return 0;
}
+
+ log_debug_lvmetad("Failed to connect to lvmetad: %s", strerror(_lvmetad.error));
+ _lvmetad_connected = 0;
+ _lvmetad_use = 0;
+ _lvmetad_cmd = NULL;
+
+ return 0;
}
int lvmetad_used(void)
diff --git a/lib/config/config.c b/lib/config/config.c
index daf5fa3..04dded7 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -481,7 +481,8 @@ int override_config_tree_from_profile(struct cmd_context *cmd,
if (profile->source == CONFIG_PROFILE_COMMAND)
return _override_config_tree_from_command_profile(cmd, profile);
- else if (profile->source == CONFIG_PROFILE_METADATA)
+
+ if (profile->source == CONFIG_PROFILE_METADATA)
return _override_config_tree_from_metadata_profile(cmd, profile);
log_error(INTERNAL_ERROR "override_config_tree_from_profile: incorrect profile source type");
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 9a4dbc9..7802e45 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -320,8 +320,8 @@ static int _compare_paths(const char *path0, const char *path1)
/* ASCII comparison */
if (strcmp(path0, path1) < 0)
return 0;
- else
- return 1;
+
+ return 1;
}
static int _add_alias(struct device *dev, const char *path)
@@ -898,10 +898,10 @@ int dev_cache_index_devs(void)
if (errno == ENOENT) {
sysfs_has_dev_block = 0;
return 1;
- } else {
- log_sys_error("stat", path);
- return 0;
}
+
+ log_sys_error("stat", path);
+ return 0;
}
} else if (!sysfs_has_dev_block)
return 1;
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index a9a2374..519b5c7 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -405,8 +405,8 @@ int dev_get_size(struct device *dev, uint64_t *size)
if ((dev->flags & DEV_REGULAR))
return _dev_get_size_file(dev, size);
- else
- return _dev_get_size_dev(dev, size);
+
+ return _dev_get_size_dev(dev, size);
}
int dev_get_read_ahead(struct device *dev, uint32_t *read_ahead)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 325b66b..aa22e3b 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -615,38 +615,38 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
if (force < DONT_PROMPT) {
log_error(MSG_FAILED_SIG_OFFSET, type, name);
return 0;
- } else {
- log_error("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
- return 2;
}
+
+ log_error("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
+ return 2;
}
if (blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len)) {
if (force < DONT_PROMPT) {
log_error(MSG_FAILED_SIG_LENGTH, type, name);
return 0;
- } else {
- log_warn("WARNING: " MSG_FAILED_SIG_LENGTH MSG_WIPING_SKIPPED, type, name);
- return 2;
}
+
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH MSG_WIPING_SKIPPED, type, name);
+ return 2;
}
} else if (!blkid_probe_lookup_value(probe, "PTTYPE", &type, NULL)) {
if (blkid_probe_lookup_value(probe, "PTMAGIC_OFFSET", &offset, NULL)) {
if (force < DONT_PROMPT) {
log_error(MSG_FAILED_SIG_OFFSET, type, name);
return 0;
- } else {
- log_warn("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
- return 2;
}
+
+ log_warn("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
+ return 2;
}
if (blkid_probe_lookup_value(probe, "PTMAGIC", &magic, &len)) {
if (force < DONT_PROMPT) {
log_error(MSG_FAILED_SIG_LENGTH, type, name);
return 0;
- } else {
- log_warn("WARNING: " MSG_FAILED_SIG_LENGTH MSG_WIPING_SKIPPED, type, name);
- return 2;
}
+
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH MSG_WIPING_SKIPPED, type, name);
+ return 2;
}
usage = "partition table";
} else
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
index 6dacd5d..93862e6 100644
--- a/lib/filters/filter-sysfs.c
+++ b/lib/filters/filter-sysfs.c
@@ -274,8 +274,9 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
if (!_set_lookup(ds, dev->dev)) {
log_debug_devs("%s: Skipping (sysfs)", dev_name(dev));
return 0;
- } else
- return 1;
+ }
+
+ return 1;
}
static void _destroy(struct dev_filter *f)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index bf8cd02..91f8816 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -152,8 +152,8 @@ static uint64_t _get_prev_sector_circular(uint64_t region_start,
{
if (region_ptr >= region_start + SECTOR_SIZE)
return region_ptr - SECTOR_SIZE;
- else
- return (region_start + region_size - SECTOR_SIZE);
+
+ return (region_start + region_size - SECTOR_SIZE);
}
/*
@@ -447,9 +447,9 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
(isspace(vgnamebuf[len]) || vgnamebuf[len] == '{'))
return rlocn;
- else
- log_debug_metadata("Volume group name found in metadata does "
- "not match expected name %s.", vgname);
+
+ log_debug_metadata("Volume group name found in metadata does "
+ "not match expected name %s.", vgname);
bad:
if ((info = lvmcache_info_from_pvid(dev_area->dev->pvid, dev_area->dev, 0)) &&
@@ -893,8 +893,9 @@ static struct volume_group *_vg_read_file_name(struct format_instance *fid,
log_error("'%s' does not contain volume group '%s'.",
read_path, vgname);
return NULL;
- } else
- log_debug_metadata("Read volume group %s from %s", vg->name, read_path);
+ }
+
+ log_debug_metadata("Read volume group %s from %s", vg->name, read_path);
return vg;
}
@@ -1634,10 +1635,10 @@ static int _text_pv_initialise(const struct format_type *fmt,
log_error("%s: Bootloader area would overlap "
"data area.", pv_dev_name(pv));
return 0;
- } else {
- pv->ba_start = pva->ba_start ? : final_alignment;
- pv->ba_size = pva->ba_size;
}
+
+ pv->ba_start = pva->ba_start ? : final_alignment;
+ pv->ba_size = pva->ba_size;
}
}
diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c
index b031833..a04d9c7 100644
--- a/lib/locking/cluster_locking.c
+++ b/lib/locking/cluster_locking.c
@@ -519,11 +519,14 @@ static int decode_lock_type(const char *response)
{
if (!response)
return LCK_NULL;
- else if (!strcmp(response, "EX"))
+
+ if (!strcmp(response, "EX"))
return LCK_EXCL;
- else if (!strcmp(response, "CR"))
+
+ if (!strcmp(response, "CR"))
return LCK_READ;
- else if (!strcmp(response, "PR"))
+
+ if (!strcmp(response, "PR"))
return LCK_PREAD;
return_0;
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index afc001a..2886fc4 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -187,9 +187,9 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages)
"be inaccessible.");
if (init_file_locking(&_locking, cmd, suppress_messages))
return 1;
- else
- log_error_suppress(suppress_messages,
- "File-based locking initialisation failed.");
+
+ log_error_suppress(suppress_messages,
+ "File-based locking initialisation failed.");
}
if (!ignorelockingfailure())
@@ -232,7 +232,9 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
log_error("%s exists: Is the original LVM driver using "
"this volume group?", path);
return 0;
- } else if (errno != ENOENT && errno != ENOTDIR) {
+ }
+
+ if (errno != ENOENT && errno != ENOTDIR) {
log_sys_error("stat", path);
return 0;
}
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 94a674f..54e3cf6 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1596,15 +1596,15 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
*/
log_error("Global lock failed: held by other host.");
return 0;
- } else {
- /*
- * We don't intend to reach this. We should check
- * any known/possible error specifically and print
- * a more helpful message. This is for completeness.
- */
- log_error("Global lock failed: error %d.", result);
- return 0;
}
+
+ /*
+ * We don't intend to reach this. We should check
+ * any known/possible error specifically and print
+ * a more helpful message. This is for completeness.
+ */
+ log_error("Global lock failed: error %d.", result);
+ return 0;
}
allow:
@@ -2330,15 +2330,16 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
if (!_lvmlockd_connected)
return 0;
- if (!lp->needs_lockd_init) {
+ if (!lp->needs_lockd_init)
/* needs_lock_init is set for LVs that need a lockd lock. */
return 1;
- } else if (seg_is_cache(lp) || seg_is_cache_pool(lp)) {
+ if (seg_is_cache(lp) || seg_is_cache_pool(lp)) {
log_error("Use lvconvert for cache with lock type %s", vg->lock_type);
return 0;
+ }
- } else if (!seg_is_thin_volume(lp) && lp->snapshot) {
+ if (!seg_is_thin_volume(lp) && lp->snapshot) {
struct logical_volume *origin_lv;
/*
@@ -2363,8 +2364,9 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
}
lv->lock_args = NULL;
return 1;
+ }
- } else if (seg_is_thin(lp)) {
+ if (seg_is_thin(lp)) {
if ((seg_is_thin_volume(lp) && !lp->create_pool) ||
(!seg_is_thin_volume(lp) && lp->snapshot)) {
struct lv_list *lvl;
@@ -2385,8 +2387,9 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
}
lv->lock_args = NULL;
return 1;
+ }
- } else if (seg_is_thin_volume(lp) && lp->create_pool) {
+ if (seg_is_thin_volume(lp) && lp->create_pool) {
/*
* Creating a thin pool and a thin lv in it. We could
* probably make this work.
@@ -2394,21 +2397,21 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
log_error("Create thin pool and thin LV separately with lock type %s",
vg->lock_type);
return 0;
+ }
- } else if (!seg_is_thin_volume(lp) && lp->create_pool) {
+ if (!seg_is_thin_volume(lp) && lp->create_pool) {
/* Creating a thin pool only. */
/* lv_name_lock = lp->pool_name; */
- } else {
- log_error("Unknown thin options for lock init.");
- return 0;
}
- } else {
- /* Creating a normal lv. */
- /* lv_name_lock = lv_name; */
+ log_error("Unknown thin options for lock init.");
+ return 0;
}
+ /* Creating a normal lv. */
+ /* lv_name_lock = lv_name; */
+
/*
* The LV gets its own lock, so set lock_args to non-NULL.
*
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index c87bb6b..e3815c9 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -581,8 +581,8 @@ static char *_do_lv_origin_dup(struct dm_pool *mem, const struct logical_volume
if (uuid)
return lv_uuid_dup(mem, origin_lv);
- else
- return lv_name_dup(mem, origin_lv);
+
+ return lv_name_dup(mem, origin_lv);
}
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -650,6 +650,7 @@ char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
if (!list_lv_modules(mem, lv, modules))
return_NULL;
+
return tags_format_and_copy(mem, modules);
}
@@ -675,8 +676,8 @@ static char *_do_lv_mirror_log_dup(struct dm_pool *mem, const struct logical_vol
if (uuid)
return lv_uuid_dup(mem, mirror_log_lv);
- else
- return lv_name_dup(mem, mirror_log_lv);
+
+ return lv_name_dup(mem, mirror_log_lv);
}
char *lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -708,8 +709,8 @@ static char *_do_lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume
if (uuid)
return lv_uuid_dup(mem, pool_lv);
- else
- return lv_name_dup(mem, pool_lv);
+
+ return lv_name_dup(mem, pool_lv);
}
char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -741,8 +742,8 @@ static char *_do_lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume
if (uuid)
return lv_uuid_dup(mem, data_lv);
- else
- return lv_name_dup(mem, data_lv);
+
+ return lv_name_dup(mem, data_lv);
}
char *lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -774,8 +775,8 @@ static char *_do_lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_vo
if (uuid)
return lv_uuid_dup(mem, metadata_lv);
- else
- return lv_name_dup(mem, metadata_lv);
+
+ return lv_name_dup(mem, metadata_lv);
}
char *lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -792,7 +793,8 @@ const char *lv_layer(const struct logical_volume *lv)
{
if (lv_is_thin_pool(lv))
return "tpool";
- else if (lv_is_origin(lv) || lv_is_external_origin(lv))
+
+ if (lv_is_origin(lv) || lv_is_external_origin(lv))
return "real";
return NULL;
@@ -841,8 +843,8 @@ static char *_do_lv_convert_lv_dup(struct dm_pool *mem, const struct logical_vol
if (uuid)
return lv_uuid_dup(mem, convert_lv);
- else
- return lv_name_dup(mem, convert_lv);
+
+ return lv_name_dup(mem, convert_lv);
}
char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
@@ -877,8 +879,8 @@ static char *_do_lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume
if (uuid)
return pv_uuid_dup(mem, pvseg->pv);
- else
- return pv_name_dup(mem, pvseg->pv);
+
+ return pv_name_dup(mem, pvseg->pv);
}
}
@@ -1104,12 +1106,8 @@ int lv_raid_healthy(const struct logical_volume *lv)
if (!lv_raid_dev_health(raid_seg->lv, &raid_health))
return_0;
- if (lv_is_raid(lv)) {
- if (strchr(raid_health, 'D'))
- return 0;
- else
- return 1;
- }
+ if (lv_is_raid(lv))
+ return (strchr(raid_health, 'D')) ? 0 : 1;
/* Find out which sub-LV this is. */
for (s = 0; s < raid_seg->area_count; s++)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 0b90705..5c2e722 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -990,7 +990,8 @@ static uint32_t _raid_data_copies(struct lv_segment *seg)
*/
if (seg_is_raid10(seg))
return 2;
- else if (seg_is_raid1(seg))
+
+ if (seg_is_raid1(seg))
return seg->area_count;
return seg->segtype->parity_devs + 1;
@@ -1531,11 +1532,11 @@ int historical_glv_remove(struct generic_logical_volume *glv)
log_error(INTERNAL_ERROR "historical_glv_remove: historical LV %s/-%s not found ",
hlv->vg->name, hlv->name);
return 0;
- } else {
- log_verbose("Historical LV %s/-%s already on removed list ",
- hlv->vg->name, hlv->name);
- return 1;
}
+
+ log_verbose("Historical LV %s/-%s already on removed list ",
+ hlv->vg->name, hlv->name);
+ return 1;
}
if ((origin_glv = hlv->indirect_origin) &&
@@ -2057,7 +2058,7 @@ static int _comp_area(const void *l, const void *r)
if (lhs->used < rhs->used)
return 1;
- else if (lhs->used > rhs->used)
+ if (lhs->used > rhs->used)
return -1;
return 0;
@@ -5773,7 +5774,9 @@ struct logical_volume *lv_create_empty(const char *name,
log_error("Failed to generate unique name for the new "
"logical volume");
return NULL;
- } else if (lv_name_is_used_in_vg(vg, name, &historical)) {
+ }
+
+ if (lv_name_is_used_in_vg(vg, name, &historical)) {
log_error("Unable to create LV %s in Volume Group %s: "
"name already in use%s.", name, vg->name,
historical ? " by historical LV" : "");
@@ -6000,7 +6003,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
log_error("Can't remove logical volume %s used by a pool.",
display_lvname(lv));
return 0;
- } else if (lv_is_thin_volume(lv)) {
+ }
+
+ if (lv_is_thin_volume(lv)) {
if (!(pool_lv = first_seg(lv)->pool_lv)) {
log_error(INTERNAL_ERROR "Thin LV %s without pool.",
display_lvname(lv));
@@ -6036,9 +6041,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
display_lvname(lv)) == 'n') {
log_error("Logical volume %s not removed.", display_lvname(lv));
return 0;
- } else {
- ask_discard = 0;
}
+
+ ask_discard = 0;
}
}
@@ -6269,18 +6274,21 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
display_lvname(lv));
return 0;
}
+
if ((snap_percent != DM_PERCENT_INVALID) &&
(snap_percent != LVM_PERCENT_MERGE_FAILED)) {
log_error("Can't remove merging snapshot logical volume %s.",
display_lvname(lv));
return 0;
- } else if ((snap_percent == LVM_PERCENT_MERGE_FAILED) &&
- (force == PROMPT) &&
- yes_no_prompt("Removing snapshot %s that failed to merge "
- "may leave origin %s inconsistent. Proceed? [y/n]: ",
- display_lvname(lv),
- display_lvname(origin_from_cow(lv))) == 'n')
- goto no_remove;
+ }
+
+ if ((snap_percent == LVM_PERCENT_MERGE_FAILED) &&
+ (force == PROMPT) &&
+ yes_no_prompt("Removing snapshot %s that failed to merge "
+ "may leave origin %s inconsistent. Proceed? [y/n]: ",
+ display_lvname(lv),
+ display_lvname(origin_from_cow(lv))) == 'n')
+ goto no_remove;
}
} else if (!level && lv_is_virtual_origin(origin = origin_from_cow(lv)))
/* If this is a sparse device, remove its origin too. */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 45495dc..d8f993c 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -198,7 +198,9 @@ static int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
log_error("Physical volume '%s' is already in volume group "
"'%s'", pv_name, pv->vg_name);
return 0;
- } else if (!new_pv) {
+ }
+
+ if (!new_pv) {
if ((used = is_used_pv(pv)) < 0)
return_0;
@@ -730,7 +732,9 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
log_error("%s not identified as an existing "
"physical volume", pv_name);
return 0;
- } else if (!pv && pp) {
+ }
+
+ if (!pv && pp) {
if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
return_0;
new_pv = 1;
@@ -5725,10 +5729,10 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
log_error("Cannot access VG %s due to failed lock.", vg->name);
*failure |= FAILED_LOCK_MODE;
return 0;
- } else {
- log_warn("Reading VG %s without a lock.", vg->name);
- return 1;
}
+
+ log_warn("Reading VG %s without a lock.", vg->name);
+ return 1;
}
if (test_mode()) {
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 52e1488..7496ddc 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -1532,8 +1532,8 @@ const char *get_pvmove_pvname_from_lv(const struct logical_volume *lv)
if (pvmove_lv)
return get_pvmove_pvname_from_lv_mirr(pvmove_lv);
- else
- return NULL;
+
+ return NULL;
}
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
@@ -2170,7 +2170,9 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
return _add_mirrors_that_preserve_segments(lv, MIRROR_BY_SEG,
mirrors, region_size,
pvs, alloc);
- } else if (flags & MIRROR_BY_SEGMENTED_LV) {
+ }
+
+ if (flags & MIRROR_BY_SEGMENTED_LV) {
if (stripes > 1) {
log_error("Striped-mirroring is not supported on "
"segment-by-segment mirroring.");
@@ -2180,7 +2182,9 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
return _add_mirrors_that_preserve_segments(lv, MIRROR_BY_SEGMENTED_LV,
mirrors, region_size,
pvs, alloc);
- } else if (flags & MIRROR_BY_LV) {
+ }
+
+ if (flags & MIRROR_BY_LV) {
if (!mirrors)
return add_mirror_log(cmd, lv, log_count,
region_size, pvs, alloc);
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index a8cd763..de6644e 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -358,10 +358,11 @@ static uint32_t _overlap_pe(const struct pv_segment *pvseg,
start = max(pvseg->pe, per->start);
end = min(pvseg->pe + pvseg->len, per->start + per->count);
+
if (end < start)
return 0;
- else
- return end - start;
+
+ return end - start;
}
/*
@@ -608,8 +609,8 @@ static int pv_resize(struct physical_volume *pv,
if (new_pe_count > old_pe_count)
return _extend_pv(pv, vg, old_pe_count, new_pe_count);
- else
- return _reduce_pv(pv, vg, old_pe_count, new_pe_count);
+
+ return _reduce_pv(pv, vg, old_pe_count, new_pe_count);
}
return 1;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 84c14ba..d96eceb 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1251,10 +1251,13 @@ uint32_t lv_raid_data_copies(const struct segment_type *segtype, uint32_t area_c
if (segtype_is_any_raid10(segtype))
/* FIXME: change for variable number of data copies */
return 2;
- else if (segtype_is_mirrored(segtype))
+
+ if (segtype_is_mirrored(segtype))
return area_count;
- else if (segtype_is_striped_raid(segtype))
+
+ if (segtype_is_striped_raid(segtype))
return segtype->parity_devs + 1;
+
return 1;
}
@@ -4807,8 +4810,8 @@ static int _raid0_meta_change_wrapper(struct logical_volume *lv,
if (alloc_metadata_devs)
return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, NULL);
- else
- return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, &removal_lvs);
+
+ return _raid0_add_or_remove_metadata_lvs(lv, 1, allocate_pvs, &removal_lvs);
}
static int _raid0_to_striped_wrapper(struct logical_volume *lv,
@@ -6040,8 +6043,9 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
log_error("Convert %s LV %s to 2 images first.",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
+ }
- } else if (segtype_is_striped(*segtype) ||
+ if (segtype_is_striped(*segtype) ||
segtype_is_any_raid0(*segtype) ||
segtype_is_raid10(*segtype))
seg_flag = SEG_RAID5_N;
@@ -6056,8 +6060,9 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
log_error("Convert %s LV %s to 2 stripes first (i.e. --stripes 1).",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
+ }
- } else if (seg_is_raid4(seg_from) &&
+ if (seg_is_raid4(seg_from) &&
segtype_is_any_raid5(*segtype) &&
!segtype_is_raid5_n(*segtype))
seg_flag = SEG_RAID5_N;
@@ -6081,8 +6086,9 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
log_error("Convert %s LV %s to minimum 4 stripes first (i.e. --stripes 3).",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
+ }
- } else if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
+ if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
seg_flag = SEG_RAID6_N_6;
else
seg_flag = _raid_seg_flag_5_to_6(seg_from);
@@ -6118,12 +6124,12 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
log_error("Convert %s LV %s to raid4/raid5 first.",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
+ }
- } else if (seg_from->area_count != 2) {
+ if (seg_from->area_count != 2) {
log_error("Convert %s LV %s to 2 stripes first (i.e. --stripes 1).",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
-
}
/* raid10 -> ... */
@@ -6352,7 +6358,9 @@ int lv_raid_convert(struct logical_volume *lv,
log_error("%s must be active to perform this operation.",
display_lvname(lv));
return 0;
- } else if (vg_is_clustered(lv->vg) &&
+ }
+
+ if (vg_is_clustered(lv->vg) &&
!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
/* In clustered VGs, the LV must be active on this node exclusively. */
log_error("%s must be active exclusive locally to "
@@ -6710,17 +6718,23 @@ static int _lv_raid_rebuild_or_replace(struct logical_volume *lv,
log_print_unless_silent("%s does not contain devices specified to %s.",
display_lvname(lv), action_str);
return 1;
- } else if (match_count == raid_seg->area_count) {
+ }
+
+ if (match_count == raid_seg->area_count) {
log_error("Unable to %s all PVs from %s at once.",
action_str, display_lvname(lv));
return 0;
- } else if (raid_seg->segtype->parity_devs &&
- (match_count > raid_seg->segtype->parity_devs)) {
+ }
+
+ if (raid_seg->segtype->parity_devs &&
+ (match_count > raid_seg->segtype->parity_devs)) {
log_error("Unable to %s more than %u PVs from (%s) %s.",
action_str, raid_seg->segtype->parity_devs,
lvseg_name(raid_seg), display_lvname(lv));
return 0;
- } else if (seg_is_raid10(raid_seg)) {
+ }
+
+ if (seg_is_raid10(raid_seg)) {
uint32_t i, rebuilds_per_group = 0;
/* FIXME: We only support 2-way mirrors (i.e. 2 data copies) in RAID10 currently */
uint32_t copies = 2;
@@ -7039,8 +7053,10 @@ static int _partial_raid_lv_is_redundant(const struct logical_volume *lv)
log_verbose("All components of raid LV %s have failed.",
display_lvname(lv));
return 0; /* Insufficient redundancy to activate */
- } else if (raid_seg->segtype->parity_devs &&
- (failed_components > raid_seg->segtype->parity_devs)) {
+ }
+
+ if (raid_seg->segtype->parity_devs &&
+ (failed_components > raid_seg->segtype->parity_devs)) {
log_verbose("More than %u components from %s %s have failed.",
raid_seg->segtype->parity_devs,
lvseg_name(raid_seg),
diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c
index aaf2296..8f43f8b 100644
--- a/lib/replicator/replicator.c
+++ b/lib/replicator/replicator.c
@@ -627,7 +627,9 @@ static int _replicator_dev_add_target_line(struct dev_manager *dm,
if (!(rdev_dlid = build_dm_uuid(mem, seg->lv->rdevice->lv, NULL)))
return_0;
return dm_tree_node_add_target_area(node, NULL, rdev_dlid, 0);
- } else if (seg->lv->rdevice->rsite->site_index) {
+ }
+
+ if (seg->lv->rdevice->rsite->site_index) {
log_error("Active site with site_index != 0 (%s, %d)",
seg->lv->rdevice->rsite->name,
seg->lv->rdevice->rsite->site_index);
diff --git a/lib/report/report.c b/lib/report/report.c
index 71fe35a..89110f0 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -732,7 +732,9 @@ static int _check_time_items(struct time_info *info)
if (label_date) {
log_error("Ambiguous date specification found at \"%s\".", ti->s);
return 0;
- } else if (_is_time_label_date(ti->prop->id))
+ }
+
+ if (_is_time_label_date(ti->prop->id))
label_date = 1;
}
@@ -749,7 +751,9 @@ static int _check_time_items(struct time_info *info)
if (label_time) {
log_error("Ambiguous time specification found at \"%s\".", ti->s);
return 0;
- } else if (_is_time_label_time(ti->prop->id))
+ }
+
+ if (_is_time_label_time(ti->prop->id))
label_time = 1;
}
}
@@ -1251,9 +1255,9 @@ static int _binary_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (cmd->report_binary_values_as_numeric)
/* "0"/"1" */
return _field_set_value(field, bin_value ? _str_one : _str_zero, bin_value ? &_one64 : &_zero64);
- else
- /* blank/"word" */
- return _field_set_value(field, bin_value ? word : "", bin_value ? &_one64 : &_zero64);
+
+ /* blank/"word" */
+ return _field_set_value(field, bin_value ? word : "", bin_value ? &_one64 : &_zero64);
}
static int _binary_undef_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1263,8 +1267,8 @@ static int _binary_undef_disp(struct dm_report *rh, struct dm_pool *mem __attrib
if (cmd->report_binary_values_as_numeric)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(num_undef_64), &GET_TYPE_RESERVED_VALUE(num_undef_64));
- else
- return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
+
+ return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1772,8 +1776,8 @@ static int _do_loglv_disp(struct dm_report *rh, struct dm_pool *mem,
if (uuid)
return _uuid_disp(rh, mem, field, &mirror_log_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, mirror_log_lv, private);
+
+ return _lvname_disp(rh, mem, field, mirror_log_lv, private);
}
static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1829,8 +1833,8 @@ static int _do_datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute
if (uuid)
return _uuid_disp(rh, mem, field, &data_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, data_lv, private);
+
+ return _lvname_disp(rh, mem, field, data_lv, private);
}
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1860,8 +1864,8 @@ static int _do_metadatalv_disp(struct dm_report *rh, struct dm_pool *mem __attri
if (uuid)
return _uuid_disp(rh, mem, field, &metadata_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, metadata_lv, private);
+
+ return _lvname_disp(rh, mem, field, metadata_lv, private);
}
static int _metadatalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1891,8 +1895,8 @@ static int _do_poollv_disp(struct dm_report *rh, struct dm_pool *mem,
if (uuid)
return _uuid_disp(rh, mem, field, &pool_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, pool_lv, private);
+
+ return _lvname_disp(rh, mem, field, pool_lv, private);
}
static int _poollv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -1948,8 +1952,8 @@ static int _do_origin_disp(struct dm_report *rh, struct dm_pool *mem,
if (uuid)
return _uuid_disp(rh, mem, field, &origin_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, origin_lv, private);
+
+ return _lvname_disp(rh, mem, field, origin_lv, private);
}
static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -2241,8 +2245,8 @@ static int _do_convertlv_disp(struct dm_report *rh, struct dm_pool *mem,
if (uuid)
return _uuid_disp(rh, mem, field, &convert_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, convert_lv, private);
+
+ return _lvname_disp(rh, mem, field, convert_lv, private);
}
static int _convertlv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -2361,9 +2365,9 @@ static int _lvwhenfull_disp(struct dm_report *rh, struct dm_pool *mem,
if (lv->status & LV_ERROR_WHEN_FULL)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_when_full_error),
GET_FIELD_RESERVED_VALUE(lv_when_full_error));
- else
- return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_when_full_queue),
- GET_FIELD_RESERVED_VALUE(lv_when_full_queue));
+
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_when_full_queue),
+ GET_FIELD_RESERVED_VALUE(lv_when_full_queue));
}
return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_when_full_undef),
@@ -3584,8 +3588,8 @@ static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
*/
if (lv_is_active_locally(lv))
return _binary_undef_disp(rh, mem, field, private);
- else
- active_remotely = lv_is_active_but_not_locally(lv);
+
+ active_remotely = lv_is_active_but_not_locally(lv);
} else
active_remotely = 0;
@@ -3725,7 +3729,7 @@ static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
if (lvdm->seg_status.type != SEG_STATUS_CACHE)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(health_undef),
GET_FIELD_RESERVED_VALUE(health_undef));
- else if (lvdm->seg_status.cache->fail)
+ if (lvdm->seg_status.cache->fail)
health = "failed";
else if (lvdm->seg_status.cache->read_only)
health = "metadata_read_only";
@@ -3733,7 +3737,7 @@ static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
if (lvdm->seg_status.type != SEG_STATUS_THIN_POOL)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(health_undef),
GET_FIELD_RESERVED_VALUE(health_undef));
- else if (lvdm->seg_status.thin_pool->fail)
+ if (lvdm->seg_status.thin_pool->fail)
health = "failed";
else if (lvdm->seg_status.thin_pool->out_of_data_space)
health = "out_of_data";
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 65e75f6..c47e084 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -208,8 +208,9 @@ static int _get_proc_number(const char *file, const char *name,
if (require_module_loaded) {
log_error("%s: No entry for %s found", file, name);
return 0;
- } else
- return 2;
+ }
+
+ return 2;
}
return 1;
@@ -368,11 +369,11 @@ int dm_is_dm_major(uint32_t major)
return 0;
return dm_bit(_dm_bitset, major) ? 1 : 0;
}
- else {
- if (!_dm_device_major)
- return 0;
- return (major == _dm_device_major) ? 1 : 0;
- }
+
+ if (!_dm_device_major)
+ return 0;
+
+ return (major == _dm_device_major) ? 1 : 0;
}
static void _close_control_fd(void)
@@ -1704,7 +1705,9 @@ static int _do_dm_ioctl_unmangle_string(char *str, const char *str_name,
log_debug_activation("_do_dm_ioctl_unmangle_string: failed to "
"unmangle %s \"%s\"", str_name, str);
return 0;
- } else if (r)
+ }
+
+ if (r)
memcpy(str, buf, strlen(buf) + 1);
return 1;
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index d8cf946..e983b03 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1137,13 +1137,12 @@ static int _rename_dev_node(const char *old_name, const char *new_name,
errno == ENOENT)
/* assume udev already deleted this */
return 1;
- else {
- log_warn("The node %s should have been renamed to %s "
- "by udev but old node is still present. "
- "Falling back to direct old node removal.",
- oldpath, newpath);
- return _rm_dev_node(old_name, 0);
- }
+
+ log_warn("The node %s should have been renamed to %s "
+ "by udev but old node is still present. "
+ "Falling back to direct old node removal.",
+ oldpath, newpath);
+ return _rm_dev_node(old_name, 0);
}
if (unlink(newpath) < 0) {
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index a5100d4..d2371db 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1013,16 +1013,18 @@ static int _field_match(struct dm_report *rh, const char *field, size_t flen,
rh->report_types |= implicit ? _implicit_report_fields[f].type
: rh->fields[f].type;
return 1;
- } else
- return _add_field(rh, f, implicit, 0) ? 1 : 0;
+ }
+
+ return _add_field(rh, f, implicit, 0) ? 1 : 0;
}
if ((type = _all_match(rh, field, flen))) {
if (report_type_only) {
rh->report_types |= type;
return 1;
- } else
- return _add_all_fields(rh, type);
+ }
+
+ return _add_all_fields(rh, type);
}
return 0;
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index cbaae22..803ae56 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4538,10 +4538,11 @@ static int _ls(CMD_ARGS)
if ((_switches[TARGET_ARG] && _target) ||
(_switches[EXEC_ARG] && _command_to_exec))
return _status(cmd, NULL, argc, argv, NULL, 0);
- else if ((_switches[TREE_ARG]))
+
+ if ((_switches[TREE_ARG]))
return _display_tree(cmd, NULL, 0, NULL, NULL, 0);
- else
- return _process_all(cmd, NULL, argc, argv, 0, _display_name);
+
+ return _process_all(cmd, NULL, argc, argv, 0, _display_name);
}
static int _mangle(CMD_ARGS)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index cfdf5de..d90e675 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -341,9 +341,9 @@ static int _lvconvert_poll_by_id(struct cmd_context *cmd, struct poll_operation_
(MERGING | (is_merging_origin_thin ? THIN_VOLUME : SNAPSHOT)),
is_merging_origin_thin ? &_lvconvert_thin_merge_fns : &_lvconvert_merge_fns,
"Merged", id);
- else
- return poll_daemon(cmd, background, CONVERTING,
- &_lvconvert_mirror_fns, "Converted", id);
+
+ return poll_daemon(cmd, background, CONVERTING,
+ &_lvconvert_mirror_fns, "Converted", id);
}
int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
@@ -1313,7 +1313,9 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
log_error("Linear LV %s cannot be converted to %s.",
display_lvname(lv), lp->type_str);
return 0;
- } else if (!strcmp(lp->type_str, SEG_TYPE_NAME_RAID1)) {
+ }
+
+ if (!strcmp(lp->type_str, SEG_TYPE_NAME_RAID1)) {
log_error("Raid conversions of LV %s require -m/--mirrors.",
display_lvname(lv));
return 0;
@@ -3398,10 +3400,11 @@ static int _lvconvert_repair_pvs_or_thinpool_single(struct cmd_context *cmd, str
{
if (lv_is_thin_pool(lv))
return _lvconvert_repair_thinpool(cmd, lv, handle);
- else if (lv_is_raid(lv) || lv_is_mirror(lv))
+
+ if (lv_is_raid(lv) || lv_is_mirror(lv))
return _lvconvert_repair_pvs(cmd, lv, handle);
- else
- return_ECMD_FAILED;
+
+ return_ECMD_FAILED;
}
/*
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index f464896..d2199f5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -628,7 +628,9 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
log_error("Only up to %u stripes in %s supported currently.",
max_images / lp->mirrors, lp->segtype->name);
return 0;
- } else if (seg_is_mirrored(lp)) {
+ }
+
+ if (seg_is_mirrored(lp)) {
if (lp->mirrors > max_images) {
log_error("Only up to %u mirrors in %s supported currently.",
max_images, lp->segtype->name);
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 33fe947..a4df22e 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -559,17 +559,18 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *id
}
return r ? ECMD_PROCESSED : ECMD_FAILED;
- } else {
- /* process all in-flight operations */
- if (!(handle = init_processing_handle(cmd, NULL))) {
- log_error("Failed to initialize processing handle.");
- return ECMD_FAILED;
- } else {
- _lvmpolld_poll_for_all_vgs(cmd, parms, handle);
- destroy_processing_handle(cmd, handle);
- return ECMD_PROCESSED;
- }
}
+
+ /* process all in-flight operations */
+ if (!(handle = init_processing_handle(cmd, NULL))) {
+ log_error("Failed to initialize processing handle.");
+ return ECMD_FAILED;
+ }
+
+ _lvmpolld_poll_for_all_vgs(cmd, parms, handle);
+ destroy_processing_handle(cmd, handle);
+
+ return ECMD_PROCESSED;
}
#else
# define _lvmpoll_daemon(cmd, id, parms) (ECMD_FAILED)
@@ -592,7 +593,8 @@ static int _poll_daemon(struct cmd_context *cmd, struct poll_operation_id *id,
daemon_mode = become_daemon(cmd, 0);
if (daemon_mode == 0)
return ECMD_PROCESSED; /* Parent */
- else if (daemon_mode == 1)
+
+ if (daemon_mode == 1)
parms->progress_display = 0; /* Child */
/* FIXME Use wait_event (i.e. interval = 0) and */
/* fork one daemon per copy? */
@@ -680,9 +682,8 @@ int poll_daemon(struct cmd_context *cmd, unsigned background,
if (lvmpolld_use())
return _lvmpoll_daemon(cmd, id, &parms);
- else {
- /* classical polling allows only PMVOVE or 0 values */
- parms.lv_type &= PVMOVE;
- return _poll_daemon(cmd, id, &parms);
- }
+
+ /* classical polling allows only PMVOVE or 0 values */
+ parms.lv_type &= PVMOVE;
+ return _poll_daemon(cmd, id, &parms);
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 9e89ed7..5e3fedd 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -938,9 +938,9 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
if (clustery) {
log_error("The --clustered option requires clvmd (locking_type=3).");
return 0;
- } else {
- lock_type = "none";
}
+
+ lock_type = "none";
}
} else if (arg_is_set(cmd, shared_ARG)) {
@@ -4676,11 +4676,11 @@ int pvcreate_params_from_args(struct cmd_context *cmd, struct pvcreate_params *p
log_error("labelsector must be less than %lu.",
LABEL_SCAN_SECTORS);
return 0;
- } else {
- pp->pva.label_sector = arg_int64_value(cmd, labelsector_ARG,
- DEFAULT_LABELSECTOR);
}
+ pp->pva.label_sector = arg_int64_value(cmd, labelsector_ARG,
+ DEFAULT_LABELSECTOR);
+
if (!(cmd->fmt->features & FMT_MDAS) &&
(arg_is_set(cmd, pvmetadatacopies_ARG) ||
arg_is_set(cmd, metadatasize_ARG) ||
@@ -5084,7 +5084,9 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
log_error("Can't get device size of %s.", pv_dev_name(pv));
dm_list_move(&pp->arg_fail, &pd->list);
return 1;
- } else if (new_size != size)
+ }
+
+ if (new_size != size)
need_size_prompt = 1;
}
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index 7fc64b0..f4b0b6f 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -60,13 +60,16 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
return vgs(cmd, argc, argv);
- } else if (arg_is_set(cmd, aligned_ARG) ||
- arg_is_set(cmd, binary_ARG) ||
- arg_is_set(cmd, noheadings_ARG) ||
- arg_is_set(cmd, options_ARG) ||
- arg_is_set(cmd, separator_ARG) ||
- arg_is_set(cmd, sort_ARG) || arg_is_set(cmd, unbuffered_ARG)) {
- log_error("Incompatible options selected");
+ }
+
+ if (arg_is_set(cmd, aligned_ARG) ||
+ arg_is_set(cmd, binary_ARG) ||
+ arg_is_set(cmd, noheadings_ARG) ||
+ arg_is_set(cmd, options_ARG) ||
+ arg_is_set(cmd, separator_ARG) ||
+ arg_is_set(cmd, sort_ARG) ||
+ arg_is_set(cmd, unbuffered_ARG)) {
+ log_error("Incompatible options selected.");
return EINVALID_CMD_LINE;
}
6 years, 9 months
master - cleanup: add braces in macro
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0d0a3397c22b9d53425...
Commit: 0d0a3397c22b9d5342584299acd814f6c8221c18
Parent: b37e4e3f90b005e116b46949d55f95b9d1470f5b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 16:17:30 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 20 11:18:29 2017 +0200
cleanup: add braces in macro
---
lib/config/config.c | 16 ++++++++--------
lib/device/dev-md.c | 2 +-
lib/format_text/export.c | 2 +-
lib/format_text/import_vsn1.c | 6 +++---
lib/locking/lvmlockd.c | 2 +-
lib/metadata/raid_manip.c | 2 +-
lib/report/report.c | 6 +++---
libdm/libdm-report.c | 4 ++--
tools/command.c | 2 +-
tools/dmsetup.c | 2 +-
tools/reporter.c | 10 +++++-----
tools/toollib.c | 4 ++--
12 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 5c5916b..daf5fa3 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -65,11 +65,11 @@ struct config_source {
* Map each ID to respective definition of the configuration item.
*/
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
-#define cfg_section(id, name, parent, flags, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, {0}, deprecated_since_version, deprecation_comment, comment},
-#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, deprecated_since_version, deprecation_comment, comment},
-#define cfg_runtime(id, name, parent, flags, type, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, deprecation_comment, comment},
-#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, deprecated_since_version, deprecation_comment, comment},
-#define cfg_array_runtime(id, name, parent, flags, types, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, deprecation_comment, comment},
+#define cfg_section(id, name, parent, flags, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, (flags), since_version, {0}, deprecated_since_version, deprecation_comment, comment},
+#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.v_##type = (default_value)}, (flags), since_version, {.v_UNCONFIGURED = (unconfigured_value)}, deprecated_since_version, deprecation_comment, comment},
+#define cfg_runtime(id, name, parent, flags, type, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, (flags) | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, (deprecation_comment), comment},
+#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | (types), {.v_CFG_TYPE_STRING = (default_value)}, (flags), (since_version), {.v_UNCONFIGURED = (unconfigured_value)}, deprecated_since_version, deprecation_comment, comment},
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | (types), {.fn_CFG_TYPE_STRING = get_default_##id}, (flags) | CFG_DEFAULT_RUN_TIME, (since_version), {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, deprecation_comment, comment},
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -619,9 +619,9 @@ struct timespec config_file_timestamp(struct dm_config_tree *cft)
}
#define cfg_def_get_item_p(id) (&_cfg_def_items[id])
-#define cfg_def_get_default_unconfigured_value_hint(cmd,item) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_unconfigured_value.fn_UNCONFIGURED(cmd) : item->default_unconfigured_value.v_UNCONFIGURED)
-#define cfg_def_get_default_value_hint(cmd,item,type,profile) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_value.fn_##type(cmd,profile) : item->default_value.v_##type)
-#define cfg_def_get_default_value(cmd,item,type,profile) (item->flags & CFG_DEFAULT_UNDEFINED ? 0 : cfg_def_get_default_value_hint(cmd,item,type,profile))
+#define cfg_def_get_default_unconfigured_value_hint(cmd,item) (((item)->flags & CFG_DEFAULT_RUN_TIME) ? (item)->default_unconfigured_value.fn_UNCONFIGURED(cmd) : (item)->default_unconfigured_value.v_UNCONFIGURED)
+#define cfg_def_get_default_value_hint(cmd,item,type,profile) (((item)->flags & CFG_DEFAULT_RUN_TIME) ? (item)->default_value.fn_##type(cmd,profile) : (item)->default_value.v_##type)
+#define cfg_def_get_default_value(cmd,item,type,profile) ((item)->flags & CFG_DEFAULT_UNDEFINED ? 0 : cfg_def_get_default_value_hint(cmd,item,type,profile))
static int _cfg_def_make_path(char *buf, size_t buf_size, int id, cfg_def_item_t *item, int xlate)
{
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 3dbe831..d0e69a1 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -28,7 +28,7 @@
#define MD_SB_MAGIC 0xa92b4efc
#define MD_RESERVED_BYTES (64 * 1024ULL)
#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
-#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) \
+#define MD_NEW_SIZE_SECTORS(x) (((x) & ~(MD_RESERVED_SECTORS - 1)) \
- MD_RESERVED_SECTORS)
#define MD_MAX_SYSFS_SIZE 64
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 7a84909..9fede20 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -42,7 +42,7 @@ typedef int (*nl_fn) (struct formatter * f);
#define _out_with_comment(f, buffer, fmt, ap) \
do { \
va_start(ap, fmt); \
- r = f->out_with_comment(f, buffer, fmt, ap); \
+ r = (f)->out_with_comment((f), (buffer), (fmt), ap); \
va_end(ap); \
} while (r == -1)
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 7d9257e..9267d45 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -37,13 +37,13 @@ typedef int (*section_fn) (struct format_instance * fid,
unsigned report_missing_devices);
#define _read_int32(root, path, result) \
- dm_config_get_uint32(root, path, (uint32_t *) result)
+ dm_config_get_uint32(root, path, (uint32_t *) (result))
#define _read_uint32(root, path, result) \
- dm_config_get_uint32(root, path, result)
+ dm_config_get_uint32(root, path, (result))
#define _read_uint64(root, path, result) \
- dm_config_get_uint64(root, path, result)
+ dm_config_get_uint64(root, path, (result))
/*
* Logs an attempt to read an invalid format file.
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 34b3882..94a674f 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -134,7 +134,7 @@ static void _flags_str_to_lockd_flags(const char *flags_str, uint32_t *lockd_fla
* will not return. daemon_reply_int reverts to this
* value if it finds no result value.
*/
-#define NO_LOCKD_RESULT -1000
+#define NO_LOCKD_RESULT (-1000)
static int _lockd_result(daemon_reply reply, int *result, uint32_t *lockd_flags)
{
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index c207970..84c14ba 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -26,7 +26,7 @@ typedef int (*fn_on_lv_t)(struct logical_volume *lv, void *data);
static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg,
struct dm_list *removal_lvs,
int vg_write_requested);
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
static int _check_restriping(uint32_t new_stripes, struct logical_volume *lv)
{
diff --git a/lib/report/report.c b/lib/report/report.c
index de8c06a..71fe35a 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -162,7 +162,7 @@ struct time_prop {
time_id_t granularity;
};
-#define ADD_TIME_PROP(id, flags, granularity) [id] = {id, flags, granularity},
+#define ADD_TIME_PROP(id, flags, granularity) [(id)] = {(id), (flags), (granularity)},
static const struct time_prop _time_props[] = {
ADD_TIME_PROP(TIME_NULL, 0, TIME_NULL)
@@ -228,7 +228,7 @@ struct time_reg {
uint32_t reg_flags;
};
-#define TIME_PROP(id) (_time_props + id)
+#define TIME_PROP(id) (_time_props + (id))
static const struct time_reg _time_reg[] = {
/*
@@ -3915,7 +3915,7 @@ static const struct dm_report_object_type _devtypes_report_types[] = {
#define STR_LIST DM_REPORT_FIELD_TYPE_STRING_LIST
#define SNUM DM_REPORT_FIELD_TYPE_NUMBER
#define FIELD(type, strct, sorttype, head, field, width, func, id, desc, writeable) \
- {type, sorttype, offsetof(type_ ## strct, field), width ? : sizeof(head) - 1, \
+ {type, sorttype, offsetof(type_ ## strct, field), (width) ? : sizeof(head) - 1, \
#id, head, &_ ## func ## _disp, desc},
typedef struct cmd_log_item type_cmd_log_item;
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index a0ad26c..a5100d4 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1426,10 +1426,10 @@ static int _dbl_less_or_equal(double d1, double d2)
}
#define _uint64 *(const uint64_t *)
-#define _uint64arr(var,index) ((const uint64_t *)var)[index]
+#define _uint64arr(var,index) ((const uint64_t *)(var))[(index)]
#define _str (const char *)
#define _dbl *(const double *)
-#define _dblarr(var,index) ((const double *)var)[index]
+#define _dblarr(var,index) ((const double *)(var))[(index)]
static int _do_check_value_is_strictly_reserved(unsigned type, const void *res_val, int res_range,
const void *val, struct field_selection *fs)
diff --git a/tools/command.c b/tools/command.c
index c094f12..bd3c7cc 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -284,7 +284,7 @@ static struct oo_line oo_lines[MAX_OO_LINES];
#define REQUIRED 1 /* required option */
#define OPTIONAL 0 /* optional option */
-#define IGNORE -1 /* ignore option */
+#define IGNORE (-1) /* ignore option */
#define MAX_LINE 1024
#define MAX_LINE_ARGC 256
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 69649ae..cbaae22 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -296,7 +296,7 @@ static uint64_t _new_interval = 0; /* flag top-of-interval */
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
/* Invalid fd value used to signal end-of-reporting. */
-#define TIMER_STOPPED -2
+#define TIMER_STOPPED (-2)
#define NSEC_PER_USEC UINT64_C(1000)
#define NSEC_PER_MSEC UINT64_C(1000000)
diff --git a/tools/reporter.c b/tools/reporter.c
index ad9d5ee..98e3d12 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -780,7 +780,7 @@ static void _del_option_from_list(struct dm_list *sll, const char *prefix,
}
#define _get_report_idx(report_type,single_report_type) \
- (((report_type != FULL) && (report_type == single_report_type)) ? REPORT_IDX_SINGLE : REPORT_IDX_FULL_ ## single_report_type)
+ ((((report_type) != FULL) && ((report_type) == single_report_type)) ? REPORT_IDX_SINGLE : REPORT_IDX_FULL_ ## single_report_type)
static report_idx_t _get_report_idx_from_name(report_type_t report_type, const char *name)
{
@@ -1262,10 +1262,10 @@ out:
#define _set_full_report_single(cmd,args,type,name) \
do { \
- args->single_args[REPORT_IDX_FULL_ ## type].report_type = type; \
- args->single_args[REPORT_IDX_FULL_ ## type].keys = find_config_tree_str(cmd, report_ ## name ## _sort_full_CFG, NULL); \
- args->single_args[REPORT_IDX_FULL_ ## type].options = find_config_tree_str(cmd, report_ ## name ## _cols_full_CFG, NULL); \
- if (!_set_report_prefix_and_name(args, &args->single_args[REPORT_IDX_FULL_ ## type])) \
+ (args)->single_args[REPORT_IDX_FULL_ ## type].report_type = type; \
+ (args)->single_args[REPORT_IDX_FULL_ ## type].keys = find_config_tree_str(cmd, report_ ## name ## _sort_full_CFG, NULL); \
+ (args)->single_args[REPORT_IDX_FULL_ ## type].options = find_config_tree_str(cmd, report_ ## name ## _cols_full_CFG, NULL); \
+ if (!_set_report_prefix_and_name((args), &(args)->single_args[REPORT_IDX_FULL_ ## type])) \
return_0; \
} while (0)
diff --git a/tools/toollib.c b/tools/toollib.c
index 2836aeb..9e89ed7 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -23,8 +23,8 @@
#include <sys/utsname.h>
#define report_log_ret_code(ret_code) report_current_object_cmdlog(REPORT_OBJECT_CMDLOG_NAME, \
- ret_code == ECMD_PROCESSED ? REPORT_OBJECT_CMDLOG_SUCCESS \
- : REPORT_OBJECT_CMDLOG_FAILURE, ret_code)
+ ((ret_code) == ECMD_PROCESSED) ? REPORT_OBJECT_CMDLOG_SUCCESS \
+ : REPORT_OBJECT_CMDLOG_FAILURE, (ret_code))
struct device_id_list {
struct dm_list list;
6 years, 9 months
master - cleanup: constify used parameter
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b37e4e3f90b005e116b...
Commit: b37e4e3f90b005e116b46949d55f95b9d1470f5b
Parent: e769e3d3bfd5eaccd5a9043b5641bc73550e5528
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 16:15:15 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 20 11:18:29 2017 +0200
cleanup: constify used parameter
---
libdm/libdm-deptree.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 6ea710d..cf4fd62 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2365,7 +2365,7 @@ static int _2_if_value(unsigned p)
}
/* Return number of bits passed in @bits assuming 2 * 64 bit size */
-static int _get_params_count(uint64_t *bits)
+static int _get_params_count(const uint64_t *bits)
{
int r = 0;
int i = RAID_BITMAP_SIZE;
6 years, 9 months
master - dmsetup: simplify check of parsed cookie value
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e769e3d3bfd5eaccd5a...
Commit: e769e3d3bfd5eaccd5a9043b5641bc73550e5528
Parent: 86d7adc2a587228f30c4fbceed82005ccd7b0efb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 22:04:37 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 20 11:18:16 2017 +0200
dmsetup: simplify check of parsed cookie value
Improving parsing error detection for strtoul.
---
tools/dmsetup.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 2eed39e..69649ae 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -1396,15 +1396,14 @@ static uint32_t _get_cookie_value(const char *str_value)
char *p;
errno = 0;
- if (!(value = strtoul(str_value, &p, 0)) ||
- *p ||
- (value == ULONG_MAX && errno == ERANGE) ||
- value > 0xFFFFFFFF) {
+ value = strtoul(str_value, &p, 0);
+
+ if (errno || !value || (*p) || (value > UINT32_MAX)) {
err("Incorrect cookie value");
return 0;
}
- else
- return (uint32_t) value;
+
+ return (uint32_t) value;
}
static int _udevflags(CMD_ARGS)
6 years, 9 months
master - tests: aux.sh fix wait_pvmove_lv_ready
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=86d7adc2a587228f30c...
Commit: 86d7adc2a587228f30c4fbceed82005ccd7b0efb
Parent: 43dbfee32a0758c84b54aff41d1f91b2c974117f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 19 12:15:39 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 19 12:15:39 2017 +0200
tests: aux.sh fix wait_pvmove_lv_ready
Ignore error if the 'queried' LV is still not available
(since 'get' now properly returns failure when LV is missing)
---
test/lib/aux.sh | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 7ab3885..e620e81 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -488,15 +488,16 @@ teardown_devs() {
}
kill_sleep_kill_() {
- pidfile=$1
- slow=$2
+ local pidfile=$1
+ local slow=$2
+
if test -s "$pidfile" ; then
pid=$(< "$pidfile")
rm -f "$pidfile"
kill -TERM "$pid" 2>/dev/null || return 0
if test "$slow" -eq 0 ; then sleep .1 ; else sleep 1 ; fi
kill -KILL "$pid" 2>/dev/null || true
- wait=0
+ local wait=0
while ps "$pid" > /dev/null && test "$wait" -le 10; do
sleep .5
wait=$(( wait + 1 ))
@@ -1085,7 +1086,7 @@ prepare_vg() {
}
extend_filter() {
- filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
+ local filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for rx in "$@"; do
filter=$(echo "$filter" | sed -e "s:\[:[ \"$rx\", :")
done
@@ -1097,7 +1098,7 @@ extend_filter_LVMTEST() {
}
hide_dev() {
- filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
+ local filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for dev in "$@"; do
filter=$(echo "$filter" | sed -e "s:\[:[ \"r|$dev|\", :")
done
@@ -1105,7 +1106,7 @@ hide_dev() {
}
unhide_dev() {
- filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
+ local filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for dev in "$@"; do
filter=$(echo "$filter" | sed -e "s:\"r|$dev|\", ::")
done
@@ -1556,8 +1557,7 @@ check_lvmpolld_init_rq_count() {
local ret
ret=$(awk -v vvalue="$2" -v vkey="${3:-lvname}" "$(awk_parse_init_count_in_lvmpolld_dump)" lvmpolld_dump.txt)
test "$ret" -eq "$1" || {
- echo "check_lvmpolld_init_rq_count failed. Expected $1, got $ret"
- return 1
+ die "check_lvmpolld_init_rq_count failed. Expected $1, got $ret"
}
}
@@ -1570,9 +1570,11 @@ wait_pvmove_lv_ready() {
while : ; do
test "$retries" -le 0 && die "Waiting for lvmpolld timed out"
test -n "$lvid" || {
- lvid=$(get lv_field "${1//-//}" vg_uuid,lv_uuid -a 2>/dev/null)
- lvid=${lvid//\ /}
- lvid=${lvid//-/}
+ # wait till wanted LV really appears
+ lvid=$(get lv_field "${1//-//}" vg_uuid,lv_uuid -a 2>/dev/null) && {
+ lvid=${lvid//\ /}
+ lvid=${lvid//-/}
+ }
}
test -z "$lvid" || {
lvmpolld_dump > lvmpolld_dump.txt
@@ -1615,6 +1617,9 @@ hold_device_open() {
# return total memory size in kB units
total_mem() {
+ local a
+ local b
+
while IFS=":" read -r a b ; do
case "$a" in MemTotal*) echo "${b%% kB}" ; break ;; esac
done < /proc/meminfo
6 years, 9 months
master - tests: aus.sh better defaults
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=43dbfee32a0758c84b5...
Commit: 43dbfee32a0758c84b54aff41d1f91b2c974117f
Parent: 466da710e03149187c05dcfd598aa66c32158496
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 18 21:25:03 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 18 21:25:03 2017 +0200
tests: aus.sh better defaults
---
test/lib/aux.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 93345bf..7ab3885 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1563,7 +1563,7 @@ check_lvmpolld_init_rq_count() {
wait_pvmove_lv_ready() {
# given sleep .1 this is about 60 secs of waiting
- local retries=${2:-300}
+ local retries=${2-300}
if [ -e LOCAL_LVMPOLLD ]; then
local lvid=""
@@ -1597,7 +1597,7 @@ wait_pvmove_lv_ready() {
hold_device_open() {
local vgname=$1
local lvname=$2
- local sec=${3:-20} # default 20sec
+ local sec=${3-20} # default 20sec
sleep "$sec" < "$DM_DEV_DIR/$vgname/$lvname" >/dev/null 2>&1 &
SLEEP_PID=$!
6 years, 9 months
master - tests: avoid endless loops
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=466da710e03149187c0...
Commit: 466da710e03149187c05dcfd598aa66c32158496
Parent: 9599645bb6a295aafd6cdf6f793fc9068c5d437f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 18 21:17:51 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 18 21:17:51 2017 +0200
tests: avoid endless loops
If there is some problem with device removal avoid generating very long
error logs...
---
test/shell/pvmove-resume-1.sh | 15 +++++++++++----
test/shell/pvmove-resume-2.sh | 16 ++++++++++++----
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/test/shell/pvmove-resume-1.sh b/test/shell/pvmove-resume-1.sh
index ff10199..ddebcb9 100644
--- a/test/shell/pvmove-resume-1.sh
+++ b/test/shell/pvmove-resume-1.sh
@@ -54,10 +54,17 @@ test_pvmove_resume() {
wait
- while dmsetup status "$vg-$lv1"; do dmsetup remove "$vg-$lv1" || true; done
- while dmsetup status "$vg1-$lv1"; do dmsetup remove "$vg1-$lv1" || true; done
- while dmsetup status "$vg-pvmove0"; do dmsetup remove "$vg-pvmove0" || true; done
- while dmsetup status "$vg1-pvmove0"; do dmsetup remove "$vg1-pvmove0" || true; done
+ local finished
+ for i in {1..100}; do
+ finished=1
+ for d in "$vg-$lv1" "$vg1-$lv1" "$vg-pvmove0" "$vg1-pvmove0" ; do
+ dmsetup status "$d" 2>/dev/null && {
+ dmsetup remove "$d" || finished=0
+ }
+ done
+ test "$finished" -eq 0 || break
+ done
+ test "$finished" -eq 0 && die "Can't remove device"
check lv_attr_bit type $vg/pvmove0 "p"
check lv_attr_bit type $vg1/pvmove0 "p"
diff --git a/test/shell/pvmove-resume-2.sh b/test/shell/pvmove-resume-2.sh
index 50c4233..5e9ad81 100644
--- a/test/shell/pvmove-resume-2.sh
+++ b/test/shell/pvmove-resume-2.sh
@@ -44,9 +44,17 @@ test_pvmove_resume() {
wait
- while dmsetup status "$vg-$lv1"; do dmsetup remove "$vg-$lv1" || true; done
- while dmsetup status "$vg-$lv2"; do dmsetup remove "$vg-$lv2" || true; done
- while dmsetup status "$vg-pvmove0"; do dmsetup remove "$vg-pvmove0" || true; done
+ local finished
+ for i in {1..100}; do
+ finished=1
+ for d in "$vg-$lv1" "$vg-$lv2" "$vg-pvmove0" ; do
+ dmsetup status "$d" 2>/dev/null && {
+ dmsetup remove "$d" || finished=0
+ }
+ done
+ test "$finished" -eq 0 || break
+ done
+ test "$finished" -eq 0 && die "Can't remove device"
check lv_attr_bit type $vg/pvmove0 "p"
@@ -59,7 +67,7 @@ test_pvmove_resume() {
# errors, based on the fact pvmove is killed -9
# Restart clvmd
kill "$(< LOCAL_CLVMD)"
- for i in $(seq 1 100) ; do
+ for i in {1 100} ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
test -e "$CLVMD_PIDFILE" || break
sleep .1
6 years, 9 months
master - tests: aux.sh limit device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9599645bb6a295aafd6...
Commit: 9599645bb6a295aafd6cdf6f793fc9068c5d437f
Parent: 4fa739faf2d30beea5a8423806594f506644a540
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 18 13:14:02 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 18 13:14:02 2017 +0200
tests: aux.sh limit device
During test do a more close selection of visible devices.
If some test leaks a device with LVMTEST prefix, next
test should not be influnced (or parallel running one).
If the test is running in non-/dev dir - it's already protected
by full path with $PREFIX in it - however it test is running
in real /dev dir - there was no such protection and test
were confused when they have seen such leaked device.
---
test/lib/aux.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 20a8a1e..93345bf 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -475,7 +475,7 @@ teardown_devs() {
rm -f DEVICES LOOP
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
- test "${LVM_TEST_PARALLEL:-0}" -eq 1 -o -z "$COMMON_PREFIX" || {
+ test "${LVM_TEST_PARALLEL:-0}" -eq 1 || test -z "$COMMON_PREFIX" || {
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
test ${#stray_loops[@]} -eq 0 || {
teardown_devs_prefixed "$COMMON_PREFIX" 1
@@ -678,7 +678,7 @@ prepare_loop() {
# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer
prepare_scsi_debug_dev() {
local DEV_SIZE=$1
- local SCSI_DEBUG_PARAMS=( ${@:2} )
+ shift # rest of params directly passed to modprobe
local DEBUG_DEV
rm -f debug.log strace.log
@@ -694,7 +694,7 @@ prepare_scsi_debug_dev() {
# NOTE: it will _never_ make sense to pass num_tgts param;
# last param wins.. so num_tgts=1 is imposed
touch SCSI_DEBUG_DEV
- modprobe scsi_debug dev_size_mb="$DEV_SIZE" "${SCSI_DEBUG_PARAMS[@]}" num_tgts=1 || skip
+ modprobe scsi_debug dev_size_mb="$DEV_SIZE" "$@" num_tgts=1 || skip
for i in {1..20} ; do
DEBUG_DEV="/dev/$(grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /)"
@@ -1159,7 +1159,7 @@ devices/cache_dir = "$TESTDIR/etc"
devices/default_data_alignment = 1
devices/dir = "$DM_DEV_DIR"
devices/filter = "a|.*|"
-devices/global_filter = [ "a|$DM_DEV_DIR/mapper/.*pv[0-9_]*$|", "r|.*|" ]
+devices/global_filter = [ "a|$DM_DEV_DIR/mapper/${PREFIX}.*pv[0-9_]*$|", "r|.*|" ]
devices/md_component_detection = 0
devices/scan = "$DM_DEV_DIR"
devices/sysfs_scan = 1
6 years, 9 months
master - lvmcmdline: enhance locales check
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4fa739faf2d30beea5a...
Commit: 4fa739faf2d30beea5a8423806594f506644a540
Parent: 864017710c65e07a19d70bc226b2522a6b1907dc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 17 21:25:50 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 17 21:25:50 2017 +0200
lvmcmdline: enhance locales check
Make check for 'radixchar' more readable and logical.
Also avoid reread of number of locale is already using '.' as radixchar.
---
tools/lvmcmdline.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c62c776..a952c8c 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -544,7 +544,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
char *val;
double v;
uint64_t v_tmp, adjustment;
- char *radixchar = nl_langinfo(RADIXCHAR);
+ const char *radixchar = nl_langinfo(RADIXCHAR) ? : ".";
av->percent = PERCENT_NONE;
@@ -567,10 +567,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
return 0;
}
-
- if (!isdigit(*val) &&
- (*val != '.') &&
- (radixchar && (*val != radixchar[0]))) {
+ if (!isdigit(*val) && (*val != '.') && (*val != radixchar[0])) {
log_error("Size requires number argument.");
return 0;
}
@@ -578,10 +575,10 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
errno = 0;
v = strtod(val, &ptr);
- if (*ptr == '.') {
+ if (*ptr == '.' && radixchar[0] != '.') {
/*
* Maybe user has non-C locale with different decimal point ?
- * Lets be toleran and retry with standard C locales
+ * Lets be tolerant and retry with standard C locales
*/
if (setlocale(LC_ALL, "C")) {
errno = 0;
6 years, 9 months