[PATCH] lib: fwts_wakealarm: make wakealarm times uint32_t

Colin King colin.king at canonical.com
Fri Sep 8 11:00:09 UTC 2017


From: Colin Ian King <colin.king at canonical.com>

A wakealarm of negative time should not be allowed, so make the
timings uint32_t rather than int.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/wakealarm/wakealarm.c   | 4 ++--
 src/lib/include/fwts_wakealarm.h | 4 ++--
 src/lib/src/fwts_wakealarm.c     | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/acpi/wakealarm/wakealarm.c b/src/acpi/wakealarm/wakealarm.c
index 0e9551ad..fa81a642 100644
--- a/src/acpi/wakealarm/wakealarm.c
+++ b/src/acpi/wakealarm/wakealarm.c
@@ -92,11 +92,11 @@ static int wakealarm_test3(fwts_framework *fw)
 
 static int wakealarm_test4(fwts_framework *fw)
 {
-	int i;
+	uint32_t i;
 	int failed = 0;
 
 	for (i = 1; i < 5; i++) {
-		fwts_log_info(fw, "Trigger wakealarm for %d seconds in the future.", i);
+		fwts_log_info(fw, "Trigger wakealarm for %" PRIu32 " seconds in the future.", i);
 		int ret = fwts_wakealarm_test_firing(fw, i);
 		if (ret < 0) {
 			fwts_failed(fw, LOG_LEVEL_MEDIUM,
diff --git a/src/lib/include/fwts_wakealarm.h b/src/lib/include/fwts_wakealarm.h
index ded3b935..87f70a51 100644
--- a/src/lib/include/fwts_wakealarm.h
+++ b/src/lib/include/fwts_wakealarm.h
@@ -25,8 +25,8 @@
 #include "fwts_framework.h"
 
 int fwts_wakealarm_exits(fwts_framework *fw);
-int fwts_wakealarm_test_firing(fwts_framework *fw, const int sleep);
-int fwts_wakealarm_trigger(fwts_framework *fw, const int seconds);
+int fwts_wakealarm_test_firing(fwts_framework *fw, const uint32_t sleep);
+int fwts_wakealarm_trigger(fwts_framework *fw, const uint32_t seconds);
 int fwts_wakealarm_cancel(fwts_framework *fw);
 int fwts_wakealarm_get(fwts_framework *fw, struct rtc_time *rtc_tm);
 int fwts_wakealarm_set(fwts_framework *fw, struct rtc_time *rtc_tm);
diff --git a/src/lib/src/fwts_wakealarm.c b/src/lib/src/fwts_wakealarm.c
index 5ae902f1..c0550303 100644
--- a/src/lib/src/fwts_wakealarm.c
+++ b/src/lib/src/fwts_wakealarm.c
@@ -93,7 +93,7 @@ int fwts_wakealarm_exits(fwts_framework *fw)
  *  fwts_wakealarm_trigger()
  *	trigger the RTC wakealarm to fire in 'seconds' seconds from now.
  */
-int fwts_wakealarm_trigger(fwts_framework *fw, const int seconds)
+int fwts_wakealarm_trigger(fwts_framework *fw, const uint32_t seconds)
 {
 	int fd, ret = FWTS_OK;
 	struct rtc_time rtc_tm;
@@ -161,7 +161,7 @@ int fwts_wakealarm_cancel(fwts_framework *fw)
  *  fwts_wakealarm_check_fired()
  *	check if wakealarm fires
  */
-int fwts_wakealarm_check_fired(fwts_framework *fw, const int seconds)
+int fwts_wakealarm_check_fired(fwts_framework *fw, const uint32_t seconds)
 {
 	int fd, rc, ret = FWTS_OK;
 	fd_set rfds;
@@ -204,7 +204,7 @@ out:
  *	test RTC wakealarm trigger and firing from 'seconds' seconds time
  * 	from now.  returns FWTS_OK if passed, otherwise FWTS_ERROR.
  */
-int fwts_wakealarm_test_firing(fwts_framework *fw, const int seconds)
+int fwts_wakealarm_test_firing(fwts_framework *fw, const uint32_t seconds)
 {
 	int ret = FWTS_OK;
 
-- 
2.14.1




More information about the fwts-devel mailing list