Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fmatray opened this issue May 25, 2020 · 0 comments · May be fixed by #82
Open

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

fmatray opened this issue May 25, 2020 · 0 comments · May be fixed by #82

Comments

@fmatray
Copy link

fmatray commented May 25, 2020

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.

JeromeBriot added a commit to JeromeBriot/RTCZero that referenced this issue Jan 7, 2022
Fix warning on compiling with oldTime.RTC_MODE2_CLOCK_Type::reg (arduino-libraries#67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant