tlv_eeprom: suppress -Wstringop-truncation warning for false positive
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Wed, 5 Nov 2025 04:38:46 +0000 (23:38 -0500)
committerHugo Villeneuve <hvilleneuve@dimonoff.com>
Mon, 17 Nov 2025 15:36:11 +0000 (10:36 -0500)
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 <hvilleneuve@dimonoff.com>
src/tlv_eeprom.c

index 4b2dfb4..7ceae37 100644 (file)
@@ -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: