Patchwork [06/18] acpi: s3power: print format using inttypes

login
register
mail settings
Submitter Colin King
Date Sept. 23, 2012, 7:03 p.m.
Message ID <1348427041-4913-7-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/186257/
State Accepted
Headers show

Comments

Colin King - Sept. 23, 2012, 7:03 p.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/s3power/s3power.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Keng-Yu Lin - Sept. 26, 2012, 10:01 a.m.
On Mon, Sep 24, 2012 at 3:03 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/s3power/s3power.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
> index e5c4ba0..a57bcba 100644
> --- a/src/acpi/s3power/s3power.c
> +++ b/src/acpi/s3power/s3power.c
> @@ -28,6 +28,7 @@
>  #include <sys/stat.h>
>  #include <unistd.h>
>  #include <time.h>
> +#include <inttypes.h>
>
>  #define PM_SUSPEND "pm-suspend"
>
> @@ -122,7 +123,7 @@ static void s3power_difference(fwts_framework *fw,
>         float hourly_loss;
>
>         if (before != 0) {
> -               fwts_log_info(fw, "Change in capacity: %d %s\n", (int)diff, units);
> +               fwts_log_info(fw, "Change in capacity: %" PRId32 " %s\n", diff, units);
>                 hourly_loss = ((float)diff * 3600.0) / (float)s3power_sleep_delay;
>                 if (diff < 0) {
>                         fwts_log_error(fw, "Negative loss of power, are you sure the machine was not charging?");
> @@ -130,7 +131,7 @@ static void s3power_difference(fwts_framework *fw,
>                 fwts_log_info(fw, "Loss of %7.4f %s per hour.", hourly_loss, units);
>                 if ((diff > 0) && (battery_capacity > 0)) {
>                         float duration = (float)battery_capacity / hourly_loss;
> -                       fwts_log_info(fw, "The %d %s battery will provide %5.2f hours of suspend time.",
> +                       fwts_log_info(fw, "The %" PRIu32 " %s battery will provide %5.2f hours of suspend time.",
>                                 battery_capacity, units, duration);
>
>                         if (duration < 24.0) {
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Oct. 2, 2012, 2:25 a.m.
On 09/24/2012 03:03 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/s3power/s3power.c |    5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
> index e5c4ba0..a57bcba 100644
> --- a/src/acpi/s3power/s3power.c
> +++ b/src/acpi/s3power/s3power.c
> @@ -28,6 +28,7 @@
>   #include <sys/stat.h>
>   #include <unistd.h>
>   #include <time.h>
> +#include <inttypes.h>
>
>   #define PM_SUSPEND "pm-suspend"
>
> @@ -122,7 +123,7 @@ static void s3power_difference(fwts_framework *fw,
>   	float hourly_loss;
>
>   	if (before != 0) {
> -		fwts_log_info(fw, "Change in capacity: %d %s\n", (int)diff, units);
> +		fwts_log_info(fw, "Change in capacity: %" PRId32 " %s\n", diff, units);
>   		hourly_loss = ((float)diff * 3600.0) / (float)s3power_sleep_delay;
>   		if (diff < 0) {
>   			fwts_log_error(fw, "Negative loss of power, are you sure the machine was not charging?");
> @@ -130,7 +131,7 @@ static void s3power_difference(fwts_framework *fw,
>   		fwts_log_info(fw, "Loss of %7.4f %s per hour.", hourly_loss, units);
>   		if ((diff > 0) && (battery_capacity > 0)) {
>   			float duration = (float)battery_capacity / hourly_loss;
> -			fwts_log_info(fw, "The %d %s battery will provide %5.2f hours of suspend time.",
> +			fwts_log_info(fw, "The %" PRIu32 " %s battery will provide %5.2f hours of suspend time.",
>   				battery_capacity, units, duration);
>
>   			if (duration < 24.0) {
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
index e5c4ba0..a57bcba 100644
--- a/src/acpi/s3power/s3power.c
+++ b/src/acpi/s3power/s3power.c
@@ -28,6 +28,7 @@ 
 #include <sys/stat.h>
 #include <unistd.h>
 #include <time.h>
+#include <inttypes.h>
 
 #define PM_SUSPEND "pm-suspend"
 
@@ -122,7 +123,7 @@  static void s3power_difference(fwts_framework *fw,
 	float hourly_loss;
 
 	if (before != 0) {
-		fwts_log_info(fw, "Change in capacity: %d %s\n", (int)diff, units);
+		fwts_log_info(fw, "Change in capacity: %" PRId32 " %s\n", diff, units);
 		hourly_loss = ((float)diff * 3600.0) / (float)s3power_sleep_delay;
 		if (diff < 0) {
 			fwts_log_error(fw, "Negative loss of power, are you sure the machine was not charging?");
@@ -130,7 +131,7 @@  static void s3power_difference(fwts_framework *fw,
 		fwts_log_info(fw, "Loss of %7.4f %s per hour.", hourly_loss, units);
 		if ((diff > 0) && (battery_capacity > 0)) {
 			float duration = (float)battery_capacity / hourly_loss;
-			fwts_log_info(fw, "The %d %s battery will provide %5.2f hours of suspend time.",
+			fwts_log_info(fw, "The %" PRIu32 " %s battery will provide %5.2f hours of suspend time.",
 				battery_capacity, units, duration);
 
 			if (duration < 24.0) {