git: 352cf4a64adf - main - ctl: Avoid an upcast for calling ctl_scsi_path_string
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 May 2024 00:15:51 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=352cf4a64adf117a8a0cf23a20b8de4990b2ba22 commit 352cf4a64adf117a8a0cf23a20b8de4990b2ba22 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-05-02 23:30:20 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-05-02 23:30:20 +0000 ctl: Avoid an upcast for calling ctl_scsi_path_string Change the first argument of ctl_scsi_path_string to be the embedded header structure instead of the union. Currently union ctl_io and struct ctl_scsiio have the same alignment, but this changes on i386 if a new union member is added that contains a uint64_t member (such as an embedded struct nvme_command for NVMeoF). In that case, union ctl_io requires stronger alignment, so the upcast from struct ctl_scsiio to union ctl_io in ctl_scsi_sense_sbuf raises an increasing alignment warning on i386. Avoid the warning by passing struct ctl_io_hdr as the first argument to ctl_scsi_path_string instead. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44716 --- sys/cam/ctl/ctl.c | 2 +- sys/cam/ctl/ctl_scsi_all.c | 8 ++++---- sys/cam/ctl/ctl_scsi_all.h | 2 +- sys/cam/ctl/ctl_util.c | 6 +++--- usr.sbin/ctladm/ctladm.c | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 5230a2694544..6951ed6b229a 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -12837,7 +12837,7 @@ ctl_process_done(union ctl_io *io) char path_str[64]; struct sbuf sb; - ctl_scsi_path_string(io, path_str, sizeof(path_str)); + ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str)); sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); ctl_io_sbuf(io, &sb); diff --git a/sys/cam/ctl/ctl_scsi_all.c b/sys/cam/ctl/ctl_scsi_all.c index 5c55907cb27c..84fa5656fb5f 100644 --- a/sys/cam/ctl/ctl_scsi_all.c +++ b/sys/cam/ctl/ctl_scsi_all.c @@ -109,12 +109,12 @@ ctl_scsi_command_string(struct ctl_scsiio *ctsio, } void -ctl_scsi_path_string(union ctl_io *io, char *path_str, int len) +ctl_scsi_path_string(struct ctl_io_hdr *hdr, char *path_str, int len) { snprintf(path_str, len, "(%u:%u:%u/%u): ", - io->io_hdr.nexus.initid, io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.targ_lun, io->io_hdr.nexus.targ_mapped_lun); + hdr->nexus.initid, hdr->nexus.targ_port, + hdr->nexus.targ_lun, hdr->nexus.targ_mapped_lun); } /* @@ -130,7 +130,7 @@ ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio, if ((ctsio == NULL) || (sb == NULL)) return(-1); - ctl_scsi_path_string((union ctl_io *)ctsio, path_str, sizeof(path_str)); + ctl_scsi_path_string(&ctsio->io_hdr, path_str, sizeof(path_str)); if (flags & SSS_FLAG_PRINT_COMMAND) { sbuf_cat(sb, path_str); diff --git a/sys/cam/ctl/ctl_scsi_all.h b/sys/cam/ctl/ctl_scsi_all.h index 5e99acddf01c..ebf69c967978 100644 --- a/sys/cam/ctl/ctl_scsi_all.h +++ b/sys/cam/ctl/ctl_scsi_all.h @@ -43,7 +43,7 @@ int ctl_scsi_command_string(struct ctl_scsiio *ctsio, int ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio, struct scsi_inquiry_data *inq_data, struct sbuf *sb, scsi_sense_string_flags flags); -void ctl_scsi_path_string(union ctl_io *io, char *path_str, int strlen); +void ctl_scsi_path_string(struct ctl_io_hdr *hdr, char *path_str, int strlen); char *ctl_scsi_sense_string(struct ctl_scsiio *ctsio, struct scsi_inquiry_data *inq_data, char *str, int str_len); diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c index 76f4aff6bb3d..d039e3f6fe6e 100644 --- a/sys/cam/ctl/ctl_util.c +++ b/sys/cam/ctl/ctl_util.c @@ -731,7 +731,7 @@ ctl_io_sbuf(union ctl_io *io, struct sbuf *sb) const char *task_desc; char path_str[64]; - ctl_scsi_path_string(io, path_str, sizeof(path_str)); + ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str)); switch (io->io_hdr.io_type) { case CTL_IO_SCSI: @@ -784,7 +784,7 @@ ctl_io_error_sbuf(union ctl_io *io, struct scsi_inquiry_data *inq_data, } } - ctl_scsi_path_string(io, path_str, sizeof(path_str)); + ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str)); sbuf_cat(sb, path_str); if (status_desc == NULL) @@ -861,7 +861,7 @@ ctl_data_print(union ctl_io *io) return; if (io->scsiio.kern_sg_entries > 0) /* XXX: Implement */ return; - ctl_scsi_path_string(io, path_str, sizeof(path_str)); + ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str)); len = min(io->scsiio.kern_data_len, 4096); for (i = 0; i < len; ) { sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index 15cbf2d6cd77..d09187735a5a 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -1245,7 +1245,7 @@ cctl_start_stop(int fd, int lun, int iid, int retries, int start, goto bailout; } - ctl_scsi_path_string(io, scsi_path, sizeof(scsi_path)); + ctl_scsi_path_string(&io->io_hdr, scsi_path, sizeof(scsi_path)); if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) { fprintf(stdout, "%s LUN %s successfully\n", scsi_path, (start) ? "started" : "stopped"); @@ -1966,7 +1966,7 @@ cctl_get_inquiry(int fd, int lun, int iid, int retries, retval = 1; ctl_io_error_print(io, NULL, stderr); } else if (path_str != NULL) - ctl_scsi_path_string(io, path_str, path_len); + ctl_scsi_path_string(&io->io_hdr, path_str, path_len); bailout: ctl_scsi_free_io(io); @@ -2364,7 +2364,7 @@ cctl_persistent_reserve_out(int fd, int lun, int iid, } if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) { char scsi_path[40]; - ctl_scsi_path_string(io, scsi_path, sizeof(scsi_path)); + ctl_scsi_path_string(&io->io_hdr, scsi_path, sizeof(scsi_path)); fprintf( stdout, "%sPERSISTENT RESERVE OUT executed " "successfully\n", scsi_path); } else