git: a7db82cfd940 - main - nvmf_tcp: Correct tests for PDU direction

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 06 May 2024 21:04:02 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=a7db82cfd940431037e748280825931a46ed2d12

commit a7db82cfd940431037e748280825931a46ed2d12
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-05-06 20:33:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-05-06 21:03:48 +0000

    nvmf_tcp: Correct tests for PDU direction
    
    Add parentheses to ensure the correct order of operations.
    
    Reported by:    GCC
---
 lib/libnvmf/nvmf_tcp.c  | 2 +-
 sys/dev/nvmf/nvmf_tcp.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libnvmf/nvmf_tcp.c b/lib/libnvmf/nvmf_tcp.c
index 12da329f34b4..b9bf8153ab1b 100644
--- a/lib/libnvmf/nvmf_tcp.c
+++ b/lib/libnvmf/nvmf_tcp.c
@@ -803,7 +803,7 @@ nvmf_tcp_validate_ic_pdu(struct nvmf_association *na, struct nvmf_tcp_qpair *qp,
 	/* Validate pdu_type. */
 
 	/* Controllers only receive PDUs with a PDU direction of 0. */
-	if (na->na_controller != (ch->pdu_type & 0x01) == 0) {
+	if (na->na_controller != ((ch->pdu_type & 0x01) == 0)) {
 		na_error(na, "NVMe/TCP: Invalid PDU type %u", ch->pdu_type);
 		nvmf_tcp_report_error(na, qp,
 		    NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 0, ch, pdu_len,
diff --git a/sys/dev/nvmf/nvmf_tcp.h b/sys/dev/nvmf/nvmf_tcp.h
index 00b0917f75a4..78d6cf17a977 100644
--- a/sys/dev/nvmf/nvmf_tcp.h
+++ b/sys/dev/nvmf/nvmf_tcp.h
@@ -50,7 +50,7 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch,
 	/* Validate pdu_type. */
 
 	/* Controllers only receive PDUs with a PDU direction of 0. */
-	if (controller != (ch->pdu_type & 0x01) == 0) {
+	if (controller != ((ch->pdu_type & 0x01) == 0)) {
 		printf("NVMe/TCP: Invalid PDU type %u\n", ch->pdu_type);
 		*fes = NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
 		*fei = offsetof(struct nvme_tcp_common_pdu_hdr, pdu_type);