Re: [hackers] [slstatus][PATCH] Fix temperature reporting on OpenBSD.

2020-11-30 Thread Aaron Marcher

A little bit late, but merged. Thanks!

On 19-10-31 Thu, dsp wrote:

Hey list!

On OpenBSD i noticed that if you set the temperature component to be printed
it will only show the first digit due to the integer division. So for example
a temperature of 54 C shows as 5. This patch first treats it as a float
before truncating the non decimal digits.

From 407f7477bc99fd493922ff73c9803bd1b5d1dfac Mon Sep 17 00:00:00 2001
From: spiros thanasoulas 
Date: Thu, 31 Oct 2019 20:36:04 -0600
Subject: [PATCH] On OpenBSD although the formula is correct due to integer
division a temperature of for example 54 celsius appears as 5. this patch
first treats it as a floating point op before retaining the non decimal
digits

---
components/temperature.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/temperature.c b/components/temperature.c
index 8462d0f..8e1f222 100644
--- a/components/temperature.c
+++ b/components/temperature.c
@@ -45,7 +45,7 @@
}

/* kelvin to celsius */
-   return bprintf("%d", (temp.value - 27315) / 1E6);
+   return bprintf("%d", (int)((float)(temp.value-27315) / 
1E6));
}
#elif defined(__FreeBSD__)
#include 
--
2.23.0



--
Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/
GPG: 0x7A65E38D55BE96FE
Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE



[hackers] [slstatus][PATCH] Fix temperature reporting on OpenBSD.

2019-10-31 Thread dsp
Hey list!

On OpenBSD i noticed that if you set the temperature component to be printed
it will only show the first digit due to the integer division. So for example
a temperature of 54 C shows as 5. This patch first treats it as a float 
before truncating the non decimal digits. 

From 407f7477bc99fd493922ff73c9803bd1b5d1dfac Mon Sep 17 00:00:00 2001
From: spiros thanasoulas 
Date: Thu, 31 Oct 2019 20:36:04 -0600
Subject: [PATCH] On OpenBSD although the formula is correct due to integer
 division a temperature of for example 54 celsius appears as 5. this patch
 first treats it as a floating point op before retaining the non decimal
 digits

---
 components/temperature.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/temperature.c b/components/temperature.c
index 8462d0f..8e1f222 100644
--- a/components/temperature.c
+++ b/components/temperature.c
@@ -45,7 +45,7 @@
}
 
/* kelvin to celsius */
-   return bprintf("%d", (temp.value - 27315) / 1E6);
+   return bprintf("%d", (int)((float)(temp.value-27315) / 
1E6));
}
 #elif defined(__FreeBSD__)
#include 
-- 
2.23.0



signature.asc
Description: PGP signature