[PATCH] lib: fwts_wakealarm: memset a rtc_tm struct to keep static analyzers happy
Colin King
colin.king at canonical.com
Tue Apr 7 17:19:45 UTC 2020
From: Colin Ian King <colin.king at canonical.com>
Coverity throws a warning of a potential use of unitialized fields
in the rtc_tm struct, so memset it to zero before calling the ioctl.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/lib/src/fwts_wakealarm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/lib/src/fwts_wakealarm.c b/src/lib/src/fwts_wakealarm.c
index 43718707..5c4c9375 100644
--- a/src/lib/src/fwts_wakealarm.c
+++ b/src/lib/src/fwts_wakealarm.c
@@ -41,6 +41,7 @@ int fwts_wakealarm_get(fwts_framework *fw, struct rtc_time *rtc_tm)
int fd;
int ret = FWTS_OK;
+ (void)memset(rtc_tm, 0, sizeof(*rtc_tm));
if ((fd = open(fwts_rtc, O_RDWR)) < 0) {
fwts_log_error(fw, "Cannot access Real Time Clock device %s.", fwts_rtc);
return FWTS_ERROR;
@@ -92,6 +93,7 @@ int fwts_wakealarm_trigger(fwts_framework *fw, const uint32_t seconds)
return FWTS_ERROR;
}
+ (void)memset(&rtc_tm, 0, sizeof(rtc_tm));
if (ioctl(fd, RTC_RD_TIME, &rtc_tm) < 0) {
fwts_log_error(fw, "Cannot read Real Time Clock with ioctl RTC_RD_TIME %s.", fwts_rtc);
ret = FWTS_ERROR;
--
2.25.1
More information about the fwts-devel
mailing list