Skip to content

Commit 8237624

Browse files
committed
delta: minor coding style fixes
no change in behaviour
1 parent 394bac4 commit 8237624

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/delta/delta.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,16 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
428428
}
429429

430430
finish:
431-
if (top)
432-
hashmap_free_free(top);
433-
if (bottom)
434-
hashmap_free_free(bottom);
435-
if (drops) {
436-
HASHMAP_FOREACH_KEY(h, key, drops, i){
437-
hashmap_free_free(hashmap_remove(drops, key));
438-
hashmap_remove(drops, key);
439-
free(key);
440-
}
441-
hashmap_free(drops);
431+
hashmap_free_free(top);
432+
hashmap_free_free(bottom);
433+
434+
HASHMAP_FOREACH_KEY(h, key, drops, i){
435+
hashmap_free_free(hashmap_remove(drops, key));
436+
hashmap_remove(drops, key);
437+
free(key);
442438
}
439+
hashmap_free(drops);
440+
443441
return r < 0 ? r : n_found;
444442
}
445443

@@ -451,9 +449,10 @@ static int process_suffixes(const char *onlyprefix) {
451449
r = process_suffix(n, onlyprefix);
452450
if (r < 0)
453451
return r;
454-
else
455-
n_found += r;
452+
453+
n_found += r;
456454
}
455+
457456
return n_found;
458457
}
459458

@@ -467,7 +466,9 @@ static int process_suffix_chop(const char *arg) {
467466

468467
/* Strip prefix from the suffix */
469468
NULSTR_FOREACH(p, prefixes) {
470-
const char *suffix = startswith(arg, p);
469+
const char *suffix;
470+
471+
suffix = startswith(arg, p);
471472
if (suffix) {
472473
suffix += strspn(suffix, "/");
473474
if (*suffix)
@@ -575,10 +576,9 @@ static int parse_argv(int argc, char *argv[]) {
575576
if (b < 0) {
576577
log_error("Failed to parse diff boolean.");
577578
return -EINVAL;
578-
} else if (b)
579-
arg_diff = 1;
580-
else
581-
arg_diff = 0;
579+
}
580+
581+
arg_diff = b;
582582
}
583583
break;
584584

@@ -593,8 +593,7 @@ static int parse_argv(int argc, char *argv[]) {
593593
}
594594

595595
int main(int argc, char *argv[]) {
596-
int r = 0, k;
597-
int n_found = 0;
596+
int r, k, n_found = 0;
598597

599598
log_parse_environment();
600599
log_open();
@@ -618,6 +617,7 @@ int main(int argc, char *argv[]) {
618617

619618
for (i = optind; i < argc; i++) {
620619
path_kill_slashes(argv[i]);
620+
621621
k = process_suffix_chop(argv[i]);
622622
if (k < 0)
623623
r = k;
@@ -634,8 +634,7 @@ int main(int argc, char *argv[]) {
634634
}
635635

636636
if (r >= 0)
637-
printf("%s%i overridden configuration files found.\n",
638-
n_found ? "\n" : "", n_found);
637+
printf("%s%i overridden configuration files found.\n", n_found ? "\n" : "", n_found);
639638

640639
finish:
641640
pager_close();

0 commit comments

Comments
 (0)