Skip to content

rtc: Fix compiler warning in driver initialization.#9251

Merged
pkarashchenko merged 1 commit into
apache:masterfrom
fjpanag:rtc
May 11, 2023
Merged

rtc: Fix compiler warning in driver initialization.#9251
pkarashchenko merged 1 commit into
apache:masterfrom
fjpanag:rtc

Conversation

@fjpanag
Copy link
Copy Markdown
Contributor

@fjpanag fjpanag commented May 11, 2023

Summary

The RTC driver causes the following warning:

timers/rtc.c: In function ‘rtc_initialize’:
timers/rtc.c:851:34: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
  851 |   snprintf(devpath, 16, "/dev/rtc%d", minor);
      |                                  ^~
timers/rtc.c:851:25: note: directive argument in the range [-2147483648, 999]
  851 |   snprintf(devpath, 16, "/dev/rtc%d", minor);
      |                         ^~~~~~~~~~~~
timers/rtc.c:851:3: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16
  851 |   snprintf(devpath, 16, "/dev/rtc%d", minor);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This PR fixes this warning.
The devpath is slightly enlarged, to ensure that all possible numbers can be reliably printed.

Impact

Practically none.

The buffer is enlarged by just 4 bytes, but it is also located in the stack. So it shouldn't have any actual impact on any practical application.

Testing

Build test only.

Comment thread drivers/timers/rtc.c Outdated
@pkarashchenko pkarashchenko merged commit 4231938 into apache:master May 11, 2023
@fjpanag fjpanag deleted the rtc branch May 12, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants