main - shellcheck: warning enhancements
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bb6fd1a15f32d79ddaa...
Commit: bb6fd1a15f32d79ddaa351704dea47ad9e5ab9be
Parent: 5bd99d55b023f1e105bea6033aa57db3987f2ba5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 21 18:02:50 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Sep 21 21:03:47 2021 +0200
shellcheck: warning enhancements
---
scripts/lvm_import_vdo.sh | 2 +-
test/lib/aux.sh | 4 ++--
test/shell/devicesfile-devname.sh | 4 ++--
test/shell/devicesfile-realdevs.sh | 6 +++---
test/shell/idm_fabric_failure.sh | 14 +++++++-------
test/shell/idm_fabric_failure_half_brain.sh | 8 ++++----
test/shell/idm_fabric_failure_timeout.sh | 10 +++++-----
test/shell/idm_ilm_failure.sh | 4 ++--
test/shell/lvcreate-large-raid10.sh | 4 ++--
test/shell/thin-zero-meta.sh | 4 ++--
test/shell/vdo-convert.sh | 2 +-
11 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index af7917b0c..61a82e41e 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -262,7 +262,7 @@ convert2lvm_() {
if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
VGNAME=${DEFAULT_NAME%/*}
# Find largest matching VG name to our 'default' vgname
- LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "$VGNAME[0-9]? ?" | head -1 || true)
+ LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "${VGNAME}[0-9]? ?" | head -1 || true)
if test -n "$LASTVGNAME" ; then
LASTVGNAME=${LASTVGNAME#*${VGNAME}}
# If the number is becoming too high, try some random number
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 25e8c2ca5..ca9406383 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -607,7 +607,7 @@ teardown() {
# Remove any dangling symlink in /dev/disk (our tests can confuse udev)
test -d /dev/disk && {
- find /dev/disk -type l ! -exec /usr/bin/test -e {} \; -print | xargs rm -f || true
+ find /dev/disk -type l ! -exec /usr/bin/test -e {} \; -print0 | xargs -0 rm -f || true
}
# Remove any metadata archives and backups from this test on system
@@ -1200,7 +1200,7 @@ remove_dm_devs() {
}
remove=( "${held[@]}" )
done
- die "Can't remove device(s) ${held[@]}"
+ die "Can't remove device(s) ${held[*]}"
}
# Throttle down performance of kcopyd when mirroring i.e. disk image
diff --git a/test/shell/devicesfile-devname.sh b/test/shell/devicesfile-devname.sh
index c3add303b..f95be52b1 100644
--- a/test/shell/devicesfile-devname.sh
+++ b/test/shell/devicesfile-devname.sh
@@ -476,9 +476,9 @@ cat "$DF"
# pvscan does not fix DF
grep "$dev3" "$DF"
not grep "$dev1" "$DF"
-ls "$RUNDIR/lvm/pvs_online/"$PVID1""
+ls "$RUNDIR/lvm/pvs_online/$PVID1"
ls "$RUNDIR/lvm/pvs_online/$PVID2"
-not ls "$RUNDIR/lvm/pvs_online/"$PVID3""
+not ls "$RUNDIR/lvm/pvs_online/$PVID3"
check lv_field $vg1/$lv1 lv_active "active"
# pvs updates the DF
pvs |tee out
diff --git a/test/shell/devicesfile-realdevs.sh b/test/shell/devicesfile-realdevs.sh
index edcaed0c4..8d4aa3e67 100644
--- a/test/shell/devicesfile-realdevs.sh
+++ b/test/shell/devicesfile-realdevs.sh
@@ -122,7 +122,7 @@ cp $DF df2
# vgcreate from existing pvs, already in df
-vgcreate $vg ${REAL_DEVICES[@]}
+vgcreate $vg "${REAL_DEVICES[@]}"
vgremove $vg
rm $DF
@@ -130,7 +130,7 @@ rm $DF
# vgcreate from existing pvs, adding to df
touch $DF
-vgcreate $vg ${REAL_DEVICES[@]}
+vgcreate $vg "${REAL_DEVICES[@]}"
grep IDNAME $DF > df.ids
grep IDNAME df2 > df2.ids
@@ -242,7 +242,7 @@ grep $dev2 $DF
rm $DF
wipe_all
-vgcreate $vg ${REAL_DEVICES[@]}
+vgcreate $vg "${REAL_DEVICES[@]}"
rm $DF
touch $DF
diff --git a/test/shell/idm_fabric_failure.sh b/test/shell/idm_fabric_failure.sh
index e68d6ad07..633dd9d73 100644
--- a/test/shell/idm_fabric_failure.sh
+++ b/test/shell/idm_fabric_failure.sh
@@ -14,7 +14,7 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-[ -z "$LVM_TEST_FAILURE" ] && skip;
+[ -z "$LVM_TEST_FAILURE" ] && skip
aux prepare_devs 3
aux extend_filter_LVMTEST
@@ -33,17 +33,17 @@ HOST2=`readlink /sys/block/$DRIVE2 | awk -F'/' '{print $6}'`
HOST3=`readlink /sys/block/$DRIVE3 | awk -F'/' '{print $6}'`
# Emulate fabric failure
-echo 1 > /sys/block/$DRIVE1/device/delete
-[ -f /sys/block/$DRIVE2/device/delete ] && echo 1 > /sys/block/$DRIVE2/device/delete
-[ -f /sys/block/$DRIVE3/device/delete ] && echo 1 > /sys/block/$DRIVE3/device/delete
+echo 1 > "/sys/block/$DRIVE1/device/delete"
+[ -f "/sys/block/$DRIVE2/device/delete" ] && echo 1 > "/sys/block/$DRIVE2/device/delete"
+[ -f "/sys/block/$DRIVE3/device/delete" ] && echo 1 > "/sys/block/$DRIVE3/device/delete"
# Wait for 10s and will not lead to timeout
sleep 10
# Rescan drives so can probe the deleted drives and join back them
-echo "- - -" > /sys/class/scsi_host/${HOST1}/scan
-echo "- - -" > /sys/class/scsi_host/${HOST2}/scan
-echo "- - -" > /sys/class/scsi_host/${HOST3}/scan
+echo "- - -" > "/sys/class/scsi_host/${HOST1}/scan"
+echo "- - -" > "/sys/class/scsi_host/${HOST2}/scan"
+echo "- - -" > "/sys/class/scsi_host/${HOST3}/scan"
not check grep_lvmlockd_dump "S lvm_$vg kill_vg"
diff --git a/test/shell/idm_fabric_failure_half_brain.sh b/test/shell/idm_fabric_failure_half_brain.sh
index c692a12ad..784b26896 100644
--- a/test/shell/idm_fabric_failure_half_brain.sh
+++ b/test/shell/idm_fabric_failure_half_brain.sh
@@ -15,8 +15,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
-[ -z "$LVM_TEST_FAILURE" ] && skip;
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip
+[ -z "$LVM_TEST_FAILURE" ] && skip
aux prepare_devs 2
aux extend_filter_LVMTEST
@@ -55,7 +55,7 @@ for dev in /dev/*; do
done
for d in "${drive_list[@]}"; do
- [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+ [ -f "/sys/block/$d/device/delete" ] && echo 1 > "/sys/block/$d/device/delete"
done
# Fail to create new logic volume
@@ -68,7 +68,7 @@ not check grep_lvmlockd_dump "S lvm_$vg kill_vg"
# Rescan drives so can probe the deleted drives and join back them
for h in "${host_list[@]}"; do
- [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+ [ -f "/sys/class/scsi_host/${h}/scan" ] && echo "- - -" > "/sys/class/scsi_host/${h}/scan"
done
# After the drive is reconnected, $vg should be visible again.
diff --git a/test/shell/idm_fabric_failure_timeout.sh b/test/shell/idm_fabric_failure_timeout.sh
index cf71f7609..2466f94f0 100644
--- a/test/shell/idm_fabric_failure_timeout.sh
+++ b/test/shell/idm_fabric_failure_timeout.sh
@@ -15,8 +15,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
-[ -z "$LVM_TEST_FAILURE" ] && skip;
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip
+[ -z "$LVM_TEST_FAILURE" ] && skip
aux prepare_devs 1
aux extend_filter_LVMTEST
@@ -34,7 +34,7 @@ vgcreate $SHARED $vg "$dev1"
# Create new logic volume
lvcreate -a ey --zero n -l 1 -n $lv1 $vg
-drive_list=($DRIVE1)
+drive_list=( "$DRIVE1" )
# Find all drives with the same WWN and delete them from system,
# so that we can emulate the same drive with multiple paths are
@@ -52,7 +52,7 @@ for dev in /dev/*; do
done
for d in "${drive_list[@]}"; do
- [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+ [ -f "/sys/block/$d/device/delete" ] && echo 1 > "/sys/block/$d/device/delete"
done
# Fail to create new logic volume
@@ -66,7 +66,7 @@ lvmlockctl --drop $vg
# Rescan drives so can probe the deleted drives and join back them
for h in "${host_list[@]}"; do
- [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+ [ -f "/sys/class/scsi_host/${h}/scan" ] && echo "- - -" > "/sys/class/scsi_host/${h}/scan"
done
# After the drive is reconnected, $vg should be visible again.
diff --git a/test/shell/idm_ilm_failure.sh b/test/shell/idm_ilm_failure.sh
index 58bed270e..4b48476fe 100644
--- a/test/shell/idm_ilm_failure.sh
+++ b/test/shell/idm_ilm_failure.sh
@@ -15,8 +15,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
-[ -z "$LVM_TEST_FAILURE" ] && skip;
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip
+[ -z "$LVM_TEST_FAILURE" ] && skip
aux prepare_devs 3
aux extend_filter_LVMTEST
diff --git a/test/shell/lvcreate-large-raid10.sh b/test/shell/lvcreate-large-raid10.sh
index a46be374f..89eb0a664 100644
--- a/test/shell/lvcreate-large-raid10.sh
+++ b/test/shell/lvcreate-large-raid10.sh
@@ -31,8 +31,8 @@ done
aux extend_filter_LVMTEST
-pvcreate "$DM_DEV_DIR"/$vg/$lv[12345]
-vgcreate $vg1 "$DM_DEV_DIR"/$vg/$lv[12345]
+pvcreate "$DM_DEV_DIR"/$vg/${lv}[12345]
+vgcreate $vg1 "$DM_DEV_DIR"/$vg/${lv}[12345]
#
diff --git a/test/shell/thin-zero-meta.sh b/test/shell/thin-zero-meta.sh
index 6a15a7388..a46672900 100644
--- a/test/shell/thin-zero-meta.sh
+++ b/test/shell/thin-zero-meta.sh
@@ -53,8 +53,8 @@ do
# When fully zeroed, it should be zero - so almost no output from hexdump
case "$i" in
- 0) test $(wc -l < out) -ge 10 ;; # should not be zeroed
- 1) test $(wc -l < out) -le 10 ;; # should be zeroed
+ 0) test "$(wc -l < out)" -ge 10 ;; # should not be zeroed
+ 1) test "$(wc -l < out)" -le 10 ;; # should be zeroed
esac
lvremove -f $vg/pool
diff --git a/test/shell/vdo-convert.sh b/test/shell/vdo-convert.sh
index 632f86a36..f82529a2d 100644
--- a/test/shell/vdo-convert.sh
+++ b/test/shell/vdo-convert.sh
@@ -168,7 +168,7 @@ vdo create $VDOCONF --name "$VDONAME" --device="$LOOP" --vdoLogicalSize=23G \
# Get VDO table line
dmsetup table "$VDONAME" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee vdo-orig
-DM_DEV_DIR= lvm_import_vdo -y --name $vg/$lv "$LOOP"
+DM_DEV_DIR="" lvm_import_vdo -y --name $vg/$lv "$LOOP"
lvs -a $vg
dmsetup table "$vg-${lv}_vpool-vpool" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee new-vdo-lv
2 years, 7 months
main - shellcheck: tests fixes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5bd99d55b023f1e105b...
Commit: 5bd99d55b023f1e105bea6033aa57db3987f2ba5
Parent: 130993bab1a6fe40c781bff396e13b56a2b2768b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 21 16:59:21 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Sep 21 21:03:47 2021 +0200
shellcheck: tests fixes
Correcting some shell problems.
---
test/shell/integrity.sh | 2 +-
test/shell/lvcreate-thin-big.sh | 4 ++--
test/shell/pe-align.sh | 2 --
test/shell/pvmove-resume-2.sh | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/test/shell/integrity.sh b/test/shell/integrity.sh
index 80ff919b2..293cde84a 100644
--- a/test/shell/integrity.sh
+++ b/test/shell/integrity.sh
@@ -623,7 +623,7 @@ vgremove -ff $vg
# Repeat many of the tests above using bitmap mode
_prepare_vg
-lvcreate --type raid1 -m1 --raidintegrity y --raidintegritymode bitmap -n $lv1 -l 8 $vg "$dev1 "$dev2"
+lvcreate --type raid1 -m1 --raidintegrity y --raidintegritymode bitmap -n $lv1 -l 8 $vg "$dev1" "$dev2"
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/$lv1
diff --git a/test/shell/lvcreate-thin-big.sh b/test/shell/lvcreate-thin-big.sh
index 254903548..bdb594218 100644
--- a/test/shell/lvcreate-thin-big.sh
+++ b/test/shell/lvcreate-thin-big.sh
@@ -31,11 +31,11 @@ vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}"
# Size 0 is not valid
invalid lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg/pool1 2>out
-lvcreate -Zn -L4M --chunksize 128 --poolmetadatasize 16k -T $vg/pool1 2>&1 >out
+lvcreate -Zn -L4M --chunksize 128 --poolmetadatasize 16k -T $vg/pool1 >out 2>&1
grep -i "minimal" out
# FIXME: metadata allocation fails, if PV doesn't have at least 16GB
# i.e. pool metadata device cannot be multisegment
-lvcreate -Zn -L4M --chunksize 64k --poolmetadatasize 17G -T $vg/pool2 2>&1 >out
+lvcreate -Zn -L4M --chunksize 64k --poolmetadatasize 17G -T $vg/pool2 >out 2>&1
grep "maximum" out
check lv_field $vg/pool1_tmeta size "2.00m"
check lv_field $vg/pool2_tmeta size "<15.88g"
diff --git a/test/shell/pe-align.sh b/test/shell/pe-align.sh
index c547188c9..701510841 100644
--- a/test/shell/pe-align.sh
+++ b/test/shell/pe-align.sh
@@ -1,4 +1,3 @@
-
#!/usr/bin/env bash
# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
@@ -141,4 +140,3 @@ check pv_field "$dev1" ba_start 384.00k --units k
check pv_field "$dev1" ba_size 256.00k --units k
check pv_field "$dev1" pe_start 640.00k --units k
pvremove "$dev1"
-
diff --git a/test/shell/pvmove-resume-2.sh b/test/shell/pvmove-resume-2.sh
index 1ba4bc662..3dea74364 100644
--- a/test/shell/pvmove-resume-2.sh
+++ b/test/shell/pvmove-resume-2.sh
@@ -53,7 +53,7 @@ test_pvmove_resume() {
# errors, based on the fact pvmove is killed -9
# Restart clvmd
kill "$(< LOCAL_CLVMD)"
- for i in {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
2 years, 7 months
main - lvmcache: follow pv_id/pvid naming convention
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=130993bab1a6fe40c78...
Commit: 130993bab1a6fe40c781bff396e13b56a2b2768b
Parent: b1f33a4000018df57b9af40a4b2a38434ad0079d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Sep 20 09:32:21 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 20 09:35:47 2021 -0500
lvmcache: follow pv_id/pvid naming convention
name the variable pv_id_arg to follow the convention:
. "pvid" variable is null-terminated string
. "pv_id" variable is non-null-terminated struct
---
lib/cache/lvmcache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index d94d174b6..655f34bd8 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -477,14 +477,14 @@ struct lvmcache_info *lvmcache_info_from_pvid(const char *pvid_arg, struct devic
return info;
}
-struct lvmcache_info *lvmcache_info_from_pv_id(const struct id *pvid, struct device *dev, int valid_only)
+struct lvmcache_info *lvmcache_info_from_pv_id(const struct id *pv_id_arg, struct device *dev, int valid_only)
{
/*
* Since we know that lvmcache_info_from_pvid directly above
* does not assume pvid_arg is null-terminated, we make an
* exception here and cast a struct id to char *.
*/
- return lvmcache_info_from_pvid((const char *)pvid, dev, valid_only);
+ return lvmcache_info_from_pvid((const char *)pv_id_arg, dev, valid_only);
}
const struct format_type *lvmcache_fmt_from_info(struct lvmcache_info *info)
2 years, 7 months
main - tests: len always initialized
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b1f33a4000018df57b9...
Commit: b1f33a4000018df57b9af40a4b2a38434ad0079d
Parent: 133686ebc79b29316d5f913bcce3fe21bbfea9ec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 20 16:24:08 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 16:24:08 2021 +0200
tests: len always initialized
---
test/unit/run.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/test/unit/run.c b/test/unit/run.c
index 24624aea9..84b867be5 100644
--- a/test/unit/run.c
+++ b/test/unit/run.c
@@ -125,8 +125,7 @@ static void _print_path_delta(FILE *stream,
fprintf(stream, "\n");
}
- if (new_len > 0)
- len = common_prefix * 2 + (new[new_len - 1].e - new[new_len - 1].b);
+ len = (new_len > 0) ? common_prefix * 2 + (new[new_len - 1].e - new[new_len - 1].b) : 0;
fprintf(stream, " ");
for (d = len; d < 60; d++)
2 years, 7 months
main - gcc: avoid name colision with function pv_id() from metadata.h
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=133686ebc79b29316d5...
Commit: 133686ebc79b29316d5f913bcce3fe21bbfea9ec
Parent: 2e990d1fec93126017124d3db754aeed5b6c7dc3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 20 16:12:10 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 16:12:10 2021 +0200
gcc: avoid name colision with function pv_id() from metadata.h
---
lib/cache/lvmcache.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 655da164c..d94d174b6 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -477,14 +477,14 @@ struct lvmcache_info *lvmcache_info_from_pvid(const char *pvid_arg, struct devic
return info;
}
-struct lvmcache_info *lvmcache_info_from_pv_id(const struct id *pv_id, struct device *dev, int valid_only)
+struct lvmcache_info *lvmcache_info_from_pv_id(const struct id *pvid, struct device *dev, int valid_only)
{
/*
* Since we know that lvmcache_info_from_pvid directly above
* does not assume pvid_arg is null-terminated, we make an
* exception here and cast a struct id to char *.
*/
- return lvmcache_info_from_pvid((const char *)pv_id, dev, valid_only);
+ return lvmcache_info_from_pvid((const char *)pvid, dev, valid_only);
}
const struct format_type *lvmcache_fmt_from_info(struct lvmcache_info *info)
@@ -1391,11 +1391,11 @@ int lvmcache_get_vgnameids(struct cmd_context *cmd,
return 1;
}
-struct device *lvmcache_device_from_pv_id(struct cmd_context *cmd, const struct id *pv_id, uint64_t *label_sector)
+struct device *lvmcache_device_from_pv_id(struct cmd_context *cmd, const struct id *pvid, uint64_t *label_sector)
{
struct lvmcache_info *info;
- if ((info = lvmcache_info_from_pv_id(pv_id, NULL, 0))) {
+ if ((info = lvmcache_info_from_pv_id(pvid, NULL, 0))) {
if (info->label && label_sector)
*label_sector = info->label->sector;
return info->dev;
2 years, 7 months
main - gcc: avoid warns on missing braces with older version
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2e990d1fec931260171...
Commit: 2e990d1fec93126017124d3db754aeed5b6c7dc3
Parent: 1a8a33ae9b39567e2a2cc399f13cebecb5fa2dea
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 20 16:11:49 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 16:11:49 2021 +0200
gcc: avoid warns on missing braces with older version
---
libdm/libdm-stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 6cfa23384..62b28b69d 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4519,7 +4519,7 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
struct dm_stats_region *region = NULL;
struct dm_stats_group *group = NULL;
uint64_t nr_kept, nr_old;
- struct _extent ext = { 0 };
+ struct _extent ext = { .id = 0 };
int64_t i;
group = &dms->groups[group_id];
2 years, 7 months
main - tests: a bit more fancy way to initialized struct
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1a8a33ae9b39567e2a2...
Commit: 1a8a33ae9b39567e2a2cc399f13cebecb5fa2dea
Parent: 4c0354fe0fc2f42ec35c57cc69444a825e5c5386
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 20 16:01:22 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 16:01:22 2021 +0200
tests: a bit more fancy way to initialized struct
Older g++ is not smart enough to figure this out, so add a bit more push.
---
test/lib/brick-shelltest.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index b3b62a308..af2810521 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -988,7 +988,7 @@ struct TestCase {
TestCase( Journal &j, Options opt, std::string path, std::string _name, std::string _flavour )
: child( path ), name( _name ), flavour( _flavour ),
- iobuf( NULL ), usage( { 0 } ), status( 0 ), timeout( false ),
+ iobuf( NULL ), usage( (struct rusage) { { 0 } } ), status( 0 ), timeout( false ),
pid( 0 ), start( 0 ), end( 0 ), silent_start( 0 ),
last_update( 0 ), last_heartbeat( 0 ), options( opt ), journal( &j )
{
2 years, 7 months
main - cleanup: better wording
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4c0354fe0fc2f42ec35...
Commit: 4c0354fe0fc2f42ec35c57cc69444a825e5c5386
Parent: 1b5245199680841fd088cf1a834b3623b3ef18d0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 20 15:41:14 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 15:41:14 2021 +0200
cleanup: better wording
Follow-up advice of native speaker.
---
scripts/lvm_import_vdo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index 5fda9db1e..af7917b0c 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -310,7 +310,7 @@ convert2lvm_() {
case "$DM_OPEN" in
Device*) ;; # no devices
*) eval "$DM_OPEN"
- test "${DM_OPEN:-0}" -eq 0 || error "Cannot convert VDO volume \"$VDONAME\" which is in use!"
+ test "${DM_OPEN:-0}" -eq 0 || error "Cannot convert in use VDO volume \"$VDONAME\"!"
;;
esac
2 years, 7 months
main - cov: mask some warning about leakage
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1b5245199680841fd08...
Commit: 1b5245199680841fd088cf1a834b3623b3ef18d0
Parent: 548c69f58174b3cb3997c0fcff09276bd7502796
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Sep 19 20:21:55 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 14:26:09 2021 +0200
cov: mask some warning about leakage
Mask false-positive leak report.
---
daemons/cmirrord/clogd.c | 1 +
daemons/dmeventd/dmeventd.c | 1 +
lib/device/bcache.c | 4 +++-
libdaemon/server/daemon-server.c | 2 ++
libdm/dm-tools/dmfilemapd.c | 1 +
test/lib/brick-shelltest.h | 1 +
test/unit/bcache_utils_t.c | 2 ++
test/unit/io_engine_t.c | 1 +
test/unit/radix_tree_t.c | 1 +
test/unit/run.c | 1 +
tools/toollib.c | 2 ++
11 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/daemons/cmirrord/clogd.c b/daemons/cmirrord/clogd.c
index c9f65af4c..a18354784 100644
--- a/daemons/cmirrord/clogd.c
+++ b/daemons/cmirrord/clogd.c
@@ -245,6 +245,7 @@ static void daemonize(void)
}
LOG_OPEN("cmirrord", LOG_PID, LOG_DAEMON);
+ /* coverity[leaked_handle] devnull cannot leak here */
}
/*
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index c44fa4ed9..75672a7fd 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1072,6 +1072,7 @@ out:
* "label at end of compound statement" */
;
+ /* coverity[lock_order] _global_mutex is kept locked */
pthread_cleanup_pop(1);
return NULL;
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 790ff71d3..82b32644d 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -392,6 +392,7 @@ struct io_engine *create_async_io_engine(void)
e->page_mask = (unsigned) _pagesize - 1;
+ /* coverity[leaked_storage] 'e' is not leaking */
return &e->e;
}
@@ -606,7 +607,8 @@ struct io_engine *create_sync_io_engine(void)
e->e.wait = _sync_wait;
e->e.max_io = _sync_max_io;
- dm_list_init(&e->complete);
+ dm_list_init(&e->complete);
+ /* coverity[leaked_storage] 'e' is not leaking */
return &e->e;
}
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index aeb1870a3..88905a7dd 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -408,6 +408,8 @@ static void _daemonise(daemon_state s)
}
setsid();
+
+ /* coverity[leaked_handle] 'fd' handle is not leaking */
}
response daemon_reply_simple(const char *id, ...)
diff --git a/libdm/dm-tools/dmfilemapd.c b/libdm/dm-tools/dmfilemapd.c
index 3799efd83..d7ca71d7e 100644
--- a/libdm/dm-tools/dmfilemapd.c
+++ b/libdm/dm-tools/dmfilemapd.c
@@ -664,6 +664,7 @@ static int _daemonise(struct filemap_monitor *fm)
if (fd > STDERR_FILENO)
(void) close(fd);
_early_log("Error redirecting stdin/out/err to null.");
+ /* coverity[leaked_handle] no leak */
return 0;
}
if (fd > STDERR_FILENO)
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index 517c0f7d9..b3b62a308 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -482,6 +482,7 @@ struct Source {
virtual void sync( Sink *sink ) {
ssize_t sz;
+ /* coverity[stack_use_local_overflow] */
char buf[ 128 * 1024 ];
if ( (sz = read(fd, buf, sizeof(buf) - 1)) > 0 )
sink->push( std::string( buf, sz ) );
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 48dab142e..73b8902fb 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -67,6 +67,7 @@ static void *_fix_init(struct io_engine *engine)
T_ASSERT(f);
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
+ /* coverity[secure_temp] don't care */
f->fd = mkstemp(f->fname);
T_ASSERT(f->fd >= 0);
@@ -243,6 +244,7 @@ static void _reopen(struct fixture *f)
static uint8_t _random_pattern(void)
{
+ /* coverity[dont_call] don't care */
return random();
}
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index d45d8ffa7..2f6ea5b03 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -89,6 +89,7 @@ static void *_fix_init(void)
test_fail("posix_memalign failed");
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
+ /* coverity[secure_temp] don't care */
f->fd = mkstemp(f->fname);
T_ASSERT(f->fd >= 0);
diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c
index 88c8bd5a7..be24ce76d 100644
--- a/test/unit/radix_tree_t.c
+++ b/test/unit/radix_tree_t.c
@@ -169,6 +169,7 @@ static void test_prefix_keys_reversed(void *fixture)
static void _gen_key(uint8_t *b, uint8_t *e)
{
for (; b != e; b++)
+ /* coverity[dont_call] don't care */
*b = rand() % 256;
}
diff --git a/test/unit/run.c b/test/unit/run.c
index 0abd47246..24624aea9 100644
--- a/test/unit/run.c
+++ b/test/unit/run.c
@@ -200,6 +200,7 @@ static void _run_test(struct test_details *t, bool use_colour, unsigned *passed,
(*passed)++;
fprintf(stderr, "%s[ OK]%s\n", green(use_colour), normal(use_colour));
+ /* coverity[leaked_storage] fixture released by fixture_exit */
}
}
diff --git a/tools/toollib.c b/tools/toollib.c
index fa3b2ffe3..0576a76fb 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -111,6 +111,8 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
_exit(ECMD_FAILED);
}
+ /* coverity[leaked_handle] null_fd does not leak here */
+
return 1;
}
2 years, 7 months
main - cov: hide reports from optarg being NULL
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=548c69f58174b3cb399...
Commit: 548c69f58174b3cb3997c0fcff09276bd7502796
Parent: efaab93491751ccf39108d076745c6774b263232
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Sep 19 20:19:52 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 20 14:26:09 2021 +0200
cov: hide reports from optarg being NULL
It's basically irrelavant which value we assing to optarg,
since it's set by getopt() function, but Coverity tool
is incorrectly reporting possibly dereference of NULL.
---
libdm/dm-tools/dmsetup.c | 4 ++--
tools/lvmcmdline.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index f6d1ecf90..0f260b3f4 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -6680,7 +6680,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp
};
#endif
- optarg = 0;
+ optarg = (char*) "";
optind = OPTIND_INIT;
while ((c = GETOPTLONG_FN(*argcp, *argvp, "ade:fo:v",
long_options, NULL)) != -1 ) {
@@ -6976,7 +6976,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
return r;
}
- optarg = 0;
+ optarg = (char*) "";
optind = OPTIND_INIT;
while ((ind = -1, c = GETOPTLONG_FN(*argcp, *argvp, "cCfG:hj:m:M:no:O:rS:u:U:vy",
long_options, NULL)) != -1) {
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index de70e63c9..7c5930006 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2236,7 +2236,7 @@ static int _process_command_line(struct cmd_context *cmd, int *argc, char ***arg
*ptr = '\0';
memset(o, 0, sizeof(*o));
- optarg = 0;
+ optarg = (char*) "";
optind = OPTIND_INIT;
while ((goval = GETOPTLONG_FN(*argc, *argv, str, opts, NULL)) >= 0) {
2 years, 7 months