commit fa6be1b548016de8ae60722acbcfaf76a02fd8b3
parent ba1e25b338eb74f8c40bc91682da3ea2e02e5725
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date: Wed, 23 Sep 2020 17:25:37 +1000
pedantry: consolidate `= 0` statments
Diffstat:
3 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/bsdiff.c b/bsdiff.c
@@ -96,8 +96,7 @@ main(int argc, char **argv)
if (((db = malloc(newsize + 1)) == NULL) ||
((eb = malloc(newsize + 1)) == NULL))
err(1, NULL);
- dblen = 0;
- eblen = 0;
+ dblen = eblen = 0;
/* Create the patch file */
if ((pf = fopen(argv[3], "w")) == NULL)
@@ -123,11 +122,7 @@ main(int argc, char **argv)
/* Compute the differences, writing ctrl as we go */
if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL)
errx(1, "BZ2_bzWriteOpen, bz2err = %d", bz2err);
- scan = 0;
- len = 0;
- lastscan = 0;
- lastpos = 0;
- lastoffset = 0;
+ scan = len = lastscan = lastpos = lastoffset = 0;
while (scan < newsize) {
oldscore = 0;
@@ -150,9 +145,7 @@ main(int argc, char **argv)
}
if ((len != oldscore) || (scan == newsize)) {
- s = 0;
- Sf = 0;
- lenf = 0;
+ s = Sf = lenf = 0;
for (i = 0; (lastscan + i < scan) &&
(lastpos + i < oldsize);) {
if (old[lastpos + i] == new[lastscan + i])
@@ -166,8 +159,7 @@ main(int argc, char **argv)
lenb = 0;
if (scan < newsize) {
- s = 0;
- Sb = 0;
+ s = Sb = 0;
for (i = 1;
(scan >= lastscan + i) && (pos >= i);
i++) {
@@ -182,9 +174,7 @@ main(int argc, char **argv)
if (lastscan + lenf > scan - lenb) {
overlap = (lastscan + lenf) - (scan - lenb);
- s = 0;
- Ss = 0;
- lens = 0;
+ s = Ss = lens = 0;
for (i = 0; i < overlap; i++) {
if (new[lastscan + lenf - overlap +
i] ==
diff --git a/bspatch.c b/bspatch.c
@@ -129,8 +129,7 @@ main(int argc, char *argv[])
if ((new = malloc(newsize + 1)) == NULL)
err(1, NULL);
- oldpos = 0;
- newpos = 0;
+ oldpos = newpos = 0;
while (newpos < newsize) {
/* Read control data */
for (i = 0; i <= 2; i++) {
diff --git a/util.c b/util.c
@@ -62,8 +62,7 @@ split(off_t *I, off_t *V, off_t start, off_t len, off_t h)
}
x = V[I[start + len / 2] + h];
- jj = 0;
- kk = 0;
+ jj = kk = 0;
for (i = start; i < start + len; i++) {
if (V[I[i] + h] < x)
jj++;
@@ -74,8 +73,7 @@ split(off_t *I, off_t *V, off_t start, off_t len, off_t h)
kk += jj;
i = start;
- j = 0;
- k = 0;
+ j = k = 0;
while (i < jj) {
if (V[I[i] + h] < x) {
i++;