From 0eb28cc42b699d59b8e0a59596941d904c3a75c4 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Tue, 4 Nov 2025 23:38:46 -0500 Subject: [PATCH] tlv_eeprom: suppress -Wstringop-truncation warning for false positive MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Suppress this warning: tlv_eeprom.c:490:17: warning: ‘__builtin_strncpy’ specified bound 256 equals destination size [-Wstringop-truncation] 490 | strncpy(data, strval, MAX_TLV_VALUE_LEN); | ^ Data is a fixed-length buffer, and no terminating null character is required, thus this warning is a false positive. Signed-off-by: Hugo Villeneuve --- src/tlv_eeprom.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tlv_eeprom.c b/src/tlv_eeprom.c index 4b2dfb4..7ceae37 100644 --- a/src/tlv_eeprom.c +++ b/src/tlv_eeprom.c @@ -483,7 +483,10 @@ bool tlvinfo_add_tlv(u8 *eeprom, int tcode, char *strval) case TLV_CODE_VENDOR_NAME: case TLV_CODE_DIAG_VERSION: case TLV_CODE_SERVICE_TAG: +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy(data, strval, MAX_TLV_VALUE_LEN); +#pragma GCC diagnostic pop new_tlv_len = min_t(size_t, MAX_TLV_VALUE_LEN, strlen(strval)); break; case TLV_CODE_DEVICE_VERSION: -- 2.20.1