Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 41aec59

Browse files
committedJul 24, 2020
Remove redundant "? 1 : 0" after comparisons
1 parent 2309c7d commit 41aec59

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎src/scalar_8x32_impl.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) {
271271
tl = t; \
272272
} \
273273
c0 += tl; /* overflow is handled on the next line */ \
274-
th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \
274+
th += (c0 < tl); /* at most 0xFFFFFFFF */ \
275275
c1 += th; /* overflow is handled on the next line */ \
276-
c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \
276+
c2 += (c1 < th); /* never overflows by contract (verified in the next line) */ \
277277
VERIFY_CHECK((c1 >= th) || (c2 != 0)); \
278278
}
279279

@@ -286,7 +286,7 @@ static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) {
286286
tl = t; \
287287
} \
288288
c0 += tl; /* overflow is handled on the next line */ \
289-
th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \
289+
th += (c0 < tl); /* at most 0xFFFFFFFF */ \
290290
c1 += th; /* never overflows by contract (verified in the next line) */ \
291291
VERIFY_CHECK(c1 >= th); \
292292
}
@@ -300,32 +300,32 @@ static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) {
300300
tl = t; \
301301
} \
302302
th2 = th + th; /* at most 0xFFFFFFFE (in case th was 0x7FFFFFFF) */ \
303-
c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \
303+
c2 += (th2 < th); /* never overflows by contract (verified the next line) */ \
304304
VERIFY_CHECK((th2 >= th) || (c2 != 0)); \
305305
tl2 = tl + tl; /* at most 0xFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFF) */ \
306-
th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \
306+
th2 += (tl2 < tl); /* at most 0xFFFFFFFF */ \
307307
c0 += tl2; /* overflow is handled on the next line */ \
308-
th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \
308+
th2 += (c0 < tl2); /* second overflow is handled on the next line */ \
309309
c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \
310310
VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \
311311
c1 += th2; /* overflow is handled on the next line */ \
312-
c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \
312+
c2 += (c1 < th2); /* never overflows by contract (verified the next line) */ \
313313
VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \
314314
}
315315

316316
/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */
317317
#define sumadd(a) { \
318318
unsigned int over; \
319319
c0 += (a); /* overflow is handled on the next line */ \
320-
over = (c0 < (a)) ? 1 : 0; \
320+
over = (c0 < (a)); \
321321
c1 += over; /* overflow is handled on the next line */ \
322-
c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \
322+
c2 += (c1 < over); /* never overflows by contract */ \
323323
}
324324

325325
/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */
326326
#define sumadd_fast(a) { \
327327
c0 += (a); /* overflow is handled on the next line */ \
328-
c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \
328+
c1 += (c0 < (a)); /* never overflows by contract (verified the next line) */ \
329329
VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \
330330
VERIFY_CHECK(c2 == 0); \
331331
}

0 commit comments

Comments
 (0)
Please sign in to comment.