Skip to content

Commit e2d7c08

Browse files
authored
Merge pull request #709 from d-a-v/patch-1
Fix warning from avr compilers on "constant overflow"
2 parents e8079b9 + 3cd1900 commit e2d7c08

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lmic/lmic.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,12 @@ ostime_t LMICcore_adjustForDrift (ostime_t delay, ostime_t hsym, rxsyms_t rxsyms
14761476
// a compile-time configuration. (In other words, assume that millis()
14771477
// clock is accurate to 0.1%.) You should never use clockerror to
14781478
// compensate for system-late problems.
1479-
u2_t const maxError = LMIC_kMaxClockError_ppm * MAX_CLOCK_ERROR / (1000 * 1000);
1479+
// note about compiler: The initializer for maxError is coded for
1480+
// maximum portability. On 16-bit systems, some compilers complain
1481+
// if we write x / (1000 * 1000). x / 1000 / 1000 uses constants,
1482+
// is generally acceptable so it can be optimized in compiler's own
1483+
// way.
1484+
u2_t const maxError = LMIC_kMaxClockError_ppm * MAX_CLOCK_ERROR / 1000 / 1000;
14801485
if (! LMIC_ENABLE_arbitrary_clock_error && clockerr > maxError)
14811486
{
14821487
clockerr = maxError;

0 commit comments

Comments
 (0)