From 5d17e8be184367c18545e1a9d67589d1e80e404d Mon Sep 17 00:00:00 2001 From: Sam James Date: Sat, 4 May 2024 09:13:06 +0100 Subject: [PATCH 1/2] nvme: Use C99 types for uint32_t provides `uint32_t`, while `u_int_32` is an unofficial/internal typedef that glibc happens to provide. This fixes the build on musl. Bug: https://bugs.gentoo.org/931194 Signed-off-by: Sam James --- nvme.c | 13 +++++++------ util/base64.c | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/nvme.c b/nvme.c index 4a65c4b7c7..2234c3da26 100644 --- a/nvme.c +++ b/nvme.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -9075,8 +9076,8 @@ static int check_dhchap_key(int argc, char **argv, struct command *command, stru unsigned char decoded_key[128]; unsigned int decoded_len; - u_int32_t crc = crc32(0L, NULL, 0); - u_int32_t key_crc; + uint32_t crc = crc32(0L, NULL, 0); + uint32_t key_crc; int err = 0, hmac; struct config { char *key; @@ -9144,10 +9145,10 @@ static int check_dhchap_key(int argc, char **argv, struct command *command, stru return -EINVAL; } crc = crc32(crc, decoded_key, decoded_len); - key_crc = ((u_int32_t)decoded_key[decoded_len]) | - ((u_int32_t)decoded_key[decoded_len + 1] << 8) | - ((u_int32_t)decoded_key[decoded_len + 2] << 16) | - ((u_int32_t)decoded_key[decoded_len + 3] << 24); + key_crc = ((uint32_t)decoded_key[decoded_len]) | + ((uint32_t)decoded_key[decoded_len + 1] << 8) | + ((uint32_t)decoded_key[decoded_len + 2] << 16) | + ((uint32_t)decoded_key[decoded_len + 3] << 24); if (key_crc != crc) { nvme_show_error("CRC mismatch (key %08x, crc %08x)", key_crc, crc); return -EINVAL; diff --git a/util/base64.c b/util/base64.c index 7f47cda6c3..0e89f2e9df 100644 --- a/util/base64.c +++ b/util/base64.c @@ -20,6 +20,7 @@ * MA 02110-1301, USA. */ +#include #include #include #include @@ -42,7 +43,7 @@ static const char base64_table[65] = int base64_encode(const unsigned char *src, int srclen, char *dst) { int i, bits = 0; - u_int32_t ac = 0; + uint32_t ac = 0; char *cp = dst; for (i = 0; i < srclen; i++) { @@ -77,7 +78,7 @@ int base64_encode(const unsigned char *src, int srclen, char *dst) */ int base64_decode(const char *src, int srclen, unsigned char *dst) { - u_int32_t ac = 0; + uint32_t ac = 0; int i, bits = 0; unsigned char *bp = dst; From 2080a27ec888f9f6ce4d517ace1f437035184a9c Mon Sep 17 00:00:00 2001 From: Sam James Date: Sat, 4 May 2024 09:15:03 +0100 Subject: [PATCH 2/2] plugins/innogrit: `u_char` -> `unsigned char` `u_char` is not a standard name for `unsigned char` and may not work; some implementations may provide it for convenience. Signed-off-by: Sam James --- plugins/innogrit/typedef.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/innogrit/typedef.h b/plugins/innogrit/typedef.h index f2a59b4f3a..7220d38d84 100644 --- a/plugins/innogrit/typedef.h +++ b/plugins/innogrit/typedef.h @@ -53,14 +53,14 @@ struct vsc_smart_log { unsigned int low_pwr_cnt; unsigned int wa; unsigned int ps3_entry_cnt; - u_char highest_temp[4]; + unsigned char highest_temp[4]; unsigned int weight_ec; unsigned int slc_cap_mb; unsigned long long nand_page_write_cnt; unsigned int program_error_cnt; unsigned int erase_error_cnt; - u_char flash_type; - u_char reserved2[3]; + unsigned char flash_type; + unsigned char reserved2[3]; unsigned int hs_crc_err_cnt; unsigned int ddr_ecc_err_cnt; unsigned int reserved3[44];