mdadm: Fixup more broken logical operator formatting

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
Jes Sorensen 2017-05-16 13:59:43 -04:00
parent fc54fe7a7e
commit d7be7d8736
11 changed files with 38 additions and 38 deletions

View File

@ -220,8 +220,8 @@ static int select_devices(struct mddev_dev *devlist,
pr_err("not a recognisable container: %s\n", pr_err("not a recognisable container: %s\n",
devname); devname);
tmpdev->used = 2; tmpdev->used = 2;
} else if (!tst->ss->load_container } else if (!tst->ss->load_container ||
|| tst->ss->load_container(tst, dfd, NULL)) { tst->ss->load_container(tst, dfd, NULL)) {
if (report_mismatch) if (report_mismatch)
pr_err("no correct container type: %s\n", pr_err("no correct container type: %s\n",
devname); devname);
@ -776,9 +776,8 @@ static int load_devices(struct devs *devices, char *devmap,
*stp = st; *stp = st;
return -1; return -1;
} }
if (best[i] == -1 if (best[i] == -1 || (devices[best[i]].i.events
|| (devices[best[i]].i.events < devices[devcnt].i.events))
< devices[devcnt].i.events))
best[i] = devcnt; best[i] = devcnt;
} }
devcnt++; devcnt++;

16
Grow.c
View File

@ -3995,8 +3995,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
* a backup. * a backup.
*/ */
if (advancing) { if (advancing) {
if ((need_backup > info->reshape_progress if ((need_backup > info->reshape_progress ||
|| info->array.major_version < 0) && info->array.major_version < 0) &&
*suspend_point < info->reshape_progress + target) { *suspend_point < info->reshape_progress + target) {
if (need_backup < *suspend_point + 2 * target) if (need_backup < *suspend_point + 2 * target)
*suspend_point = need_backup; *suspend_point = need_backup;
@ -4149,8 +4149,9 @@ check_progress:
* it was just a device failure that leaves us degraded but * it was just a device failure that leaves us degraded but
* functioning. * functioning.
*/ */
if (sysfs_get_str(info, NULL, "reshape_position", buf, sizeof(buf)) < 0 if (sysfs_get_str(info, NULL, "reshape_position", buf,
|| strncmp(buf, "none", 4) != 0) { sizeof(buf)) < 0 ||
strncmp(buf, "none", 4) != 0) {
/* The abort might only be temporary. Wait up to 10 /* The abort might only be temporary. Wait up to 10
* seconds for fd to contain a valid number again. * seconds for fd to contain a valid number again.
*/ */
@ -4182,9 +4183,10 @@ check_progress:
/* Maybe racing with array shutdown - check state */ /* Maybe racing with array shutdown - check state */
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
if (sysfs_get_str(info, NULL, "array_state", buf, sizeof(buf)) < 0 if (sysfs_get_str(info, NULL, "array_state", buf,
|| strncmp(buf, "inactive", 8) == 0 sizeof(buf)) < 0 ||
|| strncmp(buf, "clear",5) == 0) strncmp(buf, "inactive", 8) == 0 ||
strncmp(buf, "clear",5) == 0)
return -2; /* abort */ return -2; /* abort */
return -1; /* complete */ return -1; /* complete */
} }

View File

@ -655,8 +655,8 @@ int attempt_re_add(int fd, int tfd, struct mddev_dev *dv,
if (dv->failfast == FlagClear) if (dv->failfast == FlagClear)
disc.state &= ~(1 << MD_DISK_FAILFAST); disc.state &= ~(1 << MD_DISK_FAILFAST);
remove_partitions(tfd); remove_partitions(tfd);
if (update || dv->writemostly != FlagDefault if (update || dv->writemostly != FlagDefault ||
|| dv->failfast != FlagDefault) { dv->failfast != FlagDefault) {
int rv = -1; int rv = -1;
tfd = dev_open(dv->devname, O_RDWR); tfd = dev_open(dv->devname, O_RDWR);
if (tfd < 0) { if (tfd < 0) {

View File

@ -530,7 +530,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->utime == array.utime && st->failed == sra->array.failed_disks && if (st->utime == array.utime && st->failed == sra->array.failed_disks &&
st->working == sra->array.working_disks && st->working == sra->array.working_disks &&
st->spare == sra->array.spare_disks && st->spare == sra->array.spare_disks &&
(mse == NULL || (mse->percent == st->percent))) { (mse == NULL || (mse->percent == st->percent))) {
if ((st->active < st->raid) && st->spare == 0) if ((st->active < st->raid) && st->spare == 0)
retval = 1; retval = 1;
goto out; goto out;
@ -672,7 +672,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
char *name; char *name;
for (mse = mdstat; mse; mse = mse->next) for (mse = mdstat; mse; mse = mse->next)
if (mse->devnm[0] && (!mse->level || /* retrieve containers */ if (mse->devnm[0] && (!mse->level || /* retrieve containers */
(strcmp(mse->level, "raid0") != 0 && (strcmp(mse->level, "raid0") != 0 &&
strcmp(mse->level, "linear") != 0))) { strcmp(mse->level, "linear") != 0))) {
struct state *st = xcalloc(1, sizeof *st); struct state *st = xcalloc(1, sizeof *st);

View File

@ -439,8 +439,8 @@ void RebuildMap(void)
if ((homehost == NULL || if ((homehost == NULL ||
st->ss->match_home(st, homehost) != 1) && st->ss->match_home(st, homehost) != 1) &&
st->ss->match_home(st, "any") != 1 && st->ss->match_home(st, "any") != 1 &&
(require_homehost (require_homehost ||
|| ! conf_name_is_free(info->name))) !conf_name_is_free(info->name)))
/* require a numeric suffix */ /* require a numeric suffix */
unum = 0; unum = 0;
else else

View File

@ -166,8 +166,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
continue; continue;
insert_here = NULL; insert_here = NULL;
/* Better be an md line.. */ /* Better be an md line.. */
if (strncmp(line, "md", 2)!= 0 || strlen(line) >= 32 if (strncmp(line, "md", 2)!= 0 || strlen(line) >= 32 ||
|| (line[2] != '_' && !isdigit(line[2]))) (line[2] != '_' && !isdigit(line[2])))
continue; continue;
strcpy(devnm, line); strcpy(devnm, line);
@ -212,8 +212,10 @@ struct mdstat_ent *mdstat_read(int hold, int start)
struct mdstat_ent **ih; struct mdstat_ent **ih;
ih = &all; ih = &all;
while (ih != insert_here && *ih && while (ih != insert_here && *ih &&
((int)strlen((*ih)->devnm) != ep-w ((int)strlen((*ih)->devnm) !=
|| strncmp((*ih)->devnm, w, ep-w) != 0)) ep-w ||
strncmp((*ih)->devnm, w,
ep-w) != 0))
ih = & (*ih)->next; ih = & (*ih)->next;
insert_here = ih; insert_here = ih;
} }

View File

@ -548,8 +548,8 @@ static int read_efi_variable(void *buffer, ssize_t buf_size, char *variable_name
errno = 0; errno = 0;
var_data_len = strtoul(buf, NULL, 16); var_data_len = strtoul(buf, NULL, 16);
if ((errno == ERANGE && (var_data_len == LONG_MAX)) if ((errno == ERANGE && (var_data_len == LONG_MAX)) ||
|| (errno != 0 && var_data_len == 0)) (errno != 0 && var_data_len == 0))
return 1; return 1;
/* get data */ /* get data */

View File

@ -731,8 +731,8 @@ int restore_stripes(int *dest, unsigned long long *offsets,
zero_size = chunk_size; zero_size = chunk_size;
} }
if (stripe_buf == NULL || stripes == NULL || blocks == NULL if (stripe_buf == NULL || stripes == NULL || blocks == NULL ||
|| zero == NULL) { zero == NULL) {
rv = -2; rv = -2;
goto abort; goto abort;
} }

View File

@ -932,14 +932,13 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname)
if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba), if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba),
dsize >> 9, 2, dsize >> 9, 2,
&super->secondary, &super->anchor)) { &super->secondary, &super->anchor)) {
if (super->active == NULL if (super->active == NULL ||
|| (be32_to_cpu(super->primary.seq) (be32_to_cpu(super->primary.seq)
< be32_to_cpu(super->secondary.seq) && < be32_to_cpu(super->secondary.seq) &&
!super->secondary.openflag) !super->secondary.openflag) ||
|| (be32_to_cpu(super->primary.seq) (be32_to_cpu(super->primary.seq) ==
== be32_to_cpu(super->secondary.seq) && be32_to_cpu(super->secondary.seq) &&
super->primary.openflag && !super->secondary.openflag) super->primary.openflag && !super->secondary.openflag))
)
super->active = &super->secondary; super->active = &super->secondary;
} else if (devname && } else if (devname &&
be64_to_cpu(super->anchor.secondary_lba) != ~(__u64)0) be64_to_cpu(super->anchor.secondary_lba) != ~(__u64)0)

View File

@ -10874,8 +10874,7 @@ static int imsm_create_metadata_update_for_reshape(
*/ */
spares = get_spares_for_grow(st); spares = get_spares_for_grow(st);
if (spares == NULL if (spares == NULL || delta_disks > spares->array.spare_disks) {
|| delta_disks > spares->array.spare_disks) {
pr_err("imsm: ERROR: Cannot get spare devices for %s.\n", geo->dev_name); pr_err("imsm: ERROR: Cannot get spare devices for %s.\n", geo->dev_name);
i = -1; i = -1;
goto abort; goto abort;

3
util.c
View File

@ -2213,8 +2213,7 @@ void enable_fds(int devices)
{ {
unsigned int fds = 20 + devices; unsigned int fds = 20 + devices;
struct rlimit lim; struct rlimit lim;
if (getrlimit(RLIMIT_NOFILE, &lim) != 0 if (getrlimit(RLIMIT_NOFILE, &lim) != 0 || lim.rlim_cur >= fds)
|| lim.rlim_cur >= fds)
return; return;
if (lim.rlim_max < fds) if (lim.rlim_max < fds)
lim.rlim_max = fds; lim.rlim_max = fds;