arduino-libraries / RTCZero

RTC Library for SAMD21 based boards
http://arduino.cc/en/Reference/RTC
GNU Lesser General Public License v2.1
78 stars 78 forks source link

Warning on compiling with oldTime.RTC_MODE2_CLOCK_Type::reg #60

Open fmatray opened 4 years ago

fmatray commented 4 years ago

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.