Commit cbeecee6 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

nvme: use array index to get pointer for MAKE_DIGEST_WORD



This fixes incorrect warning from gcc when using --enable-asan w/o
--enable-debug. Even though code explicitly references the "raw" byte
array, the compiler thinks we are referencing pdu_type in the common_hdr
which is only one byte.

In file included from nvme_tcp.c:23:
nvme_tcp.c: In function ‘nvme_tcp_qpair_write_pdu’:
/test/spdk_internal/nvme_tcp.h:37:38: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
37 |             ((*((uint8_t *)(BUF)+1)) = (uint8_t)((uint32_t)(CRC32C) >> 8)), \

Fixes issue #3260.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I089311d71515ce41a714a97e13232da18699c9ec
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21813


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
parent f8fe0c41
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -712,7 +712,7 @@ nvme_tcp_qpair_write_pdu(struct nvme_tcp_qpair *tqpair,
	/* Header Digest */
	if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && tqpair->flags.host_hdgst_enable) {
		crc32c = nvme_tcp_pdu_calc_header_digest(pdu);
		MAKE_DIGEST_WORD((uint8_t *)pdu->hdr.raw + hlen, crc32c);
		MAKE_DIGEST_WORD((uint8_t *)&pdu->hdr.raw[hlen], crc32c);
	}

	pdu_compute_crc32(pdu);