aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbigbear <ns@bigbear.dk>2024-02-08 02:46:56 +0100
committerbigbear <ns@bigbear.dk>2024-02-08 19:52:53 +0100
commit2c5076cc7ad141d8246626ab1a82e65f1c126d59 (patch)
treea60afef0597c74964a2399c4c71a9caa5207ef34
parenteefbdc82d4f8c67f3e89782e6253da262edcf9c5 (diff)
FIX CodeQL warnings
-rw-r--r--deps/uber-graph/g-ring.c2
-rw-r--r--deps/uber-graph/uber-timeout-interval.c4
-rw-r--r--hardinfo2/dmi_util.c4
-rw-r--r--modules/devices/spd-decode.c16
4 files changed, 13 insertions, 13 deletions
diff --git a/deps/uber-graph/g-ring.c b/deps/uber-graph/g-ring.c
index dc35635d..d865cc15 100644
--- a/deps/uber-graph/g-ring.c
+++ b/deps/uber-graph/g-ring.c
@@ -21,7 +21,7 @@
#include "g-ring.h"
#ifndef g_malloc0_n
-#define g_malloc0_n(x,y) g_malloc0(x * y)
+#define g_malloc0_n(x,y) g_malloc0((gsize)x * y)
#endif
#define get_element(r,i) ((r)->data + ((r)->elt_size * i))
diff --git a/deps/uber-graph/uber-timeout-interval.c b/deps/uber-graph/uber-timeout-interval.c
index 79b55947..4a4cf52a 100644
--- a/deps/uber-graph/uber-timeout-interval.c
+++ b/deps/uber-graph/uber-timeout-interval.c
@@ -131,8 +131,8 @@ _uber_timeout_interval_compare_expiration (const UberTimeoutInterval *a,
b_difference = a->start_time - b->start_time;
- comparison = ((gint) ((a->frame_count + 1) * a_delay)
- - (gint) ((b->frame_count + 1) * b_delay + b_difference));
+ comparison = ((gint) (((gint64)a->frame_count + 1) * a_delay)
+ - (gint) (((gint64)b->frame_count + 1) * b_delay + b_difference));
return (comparison < 0 ? -1
: comparison > 0 ? 1
diff --git a/hardinfo2/dmi_util.c b/hardinfo2/dmi_util.c
index 5482c151..35f9282f 100644
--- a/hardinfo2/dmi_util.c
+++ b/hardinfo2/dmi_util.c
@@ -71,10 +71,10 @@ static const char *dmi_type_strings[] = {
* returns -1 if error, 0 if ok, 1 if ignored */
static int ignore_placeholder_strings(gchar **pstr) {
gchar *chk, *p;
- chk = g_strdup(*pstr);
-
if (pstr == NULL || *pstr == NULL)
return -1;
+ chk = g_strdup(*pstr);
+
#define DMI_IGNORE(m) if (strcasecmp(m, *pstr) == 0) { g_free(chk); g_free(*pstr); *pstr = NULL; return 1; }
DMI_IGNORE("To be filled by O.E.M.");
DMI_IGNORE("Default String");
diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c
index 98095bd8..511504b2 100644
--- a/modules/devices/spd-decode.c
+++ b/modules/devices/spd-decode.c
@@ -123,13 +123,13 @@ static int parity(int value) {
}
static void decode_sdr_module_size(unsigned char *bytes, dmi_mem_size *size) {
- int i, k = 0;
+ unsigned short i, k = 0;
i = (bytes[3] & 0x0f) + (bytes[4] & 0x0f) - 17;
if (bytes[5] <= 8 && bytes[17] <= 8) { k = bytes[5] * bytes[17]; }
if (i > 0 && i <= 12 && k > 0) {
- if (size) { *size = (1 << i) * k; }
+ if (size) { *size = (dmi_mem_size)k * (unsigned short)(1 << i); }
} else {
if (size) { *size = -1; }
}
@@ -333,13 +333,13 @@ static void decode_ddr_module_speed(unsigned char *bytes, float *ddrclk, int *pc
}
static void decode_ddr_module_size(unsigned char *bytes, dmi_mem_size *size) {
- int i, k;
+ unsigned short i, k;
i = (bytes[3] & 0x0f) + (bytes[4] & 0x0f) - 17;
k = (bytes[5] <= 8 && bytes[17] <= 8) ? bytes[5] * bytes[17] : 0;
if (i > 0 && i <= 12 && k > 0) {
- if (size) { *size = (1 << i) * k; }
+ if (size) { *size = (dmi_mem_size)k * (unsigned short)(1 << i); }
} else {
if (size) { *size = -1; }
}
@@ -436,13 +436,13 @@ static void decode_ddr2_module_speed(unsigned char *bytes, float *ddr_clock, int
}
static void decode_ddr2_module_size(unsigned char *bytes, dmi_mem_size *size) {
- int i, k;
+ unsigned short i, k;
i = (bytes[3] & 0x0f) + (bytes[4] & 0x0f) - 17;
k = ((bytes[5] & 0x7) + 1) * bytes[17];
if (i > 0 && i <= 12 && k > 0) {
- if (size) { *size = ((1 << i) * k); }
+ if (size) { *size = (dmi_mem_size)k * (unsigned short)(1 << i); }
} else {
if (size) { *size = 0; }
}
@@ -595,7 +595,7 @@ static void decode_ddr3_module_size(unsigned char *bytes, dmi_mem_size *size) {
unsigned int bus_width = 8 << (bytes[8] & 0x7);
unsigned int ranks = 1 + ((bytes[7] >> 3) & 0x7);
- *size = sdr_capacity / 8 * bus_width / sdr_width * ranks;
+ *size = (dmi_mem_size)sdr_capacity / 8 * bus_width / sdr_width * ranks;
}
static void decode_ddr3_module_timings(unsigned char *bytes, float *trcd, float *trp, float *tras,
@@ -855,7 +855,7 @@ static void decode_ddr4_module_size(unsigned char *bytes, dmi_mem_size *size) {
if (signal_loading == 2) lranks_per_dimm *= ((bytes[6] >> 4) & 7) + 1;
- *size = sdrcap / 8 * buswidth / sdrwidth * lranks_per_dimm;
+ *size = (dmi_mem_size)sdrcap / 8 * buswidth / sdrwidth * lranks_per_dimm;
}