summaryrefslogtreecommitdiffstats
path: root/Incremental.c
diff options
context:
space:
mode:
authorXiao Ni <xni@redhat.com>2024-07-26 09:14:06 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-08-05 11:07:59 +0200
commit17c99bab3e2e3606961d7ecec62c29921b5d6660 (patch)
treec4d379a837ca07e9dbdfa96bef66b322eef5e283 /Incremental.c
parentmdadm/Grow: fix coverity issue STRING_OVERFLOW (diff)
downloadmdadm-17c99bab3e2e3606961d7ecec62c29921b5d6660.tar.xz
mdadm-17c99bab3e2e3606961d7ecec62c29921b5d6660.zip
mdadm/Incremental: fix coverity issues.
There are two issues PW.PARAMETER_HIDDEN (declaration hides parameter 'devname') and INTEGER_OVERFLOW. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'Incremental.c')
-rw-r--r--Incremental.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Incremental.c b/Incremental.c
index abc7721b..fc4e68ff 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -770,7 +770,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
replcnt++;
st->ss->free_super(st);
}
- if (max_journal_events >= max_events - 1)
+ if (max_events > 0 && max_journal_events >= max_events - 1)
bestinfo->journal_clean = 1;
if (!avail)
@@ -1113,7 +1113,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
int fd = -1;
struct mdinfo info;
struct supertype *st2 = NULL;
- char *devname = NULL;
+ char *dev_path_name = NULL;
unsigned long long devsectors;
char *pathlist[2];
@@ -1142,14 +1142,14 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
domain_free(domlist);
domlist = NULL;
- if (asprintf(&devname, "/dev/disk/by-path/%s", de->d_name) != 1) {
- devname = NULL;
+ if (asprintf(&dev_path_name, "/dev/disk/by-path/%s", de->d_name) != 1) {
+ dev_path_name = NULL;
goto next;
}
- fd = open(devname, O_RDONLY);
+ fd = open(dev_path_name, O_RDONLY);
if (fd < 0)
goto next;
- if (get_dev_size(fd, devname, &devsectors) == 0)
+ if (get_dev_size(fd, dev_path_name, &devsectors) == 0)
goto next;
devsectors >>= 9;
@@ -1188,8 +1188,8 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
if (chosen == NULL || chosen_size < info.component_size) {
chosen_size = info.component_size;
free(chosen);
- chosen = devname;
- devname = NULL;
+ chosen = dev_path_name;
+ dev_path_name = NULL;
if (chosen_st) {
chosen_st->ss->free_super(chosen_st);
free(chosen_st);
@@ -1199,7 +1199,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
}
next:
- free(devname);
+ free(dev_path_name);
domain_free(domlist);
dev_policy_free(pol2);
if (st2)
@@ -1246,7 +1246,7 @@ static int is_bare(int dfd)
/* OK, first 4K appear blank, try the end. */
get_dev_size(dfd, NULL, &size);
- if (lseek(dfd, size-4096, SEEK_SET) < 0 ||
+ if ((size >= 4096 && lseek(dfd, size-4096, SEEK_SET) < 0) ||
read(dfd, buf, 4096) != 4096)
return 0;