From nobody Mon Jul 08 20:26:45 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WHwdK3VnYz5QYQL; Mon, 08 Jul 2024 20:26:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHwdK2s7xz4gkw; Mon, 8 Jul 2024 20:26:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720470405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KY+us2JIz2AgdxAHg9N6WNJHUzkmpt/7S5iWQ3nEhwQ=; b=oyDyVJQvLjNXhEJI6v0q1Z+RyVQOeadD2ewe7dljlTQxix4PGMtRqeYDujxkpSRmzzttd5 UcopZSk2cCY+DgpD5xjQ52K5pCT2LYxTQzEt7Wlcsnb4snOyVe0nC0s3klCJjsZLOIcKjY B57UegVCLzDMB/BtWxYxGXuFCZlAiTYEhOh/WcuAfhGYbYu6MZ0UWuVDNmRFBxD0pV7fQH 2c1br2+rBM2Uc/bVCg+nCMCn4noqhE8lbwyeqvRnIVJblXFE5RF0iVhy4eR3IqUgpW7Z+6 2HUlW2RD0lt05Fa+QYc3i5C3EHGLoJlhCL6oMEtzoaVw1wjFNsctrZ4BNPBZ+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720470405; a=rsa-sha256; cv=none; b=jYSVlO1axN4Xw1xGt9kyjDa0FhGFzvgUk/PaMhh5ZZ/lVhMn19pHMg+jeQXPpQr+wx0QL6 kHy8tzLWrGl0lbdJnxWb+6PO6oWZmcX35jGpyX2q2tdVcJ4lk5J90xHttYPPze7h4N2bnm EpzUpKt26VgzO8Kx69UUFgcDMZJJ7aLF9LxZrl5QFgTIg03SbfTqFqJpR+O1UiSaeGMBnD I0wAbqpW1uMt8PS7vj9U/UxCVgfUY7cGI7T1igcJ3cy5KWIEZbs6fpne3NbsCLhBDDR9eD 8F3cvYK+wHiO/cX8lqwABL2cki+AyF//g1/Rxb55YaIOVwADQZ5MYUwpn1yJtw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720470405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KY+us2JIz2AgdxAHg9N6WNJHUzkmpt/7S5iWQ3nEhwQ=; b=wILvrYZHktMDKYE/TA+a7VIY02/+HSJ7sb1ZRNjEkn4ElYCWATs4PwxVLKcXlbcW6vWy9y r3t5ubVRA0XkGnXhPv+mQ2NeyjJZVWmM5uI/bUsycG3T01I7DWEN7T92KoM7Q/uLxnAOoz MGaM96k4LQaS3WSvLxNNQ/GSQwspxGMeJ4yrkiiuomC160BulE4PssnevK6OM1xpYi2mL5 kkVaJOPlZlawExrNAhWH5PQFWBzVVdx98Esmlq2hUNFyAFHJt573881ckotRtPSm5jP4rn UV63R2O+dwpL2rbYZLAuaygnTn0ZjxDUbBxhkHT2ndW9hYfxCADWT6C+P+fTOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WHwdK2LmHz15PN; Mon, 8 Jul 2024 20:26:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 468KQjNf012087; Mon, 8 Jul 2024 20:26:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 468KQjqc012083; Mon, 8 Jul 2024 20:26:45 GMT (envelope-from git) Date: Mon, 8 Jul 2024 20:26:45 GMT Message-Id: <202407082026.468KQjqc012083@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: c1a5da044c6e - stable/13 - targ: fix compiling the example List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c1a5da044c6e692250bc5eddcb99c6e9f1ab4b78 Auto-Submitted: auto-generated The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=c1a5da044c6e692250bc5eddcb99c6e9f1ab4b78 commit c1a5da044c6e692250bc5eddcb99c6e9f1ab4b78 Author: Alan Somers AuthorDate: 2024-06-19 00:17:31 +0000 Commit: Alan Somers CommitDate: 2024-07-08 20:26:04 +0000 targ: fix compiling the example The targ example program doesn't compile with current clang, and probably hasn't for multiple releases. Fix the build. I don't have the right hardware to test it, though. Sponsored by: Axcient (cherry picked from commit 873881b7dbb72077f3723f49a9f10a432231c532) --- share/examples/scsi_target/Makefile | 6 +++++- share/examples/scsi_target/scsi_cmds.c | 6 +----- share/examples/scsi_target/scsi_target.c | 32 ++++++++++++++++++-------------- share/examples/scsi_target/scsi_target.h | 6 +++++- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/share/examples/scsi_target/Makefile b/share/examples/scsi_target/Makefile index 39950b8c0ac1..1e2c076591bf 100644 --- a/share/examples/scsi_target/Makefile +++ b/share/examples/scsi_target/Makefile @@ -4,7 +4,11 @@ FILESDIR=${SHAREDIR}/examples/${PROG} PROG= scsi_target SRCS= scsi_target.h scsi_target.c scsi_cmds.c DPADD= ${LIBCAM} ${LIBSBUF} -LDADD= -lcam -lsbuf +LIBADD+= cam +LIBADD+= sbuf +# cast-qual is triggered only in a code path where the volatile keyword doesn't +# matter +CFLAGS.scsi_cmds.c= -Wno-cast-qual MAN= scsi_target.8 diff --git a/share/examples/scsi_target/scsi_cmds.c b/share/examples/scsi_target/scsi_cmds.c index 43217a562aba..122d4dec6287 100644 --- a/share/examples/scsi_target/scsi_cmds.c +++ b/share/examples/scsi_target/scsi_cmds.c @@ -102,10 +102,6 @@ static struct targ_cdb_handlers cdb_handlers[] = { static struct scsi_inquiry_data inq_data; static struct initiator_state istates[MAX_INITIATORS]; -extern int debug; -extern off_t volume_size; -extern u_int sector_size; -extern size_t buf_size; cam_status tcmd_init(u_int16_t req_inq_flags, u_int16_t sim_inq_flags) @@ -553,7 +549,7 @@ tcmd_rdwr_decode(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio) tcmd_illegal_req(atio, ctio); return (0); } - if (blkno + count > volume_size) { + if (((off_t)(blkno + count)) > volume_size) { warnx("Attempt to access past end of volume"); tcmd_sense(ctio->init_id, ctio, SSD_KEY_ILLEGAL_REQUEST, 0x21, 0); diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index b8f3ed6a8a81..ee0a94e7a2a0 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -77,7 +77,9 @@ static struct ccb_queue work_queue; static struct ioc_enable_lun ioc_enlun = { CAM_BUS_WILDCARD, CAM_TARGET_WILDCARD, - CAM_LUN_WILDCARD + CAM_LUN_WILDCARD, + 0, + 0 }; /* Local functions */ @@ -208,7 +210,7 @@ main(int argc, char *argv[]) if (argc != 2) usage(); - sscanf(argv[0], "%u:%u:%u", &ioc_enlun.path_id, &ioc_enlun.target_id, + sscanf(argv[0], "%u:%u:%ju", &ioc_enlun.path_id, &ioc_enlun.target_id, &ioc_enlun.lun_id); file_name = argv[1]; @@ -258,10 +260,12 @@ main(int argc, char *argv[]) if (notaio == 0) { struct aiocb aio, *aiop; + void *aio_buf; /* See if we have we have working AIO support */ memset(&aio, 0, sizeof(aio)); - aio.aio_buf = malloc(sector_size); + aio_buf = malloc(sector_size); + aio.aio_buf = aio_buf; if (aio.aio_buf == NULL) err(1, "malloc"); aio.aio_fildes = file_fd; @@ -278,7 +282,7 @@ main(int argc, char *argv[]) assert(aiop == &aio); signal(SIGSYS, SIG_DFL); } - free((void *)aio.aio_buf); + free(aio_buf); if (debug && notaio == 0) warnx("aio support tested ok"); } @@ -331,7 +335,7 @@ main(int argc, char *argv[]) } static void -cleanup() +cleanup(void) { struct ccb_hdr *ccb_h; @@ -358,7 +362,7 @@ cleanup() /* Allocate ATIOs/INOTs and queue on HBA */ static int -init_ccbs() +init_ccbs(void) { int i; @@ -395,7 +399,7 @@ init_ccbs() } static void -request_loop() +request_loop(void) { struct kevent events[MAX_EVENTS]; struct timespec ts, *tptr; @@ -535,10 +539,10 @@ request_loop() /* CCBs are ready from the kernel */ static void -handle_read() +handle_read(void) { union ccb *ccb_array[MAX_INITIATORS], *ccb; - int ccb_count, i, oo; + int ccb_count, i; ccb_count = read(targ_fd, ccb_array, sizeof(ccb_array)); if (ccb_count <= 0) { @@ -590,7 +594,7 @@ handle_read() /* Queue on the appropriate ATIO */ queue_io(ctio); /* Process any queued completions. */ - oo += run_queue(c_descr->atio); + run_queue(c_descr->atio); break; } case XPT_IMMEDIATE_NOTIFY: @@ -840,7 +844,7 @@ send_ccb(union ccb *ccb, int priority) /* Return a CTIO/descr/buf combo from the freelist or malloc one */ static struct ccb_scsiio * -get_ctio() +get_ctio(void) { struct ccb_scsiio *ctio; struct ctio_descr *c_descr; @@ -938,7 +942,7 @@ get_sim_flags(u_int16_t *flags) } static void -rel_simq() +rel_simq(void) { struct ccb_relsim crs; @@ -953,7 +957,7 @@ rel_simq() /* Cancel all pending CCBs. */ static void -abort_all_pending() +abort_all_pending(void) { struct ccb_abort cab; struct ccb_hdr *ccb_h; @@ -976,7 +980,7 @@ abort_all_pending() } static void -usage() +usage(void) { fprintf(stderr, "Usage: scsi_target [-AdSTY] [-b bufsize] [-c sectorsize]\n" diff --git a/share/examples/scsi_target/scsi_target.h b/share/examples/scsi_target/scsi_target.h index a873c050b7c6..57b6696d2e77 100644 --- a/share/examples/scsi_target/scsi_target.h +++ b/share/examples/scsi_target/scsi_target.h @@ -115,7 +115,11 @@ extern void free_ccb(union ccb *ccb); static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); } /* Global Data */ -extern int notaio; +extern int notaio; +extern int debug; +extern off_t volume_size; +extern u_int sector_size; +extern size_t buf_size; /* * Compat Defines