lib: fwts_wakealarm: make wakealarm times uint32_t

Message ID 20170908110009.30488-1-colin.king@canonical.com
State New
Headers show
Series
  • lib: fwts_wakealarm: make wakealarm times uint32_t
Related show

Commit Message

Colin King Sept. 8, 2017, 11 a.m.
From: Colin Ian King <colin.king@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@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(-)

Comments

Alex Hung Sept. 11, 2017, 4:52 p.m. | #1
On 2017-09-08 04:00 AM, Colin King wrote:
> From: Colin Ian King <colin.king@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@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;
>   
> 

Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

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;