RTCZero icon indicating copy to clipboard operation
RTCZero copied to clipboard

Warning on compiling with oldTime.RTC_MODE2_CLOCK_Type::reg

Open fmatray opened this issue 5 years ago • 0 comments
trafficstars

Hello, I get a warning in RTCZero.cpp line 96:26, without having a bug.

'oldTime.RTC_MODE2_CLOCK_Type::reg' may be used uninitialized in this function [-Wmaybe-uninitialized]

line 96:26 :

if ((!resetTime) && (validTime) && (oldTime.reg != 0L)) {
    RTC->MODE2.CLOCK.reg = oldTime.reg;
  }

Looking at the code, I guess the problem is here, there no "else" or an initialization to define "oldTime.reg".

 if ((!resetTime) && (PM->RCAUSE.reg & (PM_RCAUSE_SYST | PM_RCAUSE_WDT | PM_RCAUSE_EXT))) {
    if (RTC->MODE2.CTRL.reg & RTC_MODE2_CTRL_MODE_CLOCK) {
      validTime = true;
      oldTime.reg = RTC->MODE2.CLOCK.reg;
    }
  }

Thanks a lot.

fmatray avatar May 25 '20 15:05 fmatray