Skip to content

Commit

Permalink
Merge pull request #709 from d-a-v/patch-1
Browse files Browse the repository at this point in the history
Fix warning from avr compilers on "constant overflow"
  • Loading branch information
terrillmoore authored Apr 15, 2021
2 parents e8079b9 + 3cd1900 commit e2d7c08
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,12 @@ ostime_t LMICcore_adjustForDrift (ostime_t delay, ostime_t hsym, rxsyms_t rxsyms
// a compile-time configuration. (In other words, assume that millis()
// clock is accurate to 0.1%.) You should never use clockerror to
// compensate for system-late problems.
u2_t const maxError = LMIC_kMaxClockError_ppm * MAX_CLOCK_ERROR / (1000 * 1000);
// note about compiler: The initializer for maxError is coded for
// maximum portability. On 16-bit systems, some compilers complain
// if we write x / (1000 * 1000). x / 1000 / 1000 uses constants,
// is generally acceptable so it can be optimized in compiler's own
// way.
u2_t const maxError = LMIC_kMaxClockError_ppm * MAX_CLOCK_ERROR / 1000 / 1000;
if (! LMIC_ENABLE_arbitrary_clock_error && clockerr > maxError)
{
clockerr = maxError;
Expand Down

0 comments on commit e2d7c08

Please sign in to comment.