main - man-generator: initialize struct stat to avoid MSAN error
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cd897e536fb69281d5d...
Commit: cd897e536fb69281d5d8e3e382a3827640913bd1
Parent: 064979dc3238171cc4029ebfcbf63ad71cc7d9cd
Author: Adrian Ratiu <adrian.ratiu(a)collabora.com>
AuthorDate: Thu Sep 9 17:51:47 2021 +0300
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
man-generator: initialize struct stat to avoid MSAN error
When building lvm2 in Gentoo/ChromeOS with the ASAN memory
sanitizer enabled, man-generator fails with the following
error. Initializing makes the error go away.
* SUMMARY: MemorySanitizer: use-of-uninitialized-value /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3316:6 in _include_description_file
* Exiting
* ASAN error detected:
* ==2548047==WARNING: MemorySanitizer: use-of-uninitialized-value
* #0 0x558b00ab4730 in _include_description_file /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3316:6
* #1 0x558b00ab4730 in _print_man /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3426:21
* #2 0x558b00ab4730 in main /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3570:7
* #0 0x7fa9b2cbb807 in find_derivation /var/tmp/portage/cross-x86_64-cros-linux-gnu/glibc-2.33-r8/work/glibc-2.33/iconv/gconv_db.c:583:15
* #1 0x558b00a29559 in ?? ??:0
*
* Uninitialized value was created by an allocation of 'statbuf.i.i' in the stack frame of function 'main'
* #0 0x558b00ab1d4d in main /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3505
---
tools/command.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/command.c b/tools/command.c
index 0d37de7f6..37f6a6153 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -3526,7 +3526,7 @@ static int _include_description_file(char *name, char *des_file)
char *buf;
int fd, r = 0;
ssize_t sz;
- struct stat statbuf;
+ struct stat statbuf = { 0 };
if ((fd = open(des_file, O_RDONLY)) < 0) {
log_error("Failed to open description file %s.", des_file);
2 years, 7 months
main - gcc: remove unused vg setting
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=064979dc3238171cc40...
Commit: 064979dc3238171cc4029ebfcbf63ad71cc7d9cd
Parent: 00ec716b4db371f0e28880e95539b10208f19d37
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 23:34:58 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
gcc: remove unused vg setting
---
tools/lvconvert.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d73e16e3a..33ab0637d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6294,7 +6294,6 @@ int lvconvert_to_cache_with_cachevol_cmd(struct cmd_context *cmd, int argc, char
static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_volume *lv)
{
- struct volume_group *vg = lv->vg;
int ret = 0;
if (!lv_is_integrity(lv) && !lv_is_raid(lv)) {
2 years, 7 months
main - gcc: remove invalid attribute
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=00ec716b4db371f0e28...
Commit: 00ec716b4db371f0e28880e95539b10208f19d37
Parent: 9ba76450f4a206ee48b0b6e49d35c2c33032bb58
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 23:17:29 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
gcc: remove invalid attribute
In this function parameter 'attribute' is used.
---
lib/cache_segtype/cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 93d4c5283..05de9d5cd 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -335,7 +335,7 @@ static int _lookup_kallsyms(const char *symbol)
static int _target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
- unsigned *attributes __attribute__((unused)))
+ unsigned *attributes)
{
/* List of features with their kernel target version */
static const struct feature {
2 years, 7 months
main - cov: remove unused variable setting
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9ba76450f4a206ee48b...
Commit: 9ba76450f4a206ee48b0b6e49d35c2c33032bb58
Parent: 3b2a4e3e6f081002ab92f5f78326d2c1dfa879bf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Sep 11 22:40:31 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: remove unused variable setting
Since there is no use for &end after strtol, remove it.
---
lib/report/report.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index a28744a49..60df417a4 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -882,7 +882,6 @@ static int _translate_time_items(struct dm_report *rh, struct time_info *info,
long multiplier = 1;
struct tm tm_now;
time_id_t id;
- char *end;
long num;
struct tm tm; /* absolute time */
time_t t = 0; /* offset into past before absolute time */
@@ -899,7 +898,7 @@ static int _translate_time_items(struct dm_report *rh, struct time_info *info,
if (_is_time_num(id)) {
errno = 0;
- num = strtol(ti->s, &end, 10);
+ num = strtol(ti->s, NULL, 10);
if (errno) {
log_error("_translate_time_items: invalid time.");
return 0;
2 years, 7 months
main - cov: make it aware we need these headers for muslC
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3b2a4e3e6f081002ab9...
Commit: 3b2a4e3e6f081002ab92f5f78326d2c1dfa879bf
Parent: a14371e4952f7a1b079a795c13927cea2eb196b6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 23:06:45 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: make it aware we need these headers for muslC
---
daemons/dmeventd/plugins/vdo/dmeventd_vdo.c | 1 +
lib/device/dev-cache.c | 1 +
lib/report/report.c | 3 +++
tools/lvmcmdline.c | 1 +
tools/lvmdevices.c | 1 +
5 files changed, 7 insertions(+)
diff --git a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
index 399b737ee..d3f1ba4b9 100644
--- a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
+++ b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
@@ -22,6 +22,7 @@
* in runtime we are linked agains systems libdm 'older' library
* which does not provide this symbol and plugin fails to load
*/
+/* coverity[unnecessary_header] used for parsing */
#include "device_mapper/vdo/status.c"
#include <sys/wait.h>
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 3918afba0..0d1d4e36f 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <dirent.h>
#include <locale.h>
+/* coverity[unnecessary_header] needed for MuslC */
#include <sys/file.h>
struct dev_iter {
diff --git a/lib/report/report.c b/lib/report/report.c
index efe103f43..a28744a49 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -47,6 +47,7 @@ static uint32_t _log_seqnum = 1;
*/
#define FIELD(type, strct, sorttype, head, field_name, width, func, id, desc, writeable) field_ ## id,
enum {
+/* coverity[unnecessary_header] */
#include "columns.h"
};
#undef FIELD
@@ -4340,6 +4341,7 @@ typedef struct label type_label;
typedef dev_known_type_t type_devtype;
static const struct dm_report_field_type _fields[] = {
+/* coverity[unnecessary_header] */
#include "columns.h"
{0, 0, 0, 0, "", "", NULL, NULL},
};
@@ -4350,6 +4352,7 @@ static const struct dm_report_field_type _devtypes_fields[] = {
};
static const struct dm_report_field_type _log_fields[] = {
+/* coverity[unnecessary_header] */
#include "columns-cmdlog.h"
{0, 0, 0, 0, "", "", NULL, NULL},
};
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 1fb593d84..f9eab8ec8 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -22,6 +22,7 @@
#include "lib/locking/lvmlockd.h"
#include "lib/datastruct/str_list.h"
+/* coverity[unnecessary_header] */
#include "stub.h"
#include "lib/misc/last-path-component.h"
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index 73c33c932..367536d6a 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -17,6 +17,7 @@
#include "lib/device/device_id.h"
#include "lib/device/dev-type.h"
+/* coverity[unnecessary_header] needed for MuslC */
#include <sys/file.h>
static void _search_devs_for_pvids(struct cmd_context *cmd, struct dm_list *search_pvids, struct dm_list *found_devs)
2 years, 7 months
main - cov: hide false positive warning
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a14371e4952f7a1b079...
Commit: a14371e4952f7a1b079a795c13927cea2eb196b6
Parent: 63930f576a29d701894586c6ef1f90bf63f321d1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 09:58:26 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: hide false positive warning
Here we have valid use case of strncpy() which just need
to fill precise buffer size - so no explicit \0 on buffer
end is needed.
---
daemons/lvmlockd/lvmlockd-core.c | 1 +
device_mapper/ioctl/libdm-iface.c | 2 ++
libdm/ioctl/libdm-iface.c | 2 ++
3 files changed, 5 insertions(+)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index c570b9d14..a3964c857 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2989,6 +2989,7 @@ static int add_lockspace_thread(const char *ls_name,
}
if (vg_uuid)
+ /* coverity[buffer_size_warning] */
strncpy(ls->vg_uuid, vg_uuid, 64);
if (vg_name)
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index a2a56be45..b4f7a986d 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -1250,9 +1250,11 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
/* FIXME Until resume ioctl supplies name, use dev_name for readahead */
if (DEV_NAME(dmt) && (dmt->type != DM_DEVICE_RESUME || dmt->minor < 0 ||
dmt->major < 0))
+ /* coverity[buffer_size_warning] */
strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
if (DEV_UUID(dmt))
+ /* coverity[buffer_size_warning] */
strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
if (dmt->type == DM_DEVICE_SUSPEND)
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 47f14398c..d8f1c389d 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -1245,9 +1245,11 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
(dmt->minor < 0) || (dmt->major < 0)))
/* When RESUME or RELOAD sets maj:min and dev_name, use just maj:min,
* passed dev_name is useful for better error/debug messages */
+ /* coverity[buffer_size_warning] */
strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
if (DEV_UUID(dmt))
+ /* coverity[buffer_size_warning] */
strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
if (dmt->type == DM_DEVICE_SUSPEND)
2 years, 7 months
main - cov: add some initializers
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=63930f576a29d701894...
Commit: 63930f576a29d701894586c6ef1f90bf63f321d1
Parent: f5f1cdfa70ad2ec907fba8b9f5d0c1a251571c80
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 22:32:44 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: add some initializers
---
daemons/cmirrord/cluster.c | 2 +-
daemons/cmirrord/functions.c | 2 +-
daemons/lvmlockd/lvmlockd-sanlock.c | 2 +-
daemons/lvmpolld/lvmpolld-core.c | 2 +-
device_mapper/libdm-report.c | 8 ++++----
lib/device/dev-cache.c | 2 +-
lib/format_text/archive.c | 2 +-
lib/label/label.c | 2 +-
lib/metadata/mirror.c | 2 ++
libdm/libdm-report.c | 8 ++++----
libdm/libdm-stats.c | 4 ++--
tools/toollib.c | 2 +-
12 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index 23308e7a9..5de43c534 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -1383,7 +1383,7 @@ static void cpg_leave_callback(struct clog_cpg *match,
size_t member_list_entries)
{
unsigned i;
- int j, fd;
+ int j, fd = -1;
uint32_t lowest = match->lowest_id;
struct clog_request *rq, *n;
struct checkpoint_data *p_cp, *c_cp;
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index 23a17015a..6c8c386a7 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -378,7 +378,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
uint32_t block_on_error = 0;
int disk_log;
- char disk_path[PATH_MAX];
+ char disk_path[PATH_MAX] = { 0 };
int unlink_path = 0;
long page_size;
int pages;
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index 13567cf95..e595eeffd 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -1660,7 +1660,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
struct sanlk_options opt;
uint64_t lock_lv_offset;
uint32_t flags = 0;
- struct val_blk vb;
+ struct val_blk vb = { 0 };
int added = 0;
int rv;
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index ab8284145..47c9376b4 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -372,7 +372,7 @@ static void debug_print(struct lvmpolld_state *ls, const char * const* ptr)
static void *fork_and_poll(void *args)
{
- int outfd, errfd, state;
+ int outfd, errfd, state = 0;
struct lvmpolld_thread_data *data;
pid_t r;
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index c6e7a2a03..13a8e46b1 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -2332,7 +2332,7 @@ static const char *_reserved_name(struct dm_report *rh,
uint32_t field_num, const char *s, size_t len)
{
dm_report_reserved_handler handler;
- const char *canonical_name;
+ const char *canonical_name = NULL;
const char **name;
char *tmp_s;
char c;
@@ -3910,7 +3910,7 @@ static struct selection_node *_parse_ex(struct dm_report *rh,
static const char _pe_expected_msg[] = "Syntax error: right parenthesis expected at \'%s\'";
struct selection_node *sn = NULL;
uint32_t t;
- const char *tmp;
+ const char *tmp = NULL;
t = _tok_op_log(s, next, SEL_MODIFIER_NOT | SEL_PRECEDENCE_PS);
if (t == SEL_MODIFIER_NOT) {
@@ -3956,7 +3956,7 @@ static struct selection_node *_parse_and_ex(struct dm_report *rh,
struct selection_node *and_sn)
{
struct selection_node *n;
- const char *tmp;
+ const char *tmp = NULL;
n = _parse_ex(rh, s, next);
if (!n)
@@ -3988,7 +3988,7 @@ static struct selection_node *_parse_or_ex(struct dm_report *rh,
struct selection_node *or_sn)
{
struct selection_node *n;
- const char *tmp;
+ const char *tmp = NULL;
n = _parse_and_ex(rh, s, next, NULL);
if (!n)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index d9227dfd5..3918afba0 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -836,7 +836,7 @@ static void _collapse_slashes(char *str)
static int _insert_dir(const char *dir)
{
int n, dirent_count, r = 1;
- struct dirent **dirent;
+ struct dirent **dirent = NULL;
char path[PATH_MAX];
size_t len;
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index e8c552a85..1528cb173 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -126,7 +126,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
int i, count;
uint32_t ix;
char vgname_found[64], *path;
- struct dirent **dirent;
+ struct dirent **dirent = NULL;
struct archive_file *af;
struct dm_list *results;
diff --git a/lib/label/label.c b/lib/label/label.c
index aeee35259..4c243a43d 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -893,7 +893,7 @@ static int _setup_bcache(void)
static void _prepare_open_file_limit(struct cmd_context *cmd, unsigned int num_devs)
{
#ifdef HAVE_PRLIMIT
- struct rlimit old, new;
+ struct rlimit old = { 0 }, new;
unsigned int want = num_devs + BASE_FD_COUNT;
int rv;
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index c1934b5b7..050341a03 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -456,6 +456,7 @@ static int _merge_mirror_images(struct logical_volume *lv,
return 1;
img_lvs = alloca(sizeof(*img_lvs) * addition);
+ memset(img_lvs, 0, sizeof(*img_lvs) * addition);
dm_list_iterate_items(lvl, mimages)
img_lvs[i++] = lvl->lv;
@@ -1531,6 +1532,7 @@ static int _form_mirror(struct cmd_context *cmd, struct alloc_handle *ah,
* create mirror image LVs
*/
img_lvs = alloca(sizeof(*img_lvs) * mirrors);
+ memset(img_lvs, 0, sizeof(*img_lvs) * mirrors);
if (!_create_mimage_lvs(ah, mirrors, stripes, stripe_size, lv, img_lvs, log))
return_0;
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 2efcc07c9..f3bf628a5 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -2331,7 +2331,7 @@ static const char *_reserved_name(struct dm_report *rh,
uint32_t field_num, const char *s, size_t len)
{
dm_report_reserved_handler handler;
- const char *canonical_name;
+ const char *canonical_name = NULL;
const char **name;
char *tmp_s;
char c;
@@ -3909,7 +3909,7 @@ static struct selection_node *_parse_ex(struct dm_report *rh,
static const char _pe_expected_msg[] = "Syntax error: right parenthesis expected at \'%s\'";
struct selection_node *sn = NULL;
uint32_t t;
- const char *tmp;
+ const char *tmp = NULL;
t = _tok_op_log(s, next, SEL_MODIFIER_NOT | SEL_PRECEDENCE_PS);
if (t == SEL_MODIFIER_NOT) {
@@ -3955,7 +3955,7 @@ static struct selection_node *_parse_and_ex(struct dm_report *rh,
struct selection_node *and_sn)
{
struct selection_node *n;
- const char *tmp;
+ const char *tmp = NULL;
n = _parse_ex(rh, s, next);
if (!n)
@@ -3987,7 +3987,7 @@ static struct selection_node *_parse_or_ex(struct dm_report *rh,
struct selection_node *or_sn)
{
struct selection_node *n;
- const char *tmp;
+ const char *tmp = NULL;
n = _parse_and_ex(rh, s, next, NULL);
if (!n)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 120ad4d68..6cfa23384 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;
+ struct _extent ext = { 0 };
int64_t i;
group = &dms->groups[group_id];
@@ -4607,7 +4607,7 @@ static uint64_t *_stats_map_file_regions(struct dm_stats *dms, int fd,
struct dm_pool *extent_mem = NULL;
struct _extent *old_ext;
char *hist_arg = NULL;
- struct statfs fsbuf;
+ struct statfs fsbuf = { 0 };
int64_t nr_kept = 0;
struct stat buf;
int update;
diff --git a/tools/toollib.c b/tools/toollib.c
index 3bb04f92c..562cad06a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -123,7 +123,7 @@ const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
size_t devdir_len = strlen(cmd->dev_dir);
const char *dmdir = dm_dir() + devdir_len;
size_t dmdir_len = strlen(dmdir), vglv_sz;
- char *vgname, *lvname, *layer, *vglv;
+ char *vgname = NULL, *lvname, *layer, *vglv;
/* FIXME Do this properly */
if (*vg_name == '/')
2 years, 7 months
main - cov: initilized more struct members
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f5f1cdfa70ad2ec907f...
Commit: f5f1cdfa70ad2ec907fba8b9f5d0c1a251571c80
Parent: a8ee13900db58b018e143fbf6a3435c7803e82fe
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 23:07:40 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: initilized more struct members
For some hypothetical path, make these vars defined.
---
tools/toollib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/toollib.c b/tools/toollib.c
index 9d488c5a7..3bb04f92c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4010,6 +4010,8 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
};
struct volume_group dummy_vg = {
+ .cmd = cmd,
+ .vgmem = cmd->mem,
.extent_size = 1,
.fid = &dummy_fid,
.name = "",
2 years, 7 months
main - cov: initialize attr
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a8ee13900db58b018e1...
Commit: a8ee13900db58b018e143fbf6a3435c7803e82fe
Parent: be1c2a1ae2da445309f04ac4e3ed7470ff29d436
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 22:32:26 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: initialize attr
---
lib/activate/activate.c | 2 +-
lib/metadata/cache_manip.c | 2 +-
lib/metadata/lv_manip.c | 2 +-
lib/metadata/raid_manip.c | 4 ++--
lib/misc/lvm-exec.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index b44efc617..727bd2386 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1491,7 +1491,7 @@ int lvs_in_vg_opened(const struct volume_group *vg)
*/
int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
{
- unsigned attrs;
+ unsigned attrs = 0;
if (segtype_is_raid4(segtype) &&
(!segtype->ops->target_present ||
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 98821430f..b717e8a36 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -749,7 +749,7 @@ static const char *_get_default_cache_policy(struct cmd_context *cmd)
static cache_metadata_format_t _get_default_cache_metadata_format(struct cmd_context *cmd)
{
const struct segment_type *segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_CACHE);
- unsigned attr;
+ unsigned attr = 0;
cache_metadata_format_t f;
if (!segtype ||
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 4697ebbd8..e2efbf03a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5216,7 +5216,7 @@ static int _lvresize_check(struct logical_volume *lv,
if (lv_is_raid(lv) &&
lp->resize == LV_REDUCE) {
- unsigned attrs;
+ unsigned attrs = 0;
const struct segment_type *segtype = first_seg(lv)->segtype;
if (!segtype->ops->target_present ||
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index f0d401cde..60a10332e 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -46,7 +46,7 @@ static int _check_restriping(uint32_t new_stripes, struct logical_volume *lv)
*/
static int _reshape_is_supported(struct cmd_context *cmd, const struct segment_type *segtype)
{
- unsigned attrs;
+ unsigned attrs = 0;
if (!segtype->ops->target_present ||
!segtype->ops->target_present(cmd, NULL, &attrs) ||
@@ -65,7 +65,7 @@ static int _reshape_is_supported(struct cmd_context *cmd, const struct segment_t
static int _rebuild_with_emptymeta_is_supported(struct cmd_context *cmd,
const struct segment_type *segtype)
{
- unsigned attrs;
+ unsigned attrs = 0;
if (!segtype->ops->target_present ||
!segtype->ops->target_present(cmd, NULL, &attrs) ||
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c
index c60897ca6..77a2e0653 100644
--- a/lib/misc/lvm-exec.c
+++ b/lib/misc/lvm-exec.c
@@ -50,7 +50,7 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
int *rstatus, int sync_needed)
{
pid_t pid;
- int status;
+ int status = 0;
char buf[PATH_MAX * 2];
if (rstatus)
2 years, 7 months
main - cov: keep time calculation ready for 2038
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=be1c2a1ae2da445309f...
Commit: be1c2a1ae2da445309f04ac4e3ed7470ff29d436
Parent: 3ce8db8b889cbebdfe13aa394f5b6a9a9d00e25c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 22:37:36 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
cov: keep time calculation ready for 2038
Be prepared ;) and keep arithmetic 64bit ready.
---
lib/report/report.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 0fd0f30ac..efe103f43 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -819,7 +819,7 @@ static void _adjust_time_for_granularity(struct time_info *info, struct tm *tm,
#define SECS_PER_MINUTE 60
#define SECS_PER_HOUR 3600
-#define SECS_PER_DAY 86400
+#define SECS_PER_DAY ((time_t)86400)
static int _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
2 years, 7 months