master - debug: tracing fclose failure
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9d9979963ffa5ec72a1...
Commit: 9d9979963ffa5ec72a188e123a89eeea8ea666c5
Parent: aa8b2d6a0feb91bb5ea4364cdc53a00dfa233dca
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 2 22:00:26 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 5 17:25:11 2018 +0100
debug: tracing fclose failure
Using log_debug (not returning error code) to trace possible
failure of fclose().
---
daemons/lvmlockd/lvmlockd-sanlock.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index d22d009..993f2f5 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -307,7 +307,8 @@ static int read_host_id_file(void)
}
}
if (fclose(file))
- log_error("failed to close host id file %s", daemon_host_id_file);
+ log_debug("Failed to fclose host id file %s (%s).",
+ daemon_host_id_file, strerror(errno));
out:
log_debug("host_id %d from %s", host_id, daemon_host_id_file);
return host_id;
@@ -365,7 +366,9 @@ static void _read_sysfs_size(dev_t devno, const char *name, unsigned int *val)
if (strlen(buf))
*val = atoi(buf);
out:
- fclose(fp);
+ if (fclose(fp))
+ log_debug("Failed to fclose host id file %s (%s).", path, strerror(errno));
+
}
/* Select sector/align size for a new VG based on what the device reports for
5 years, 5 months
master - cleanup: move cast to det_t into MKDEV macro
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa8b2d6a0feb91bb5ea...
Commit: aa8b2d6a0feb91bb5ea4364cdc53a00dfa233dca
Parent: d3ebb18f4052fd90bb2d177089e79801b51f6242
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 3 17:13:10 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 5 17:25:11 2018 +0100
cleanup: move cast to det_t into MKDEV macro
---
device_mapper/ioctl/libdm-iface.c | 8 ++++----
device_mapper/libdm-common.c | 2 +-
device_mapper/libdm-deptree.c | 4 ++--
device_mapper/misc/kdev_t.h | 2 +-
lib/activate/dev_manager.c | 2 +-
lib/device/dev-cache.c | 4 ++--
lib/device/dev-type.c | 4 ++--
libdm/ioctl/libdm-iface.c | 8 ++++----
libdm/libdm-common.c | 2 +-
libdm/libdm-deptree.c | 4 ++--
libdm/misc/kdev_t.h | 2 +-
tools/pvscan.c | 4 ++--
12 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index 733eece..27db622 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -32,7 +32,7 @@
#else
# define MAJOR(x) major((x))
# define MINOR(x) minor((x))
-# define MKDEV(x,y) makedev((x),(y))
+# define MKDEV(x,y) makedev(((dev_t)x),((dev_t)y))
#endif
#include "device_mapper/misc/dm-ioctl.h"
@@ -261,7 +261,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
return -1;
}
- if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)minor)) {
+ if (major && buf.st_rdev != MKDEV(major, minor)) {
log_verbose("%s: Wrong device number: (%u, %u) instead of "
"(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode),
@@ -304,7 +304,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
(void) dm_prepare_selinux_context(control, S_IFCHR);
old_umask = umask(DM_CONTROL_NODE_UMASK);
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
- MKDEV((dev_t)major, (dev_t)minor)) < 0) {
+ MKDEV(major, minor)) < 0) {
log_sys_error("mknod", control);
ret = 0;
}
@@ -1182,7 +1182,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
}
dmi->flags |= DM_PERSISTENT_DEV_FLAG;
- dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor);
+ dmi->dev = MKDEV(dmt->major, dmt->minor);
}
/* Does driver support device number referencing? */
diff --git a/device_mapper/libdm-common.c b/device_mapper/libdm-common.c
index eec31d7..45dcb4c 100644
--- a/device_mapper/libdm-common.c
+++ b/device_mapper/libdm-common.c
@@ -1042,7 +1042,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
{
char path[PATH_MAX];
struct stat info;
- dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
+ dev_t dev = MKDEV(major, minor);
mode_t old_mask;
if (!_build_dev_path(path, sizeof(path), dev_name))
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 5c5f12f..16858b4 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -531,7 +531,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
dm_list_init(&node->activated);
dm_list_init(&node->props.segs);
- dev = MKDEV((dev_t)info->major, (dev_t)info->minor);
+ dev = MKDEV(info->major, info->minor);
if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev,
sizeof(dev), node)) {
@@ -554,7 +554,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
uint32_t major, uint32_t minor)
{
- dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
+ dev_t dev = MKDEV(major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
sizeof(dev));
diff --git a/device_mapper/misc/kdev_t.h b/device_mapper/misc/kdev_t.h
index f88bb0a..12780d2 100644
--- a/device_mapper/misc/kdev_t.h
+++ b/device_mapper/misc/kdev_t.h
@@ -17,6 +17,6 @@
#define MAJOR(dev) ((dev & 0xfff00) >> 8)
#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
-#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12))
+#define MKDEV(ma,mi) (((dev_t)mi & 0xff) | ((dev_t)ma << 8) | (((dev_t)mi & ~0xff) << 12))
#endif
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index aaf113f..15dec6f 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -374,7 +374,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
if (!(tmp_dev = dev_create_file(buf, NULL, NULL, 0)))
goto_out;
- tmp_dev->dev = MKDEV((dev_t)sm->logs[0].major, (dev_t)sm->logs[0].minor);
+ tmp_dev->dev = MKDEV(sm->logs[0].major, sm->logs[0].minor);
if (device_is_usable(tmp_dev, (struct dev_usable_check_params)
{ .check_empty = 1,
.check_blocked = 1,
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index fa92031..fb48f1a 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -479,7 +479,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
return NULL;
}
- devno = MKDEV((dev_t)major, (dev_t)minor);
+ devno = MKDEV(major, minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno))) {
/*
* If we get here, it means the device is referenced in sysfs, but it's not yet in /dev.
@@ -947,7 +947,7 @@ static int _dev_cache_iterate_sysfs_for_index(const char *path)
continue;
}
- devno = MKDEV((dev_t)major, (dev_t)minor);
+ devno = MKDEV(major, minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno)) &&
!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) {
if (!dm_device_get_name(major, minor, 1, devname, sizeof(devname)) ||
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 0b7af1b..f2d193b 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -506,7 +506,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
*/
if ((parts = dt->dev_type_array[major].max_partitions) > 1) {
if ((residue = minor % parts)) {
- *result = MKDEV((dev_t)major, (dev_t)(minor - residue));
+ *result = MKDEV(major, (minor - residue));
ret = 2;
} else {
*result = dev->dev;
@@ -576,7 +576,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
path, buffer);
goto out;
}
- *result = MKDEV((dev_t)major, (dev_t)minor);
+ *result = MKDEV(major, minor);
ret = 2;
out:
if (fp && fclose(fp))
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index e775da7..6d87749 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -30,7 +30,7 @@
#else
# define MAJOR(x) major((x))
# define MINOR(x) minor((x))
-# define MKDEV(x,y) makedev((x),(y))
+# define MKDEV(x,y) makedev(((dev_t)x),((dev_t)y))
#endif
#include "libdm/misc/dm-ioctl.h"
@@ -259,7 +259,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
return -1;
}
- if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)minor)) {
+ if (major && buf.st_rdev != MKDEV(major, minor)) {
log_verbose("%s: Wrong device number: (%u, %u) instead of "
"(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode),
@@ -302,7 +302,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
(void) dm_prepare_selinux_context(control, S_IFCHR);
old_umask = umask(DM_CONTROL_NODE_UMASK);
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
- MKDEV((dev_t)major, (dev_t)minor)) < 0) {
+ MKDEV(major, minor)) < 0) {
log_sys_error("mknod", control);
ret = 0;
}
@@ -1194,7 +1194,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
}
dmi->flags |= DM_PERSISTENT_DEV_FLAG;
- dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor);
+ dmi->dev = MKDEV(dmt->major, dmt->minor);
}
/* Does driver support device number referencing? */
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 5099f91..7d19f75 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1040,7 +1040,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
{
char path[PATH_MAX];
struct stat info;
- dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
+ dev_t dev = MKDEV(major, minor);
mode_t old_mask;
if (!_build_dev_path(path, sizeof(path), dev_name))
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 3e602e2..3f95a0d 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -523,7 +523,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
dm_list_init(&node->activated);
dm_list_init(&node->props.segs);
- dev = MKDEV((dev_t)info->major, (dev_t)info->minor);
+ dev = MKDEV(info->major, info->minor);
if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev,
sizeof(dev), node)) {
@@ -546,7 +546,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
uint32_t major, uint32_t minor)
{
- dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
+ dev_t dev = MKDEV(major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
sizeof(dev));
diff --git a/libdm/misc/kdev_t.h b/libdm/misc/kdev_t.h
index f88bb0a..12780d2 100644
--- a/libdm/misc/kdev_t.h
+++ b/libdm/misc/kdev_t.h
@@ -17,6 +17,6 @@
#define MAJOR(dev) ((dev & 0xfff00) >> 8)
#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
-#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12))
+#define MKDEV(ma,mi) (((dev_t)mi & 0xff) | ((dev_t)ma << 8) | (((dev_t)mi & ~0xff) << 12))
#endif
diff --git a/tools/pvscan.c b/tools/pvscan.c
index e3cd410..85b0e04 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -692,7 +692,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
log_warn("WARNING: Failed to parse major:minor from %s, skipping.", pv_name);
continue;
}
- devno = MKDEV((dev_t)major, (dev_t)minor);
+ devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor);
@@ -748,7 +748,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
if (major < 0 || minor < 0)
continue;
- devno = MKDEV((dev_t)major, (dev_t)minor);
+ devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor);
5 years, 5 months
master - cov: avoid unsing unchecked label_scan_open
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d3ebb18f4052fd90bb2...
Commit: d3ebb18f4052fd90bb2d177089e79801b51f6242
Parent: 70e3d0a613fb53e52f7a7cb31d65bcc2fa7ab738
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 3 17:19:33 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 5 17:25:11 2018 +0100
cov: avoid unsing unchecked label_scan_open
Drop extra call too label_scan_open() without checking return value,
and let code go through next call bellow.
---
lib/label/label.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index ca8502d..5387161 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1299,9 +1299,7 @@ bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
log_debug("Close and reopen to write %s", dev_name(dev));
bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
_scan_dev_close(dev);
-
- dev->flags |= DEV_BCACHE_WRITE;
- label_scan_open(dev);
+ /* goes to label_scan_open() since bcache_fd < 0 */
}
if (dev->bcache_fd <= 0) {
5 years, 5 months
master - cov: remove unused assigns
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=70e3d0a613fb53e52f7...
Commit: 70e3d0a613fb53e52f7a7cb31d65bcc2fa7ab738
Parent: a91ac41b93eff0f3ebd3af3319e8bbcb1fe8d00f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 3 16:48:20 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 5 17:25:11 2018 +0100
cov: remove unused assigns
---
lib/cache/lvmcache.c | 3 ---
lib/device/dev-cache.c | 3 +--
lib/metadata/metadata.c | 6 ++----
libdm/dm-tools/dmfilemapd.c | 4 ++--
tools/pvscan.c | 3 +--
tools/vgchange.c | 2 +-
6 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 46470a5..e681ed8 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -67,7 +67,6 @@ static DM_LIST_INIT(_vginfos);
static DM_LIST_INIT(_found_duplicate_devs);
static DM_LIST_INIT(_unused_duplicate_devs);
static int _scanning_in_progress = 0;
-static int _has_scanned = 0;
static int _vgs_locked = 0;
static int _found_duplicate_pvs = 0; /* If we never see a duplicate PV we can skip checking for them later. */
@@ -1808,8 +1807,6 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
{
log_debug_cache("Dropping VG info");
- _has_scanned = 0;
-
if (_vgid_hash) {
dm_hash_destroy(_vgid_hash);
_vgid_hash = NULL;
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 9b141fe..fa92031 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -666,10 +666,9 @@ struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid)
void dev_cache_failed_path(struct device *dev, const char *path)
{
- struct device *dev_by_path;
struct dm_str_list *strl;
- if ((dev_by_path = (struct device *) dm_hash_lookup(_cache.names, path)))
+ if (dm_hash_lookup(_cache.names, path))
dm_hash_remove(_cache.names, path);
dm_list_iterate_items(strl, &dev->aliases) {
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 3b28bf5..57e1842 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1647,15 +1647,13 @@ struct generic_logical_volume *find_historical_glv(const struct volume_group *vg
int lv_name_is_used_in_vg(const struct volume_group *vg, const char *name, int *historical)
{
- struct generic_logical_volume *historical_lv;
- struct logical_volume *lv;
int found = 0;
- if ((lv = find_lv(vg, name))) {
+ if (find_lv(vg, name)) {
found = 1;
if (historical)
*historical = 0;
- } else if ((historical_lv = find_historical_glv(vg, name, 0, NULL))) {
+ } else if (find_historical_glv(vg, name, 0, NULL)) {
found = 1;
if (historical)
*historical = 1;
diff --git a/libdm/dm-tools/dmfilemapd.c b/libdm/dm-tools/dmfilemapd.c
index 0b17c2b..856df3d 100644
--- a/libdm/dm-tools/dmfilemapd.c
+++ b/libdm/dm-tools/dmfilemapd.c
@@ -628,10 +628,10 @@ check_unlinked:
static int _daemonise(struct filemap_monitor *fm)
{
- pid_t pid = 0, sid;
+ pid_t pid = 0;
int fd;
- if (!(sid = setsid())) {
+ if (!setsid()) {
_early_log("setsid failed.");
return 0;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index d110a6b..e3cd410 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -452,7 +452,6 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
int disable_remove,
const char **pvid_without_metadata)
{
- struct label *label;
struct lvmcache_info *info;
struct _pvscan_baton baton;
const struct format_type *fmt;
@@ -474,7 +473,7 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
return 1;
}
- if (!(label = lvmcache_get_label(info))) {
+ if (!lvmcache_get_label(info)) {
log_debug("No PV label found for %s.", dev_name(dev));
if (!disable_remove)
_online_pvid_file_remove_devno((int)MAJOR(dev->dev), (int)MINOR(dev->dev));
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 13b72cc..e8e302c 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -607,7 +607,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
{
int ret = ECMD_PROCESSED;
unsigned i;
- activation_change_t activate = CHANGE_AN;
+ activation_change_t activate;
static const struct {
int arg;
5 years, 5 months
master - cov: hide intentionaly ptr arithmetic report
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a91ac41b93eff0f3ebd...
Commit: a91ac41b93eff0f3ebd3af3319e8bbcb1fe8d00f
Parent: 9238b972c543a83fbd553cc44a916608809cfc53
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 2 22:29:43 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:10:32 2018 +0100
cov: hide intentionaly ptr arithmetic report
Only single region count is ever replaced with on-stack uint64_t.
---
libdm/dm-tools/dmsetup.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 93714ac..4b14a23 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -5245,6 +5245,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
*/
this_start = (segments) ? segment_start : start;
this_len = (segments) ? segment_len : this_len;
+ /* coverity[ptr_arith] intentional */
if (!(r = dm_stats_create_region(dms, ®ion_ids[count],
this_start, this_len, step,
precise, bounds,
5 years, 5 months
master - cov: mark warning as expected one
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9238b972c543a83fbd5...
Commit: 9238b972c543a83fbd553cc44a916608809cfc53
Parent: 0d934e730ec62d16c4f47dbb0d8e97ed16910786
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 1 15:44:13 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:10:32 2018 +0100
cov: mark warning as expected one
---
base/data-struct/radix-tree-adaptive.c | 1 +
device_mapper/libdm-file.c | 2 ++
libdm/libdm-file.c | 2 ++
3 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/base/data-struct/radix-tree-adaptive.c b/base/data-struct/radix-tree-adaptive.c
index f8f3322..25dfbee 100644
--- a/base/data-struct/radix-tree-adaptive.c
+++ b/base/data-struct/radix-tree-adaptive.c
@@ -354,6 +354,7 @@ static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb,
return false;
n48->nr_entries = 17;
+ /* coverity[bad_memset] intentional use of '0' */
memset(n48->keys, 48, sizeof(n48->keys));
for (i = 0; i < 16; i++) {
diff --git a/device_mapper/libdm-file.c b/device_mapper/libdm-file.c
index 096c796..37c6ce7 100644
--- a/device_mapper/libdm-file.c
+++ b/device_mapper/libdm-file.c
@@ -222,6 +222,8 @@ retry_fcntl:
goto fail_close_unlink;
}
+ /* coverity[leaked_handle] intentional leak of fd handle here */
+
return 1;
fail_close_unlink:
diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c
index fc93dda..290ad32 100644
--- a/libdm/libdm-file.c
+++ b/libdm/libdm-file.c
@@ -221,6 +221,8 @@ retry_fcntl:
goto fail_close_unlink;
}
+ /* coverity[leaked_handle] intentional leak of fd handle here */
+
return 1;
fail_close_unlink:
5 years, 5 months
master - cov: trace failing pthread_kill
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0d934e730ec62d16c4f...
Commit: 0d934e730ec62d16c4f47dbb0d8e97ed16910786
Parent: 813347cf84617a946d9184f44c5fbd275bb41766
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 2 22:11:18 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:10:32 2018 +0100
cov: trace failing pthread_kill
---
.../dmeventd/plugins/snapshot/dmeventd_snapshot.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index 6ffa9fc..9e9053c 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -175,6 +175,7 @@ void process_event(struct dm_task *dmt,
const char *device = dm_task_get_name(dmt);
int percent;
struct dm_info info;
+ int ret;
/* No longer monitoring, waiting for remove */
if (!state->percent_check)
@@ -205,7 +206,8 @@ void process_event(struct dm_task *dmt,
/* Maybe configurable ? */
_remove(dm_task_get_uuid(dmt));
#endif
- pthread_kill(pthread_self(), SIGALRM);
+ if ((ret = pthread_kill(pthread_self(), SIGALRM)) && (ret != ESRCH))
+ log_sys_error("pthread_kill", "self");
goto out;
}
@@ -213,7 +215,8 @@ void process_event(struct dm_task *dmt,
/* TODO eventually recognize earlier when room is enough */
log_info("Dropping monitoring of fully provisioned snapshot %s.",
device);
- pthread_kill(pthread_self(), SIGALRM);
+ if ((ret = pthread_kill(pthread_self(), SIGALRM)) && (ret != ESRCH))
+ log_sys_error("pthread_kill", "self");
goto out;
}
5 years, 5 months
master - cov: add missing check for dm_strncpy
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=813347cf84617a946d9...
Commit: 813347cf84617a946d9184f44c5fbd275bb41766
Parent: c7789daec06110b7ed3663f1ba8cf91f40c8e572
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 2 21:50:29 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:10:32 2018 +0100
cov: add missing check for dm_strncpy
---
lib/activate/dev_manager.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 67a49be..aaf113f 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1916,7 +1916,11 @@ static int _check_holder(struct dev_manager *dm, struct dm_tree *dtree,
if (!strncmp(uuid, (char*)&lv->vg->id, sizeof(lv->vg->id)) &&
!dm_tree_find_node_by_uuid(dtree, uuid)) {
- dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
+ if (!dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1)) {
+ log_error(INTERNAL_ERROR "Too long UUID %s in VG %s.",
+ uuid, lv->vg->name);
+ goto out;
+ }
/* If UUID is not yet in dtree, look for matching LV */
if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, &id))) {
5 years, 5 months
master - cov: overflow before widen
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c7789daec06110b7ed3...
Commit: c7789daec06110b7ed3663f1ba8cf91f40c8e572
Parent: bc1976011adb51951dc0280817b2c047ab22ac7c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 2 21:10:21 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:10:31 2018 +0100
cov: overflow before widen
Evaluate as 64bit arithmetic (instead of doing 32bit mults which can
in this case purely teoretically overflow).
---
base/data-struct/radix-tree-adaptive.c | 2 +-
lib/locking/lvmlockd.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/base/data-struct/radix-tree-adaptive.c b/base/data-struct/radix-tree-adaptive.c
index f5a8606..f8f3322 100644
--- a/base/data-struct/radix-tree-adaptive.c
+++ b/base/data-struct/radix-tree-adaptive.c
@@ -623,7 +623,7 @@ static void _degrade_to_n48(struct node256 *n256, struct value *result)
}
// Removes an entry in an array by sliding the values above it down.
-static void _erase_elt(void *array, unsigned obj_size, unsigned count, unsigned index)
+static void _erase_elt(void *array, size_t obj_size, unsigned count, unsigned index)
{
if (index == (count - 1))
// The simple case
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index d65e06f..969a7fe 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -389,7 +389,7 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
.resize = LV_EXTEND,
.force = 1,
};
- int i;
+ uint64_t i;
extend_bytes = extend_mb * ONE_MB_IN_BYTES;
extend_sectors = extend_bytes / SECTOR_SIZE;
@@ -443,8 +443,8 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
for (i = 0; i < extend_mb; i++) {
if (!dev_write_zeros(dev, old_size_bytes + (i * ONE_MB_IN_BYTES), ONE_MB_IN_BYTES)) {
- log_error("Extend sanlock LV %s cannot zero device at %llu.", display_lvname(lv),
- (unsigned long long)(old_size_bytes + i * ONE_MB_IN_BYTES));
+ log_error("Extend sanlock LV %s cannot zero device at " FMTu64 ".",
+ display_lvname(lv), (old_size_bytes + i * ONE_MB_IN_BYTES));
label_scan_invalidate(dev);
return 0;
}
5 years, 5 months
master - cov: explicit ignore if failures
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bc1976011adb51951dc...
Commit: bc1976011adb51951dc0280817b2c047ab22ac7c
Parent: 79879bd201d4156312bb03fc0b7228ce34a3bf38
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 1 15:38:30 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Nov 3 16:09:36 2018 +0100
cov: explicit ignore if failures
Here we can't do anything better than just ignore syscall failures
(with silence as there is no loging mechanism)
---
scripts/generator-internals.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/generator-internals.c b/scripts/generator-internals.c
index 00a15e5..5acc969 100644
--- a/scripts/generator-internals.c
+++ b/scripts/generator-internals.c
@@ -42,18 +42,18 @@ static bool _open_child(struct child_process *child, const char *cmd, const char
child->pid = fork();
if (child->pid < 0) {
- close(pipe_fd[0]);
- close(pipe_fd[1]);
+ (void) close(pipe_fd[0]);
+ (void) close(pipe_fd[1]);
_error("call to fork() failed: %d\n", r);
return false;
}
if (child->pid == 0) {
// child
- close(pipe_fd[0]);
+ (void) close(pipe_fd[0]);
if (pipe_fd[1] != STDOUT_FILENO) {
- dup2(pipe_fd[1], STDOUT_FILENO);
- close(pipe_fd[1]);
+ (void) dup2(pipe_fd[1], STDOUT_FILENO);
+ (void) close(pipe_fd[1]);
}
if (execv(cmd, (char *const *) argv) < 0)
@@ -62,7 +62,7 @@ static bool _open_child(struct child_process *child, const char *cmd, const char
exit(1);
} else {
// parent
- close(pipe_fd[1]);
+ (void) close(pipe_fd[1]);
child->fp = fdopen(pipe_fd[0], "r");
if (!child->fp) {
_error("call to fdopen() failed\n");
@@ -78,7 +78,7 @@ static bool _close_child(struct child_process *child)
{
int status;
- fclose(child->fp);
+ (void) fclose(child->fp);
while (waitpid(child->pid, &status, 0) < 0)
if (errno != EINTR)
5 years, 5 months