Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme-fc: avoid gcc-10 zero-length-bounds warning

When CONFIG_ARCH_NO_SG_CHAIN is set, op->sgl[0] cannot be dereferenced,
as gcc-10 now points out:

drivers/nvme/host/fc.c: In function 'nvme_fc_init_request':
drivers/nvme/host/fc.c:1774:29: warning: array subscript 0 is outside the bounds of an interior zero-length array 'struct scatterlist[0]' [-Wzero-length-bounds]
1774 | op->op.fcp_req.first_sgl = &op->sgl[0];
| ^~~~~~~~~~~
drivers/nvme/host/fc.c:98:21: note: while referencing 'sgl'
98 | struct scatterlist sgl[NVME_INLINE_SG_CNT];
| ^~~

I don't know if this is a legitimate warning or a false-positive.
If this is just a false alarm, the warning is easily suppressed
by interpreting the array as a pointer.

Fixes: b1ae1a238900 ("nvme-fc: Avoid preallocating big SGL for data")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Arnd Bergmann and committed by
Jens Axboe
3add1d93 e8cd1ff1

+1 -1
+1 -1
drivers/nvme/host/fc.c
··· 2106 2106 res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++); 2107 2107 if (res) 2108 2108 return res; 2109 - op->op.fcp_req.first_sgl = &op->sgl[0]; 2109 + op->op.fcp_req.first_sgl = op->sgl; 2110 2110 op->op.fcp_req.private = &op->priv[0]; 2111 2111 nvme_req(rq)->ctrl = &ctrl->ctrl; 2112 2112 return res;