git: f64d611af8ee - stable/14 - camcontrol: Fix -Wcast-align errors in the NVMe reservation report
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 21:01:17 UTC
The branch stable/14 has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=f64d611af8eee373dad980e28582f39ed698fdfd
commit f64d611af8eee373dad980e28582f39ed698fdfd
Author: Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-07 03:33:21 +0000
Commit: Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-16 21:00:07 +0000
camcontrol: Fix -Wcast-align errors in the NVMe reservation report
Casting the byte buffer that holds the Reservation Report payload to
the status structures trips -Wcast-align on strict-alignment
architectures, which broke the CI builds there. Put the buffer in a
union with the two status structures instead, so it is properly
aligned and no casts are needed.
Reported by: FreeBSD CI
Fixes: ba75cf05727e ("camcontrol: Support NVMe reservations via the persist subcommand")
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
MFC after: 1 week
Sponsored by: Spectra Logic
(cherry picked from commit 68ba58a064d1004a031fac6f299f968dfc39241f)
---
sbin/camcontrol/nvres.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/sbin/camcontrol/nvres.c b/sbin/camcontrol/nvres.c
index ab9ac5b30607..1145278356c3 100644
--- a/sbin/camcontrol/nvres.c
+++ b/sbin/camcontrol/nvres.c
@@ -308,7 +308,11 @@ static int
nvmeres_report(struct cam_device *device, int verbosemode, int err_recover,
int eds, int retry_count, int timeout)
{
- uint8_t report_data[8192];
+ union {
+ struct nvme_resv_status status;
+ struct nvme_resv_status_ext ext;
+ uint8_t bytes[8192];
+ } report_data;
union ccb *ccb = NULL;
struct nvme_resv_status *rstatus;
struct nvme_resv_status_ext *extstatus;
@@ -326,14 +330,14 @@ nvmeres_report(struct cam_device *device, int verbosemode, int err_recover,
}
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->nvmeio);
- bzero(report_data, sizeof(report_data));
+ bzero(&report_data, sizeof(report_data));
nvme_resv_report(/*nvmeio*/ &ccb->nvmeio,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/*nsid*/ device->target_lun,
/*report_type*/ eds,
- /*data_ptr*/ report_data,
+ /*data_ptr*/ report_data.bytes,
/*dxfer_len */ sizeof(report_data),
/*timeout*/ timeout ? timeout : 30000);
@@ -362,15 +366,15 @@ nvmeres_report(struct cam_device *device, int verbosemode, int err_recover,
error = 1;
goto bailout;
}
- rstatus = (struct nvme_resv_status *)report_data;
+ rstatus = &report_data.status;
/*
* XXX KDM evidently there is no concept of a residual in NVMe.
*/
if (eds == 0)
nvme_resv_status_swapbytes(rstatus,sizeof(report_data));
else
- nvme_resv_status_ext_swapbytes((struct nvme_resv_status_ext *)
- report_data,sizeof(report_data));
+ nvme_resv_status_ext_swapbytes(&report_data.ext,
+ sizeof(report_data));
num_ents = (rstatus->regctl[1] << 8) | rstatus->regctl[0];
printf("Generation: %u\n", rstatus->gen);
@@ -391,7 +395,7 @@ nvmeres_report(struct cam_device *device, int verbosemode, int err_recover,
* device reports more.
*/
if (eds == 1) {
- extstatus = (struct nvme_resv_status_ext *)report_data;
+ extstatus = &report_data.ext;
if (num_ents > (int)((sizeof(report_data) -
sizeof(*extstatus)) / sizeof(extstatus->ctrlr[0])))
num_ents = (sizeof(report_data) -