From: Hugo Villeneuve Date: Wed, 5 Nov 2025 04:38:46 +0000 (-0500) Subject: tlv_eeprom: suppress -Wstringop-truncation warning for false positive X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=0eb28cc42b699d59b8e0a59596941d904c3a75c4;p=mtlv.git tlv_eeprom: suppress -Wstringop-truncation warning for false positive 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 --- 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: