pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bsdfetch: consistently name temperature ints across implementations.
Module Name: pkgsrc-wip
Committed By: Paolo Vincenzo Olivo <vms%retrobsd.ddns.net@localhost>
Pushed By: vms
Date: Mon Dec 5 11:19:17 2022 +0100
Changeset: ac2a13576d3cac93484f4967649dbc3d0c6e83fb
Modified Files:
bsdfetch/distinfo
bsdfetch/patches/patch-bsdfetch.c
Log Message:
bsdfetch: consistently name temperature ints across implementations.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=ac2a13576d3cac93484f4967649dbc3d0c6e83fb
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
bsdfetch/distinfo | 2 +-
bsdfetch/patches/patch-bsdfetch.c | 57 ++++++++++++++++++++++-----------------
2 files changed, 34 insertions(+), 25 deletions(-)
diffs:
diff --git a/bsdfetch/distinfo b/bsdfetch/distinfo
index b344036fab..a636e91277 100644
--- a/bsdfetch/distinfo
+++ b/bsdfetch/distinfo
@@ -4,5 +4,5 @@ BLAKE2s (bsdfetch-0.9-9840c3153fcf49150ebcee94f527f4ebcc0b8c1b.tar.gz) = ee4bd56
SHA512 (bsdfetch-0.9-9840c3153fcf49150ebcee94f527f4ebcc0b8c1b.tar.gz) = b62d956f25eacc2426743c09523e89ade002fadd44445aa5c2628425b10d45d0133354be765af17fac78a936436197a8de5b02efd9c670dcdcf9513f0b744bb3
Size (bsdfetch-0.9-9840c3153fcf49150ebcee94f527f4ebcc0b8c1b.tar.gz) = 6794 bytes
SHA1 (patch-Makefile) = 62812c29b42d05ad9a9b1b9cc263ec309a7a4771
-SHA1 (patch-bsdfetch.c) = 6810e4d7fda7dd9f7028a942a646529cab84e1c9
+SHA1 (patch-bsdfetch.c) = afd935cf6bee4ebf3453f4e9d17e2b2eda19c96f
SHA1 (patch-sysctlbyname.c) = d00d3466cc3be82c7cf01ecfb6b5b12099adcc44
diff --git a/bsdfetch/patches/patch-bsdfetch.c b/bsdfetch/patches/patch-bsdfetch.c
index 335d535cad..f061e76086 100644
--- a/bsdfetch/patches/patch-bsdfetch.c
+++ b/bsdfetch/patches/patch-bsdfetch.c
@@ -59,7 +59,7 @@ Stability and portability fixes.
int color_flag = 1;
static void die(int err_num, int line);
-@@ -95,57 +97,76 @@ static void show(const char *entry, cons
+@@ -95,69 +97,89 @@ static void show(const char *entry, cons
}
static void get_shell() {
@@ -115,23 +115,23 @@ Stability and portability fixes.
- char tmp[100] = {0};
-
- num_cpu_size = sizeof(num_cpu);
--
+
- if(sysctlbyname("hw.ncpu", &num_cpu, &num_cpu_size, NULL, 0) == -1)
-- die(errno, __LINE__);
--
++ ncpu = sysconf(_SC_NPROCESSORS_ONLN);
++ ncpu_max = sysconf(_SC_NPROCESSORS_CONF);
++ if (ncpu_max <= 0 || ncpu <=0)
+ die(errno, __LINE__);
+
-#if defined(__NetBSD__)
- FILE *fc = NULL;
-
+-
- fc = popen("awk 'BEGIN{FS=\":\"} /model name/ { print $2; exit }' "
- "/proc/cpuinfo | sed -e 's/ @//' -e 's/^ *//g' -e 's/ *$//g' "
- "| head -1 | tr -d '\\n'",
- "r");
- if (fc == NULL)
-+ ncpu = sysconf(_SC_NPROCESSORS_ONLN);
-+ ncpu_max = sysconf(_SC_NPROCESSORS_CONF);
-+ if (ncpu_max <= 0 || ncpu <=0)
- die(errno, __LINE__);
-
+- die(errno, __LINE__);
+-
- fgets(cpu_type, sizeof(cpu_type), fc);
- pclose(fc);
-#else
@@ -153,19 +153,28 @@ Stability and portability fixes.
#if defined(__FreeBSD__) || defined(__MidnightBSD__) || defined(__DragonFly__)
for(uint i = 0; i < num_cpu; i++) {
- size_t temperature_size = 0;
+- size_t temperature_size = 0;
- char buf[100] = {0};
- int temperature = 0;
+- int temperature = 0;
++ size_t temp_size = 0;
++ int temp = 0;
- sprintf(buf, "dev.cpu.%d.temperature", i);
--
- temperature_size = sizeof(buf);
-+ snprintf(buf, temperature_size, "dev.cpu.%d.temperature", i);
-+
- if(sysctlbyname(buf, &temperature, &temperature_size, NULL, 0) == -1)
++ temp_size = sizeof(buf);
++ snprintf(buf, temp_size, "dev.cpu.%d.temperature", i);
+
+- temperature_size = sizeof(buf);
+- if(sysctlbyname(buf, &temperature, &temperature_size, NULL, 0) == -1)
++ if(sysctlbyname(buf, &temp, &temp_size, NULL, 0) == -1)
return;
-@@ -158,6 +179,7 @@ static void get_cpu() {
+ _SILENT fprintf(stdout, " %s->%s %sCore [%d]:%s %.1f °C\n",
+ COLOR_GREEN, COLOR_RESET,
+ COLOR_RED, i + 1, COLOR_RESET,
+- (temperature * 0.1) - CELSIUS);
++ (temp * 0.1) - CELSIUS);
+ }
+ #elif defined(__OpenBSD__)
int mib[5];
char temp[10] = {0};
size_t size = 0;
@@ -192,13 +201,13 @@ Stability and portability fixes.
static void get_loadavg() {
- char tmp[20] = {0};
- double *lavg = NULL;
--
-- lavg = malloc(sizeof(double) * 3);
+ double lavg[3] = { 0.0 };
-- (void)getloadavg(lavg, -1);
+- lavg = malloc(sizeof(double) * 3);
+ (void)getloadavg(lavg, 3);
+- (void)getloadavg(lavg, -1);
+-
- _SILENT sprintf(tmp, "%.2lf %.2lf %.2lf", lavg[0], lavg[1], lavg[2]);
+ _SILENT snprintf(tmp, tmp_size, "%.2lf %.2lf %.2lf", lavg[0], lavg[1], lavg[2]);
@@ -367,11 +376,11 @@ Stability and portability fixes.
- die(errno, __LINE__);
-#elif defined(__OpenBSD__) || defined(__DragonFly__)
- if(sysctlbyname("hw.physmem", &buf, &buf_size, NULL, 0) == -1)
-- die(errno, __LINE__);
--#elif defined(__NetBSD__)
-- if(sysctlbyname("hw.physmem64", &buf, &buf_size, NULL, 0) == -1)
+ if (pgsize == -1 || pages == -1)
die(errno, __LINE__);
+-#elif defined(__NetBSD__)
+- if(sysctlbyname("hw.physmem64", &buf, &buf_size, NULL, 0) == -1)
+- die(errno, __LINE__);
-#endif
+ else
+ buff = (uint64_t)pgsize * (uint64_t)pages;
Home |
Main Index |
Thread Index |
Old Index