From nobody Wed Jun 28 18:13:27 2023 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 4QrqT40N8Vz4kX71; Wed, 28 Jun 2023 18:13:28 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QrqT34QHrz47cM; Wed, 28 Jun 2023 18:13:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687976007; 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=9Y2YZ20d4moBwornTlNEPWAE6BSYrlTAR+o5BEMWC2Y=; b=BijE09dneqX7rYpiJOxrl0BuwQ5YlzhB0WDx6oM2wSWN/u28R4jzGrLP2P5YLYEJEHkQ9b ckj5FPOyTrjUwD4iWst/zCkrSZxmUS9aiz7IrRbjmMCI2+FrF9Hf0LfFO8rpgH5di4wYD4 Je0ASXM6oWCM100raOoKCCdE3xfroBboWSu7oT7A0w23R6b3nKfgMIfODhNNb5weh+SOTK jmUyT/LyUErOg3/unXmYZL96TFz8RuVDjtEkogiQ5OO0yYDwRdv4K9OeAvUxTk1BFX5EZp cFNEf1Z2LFRxGxu2jQ845IWgs3khiA1Xe4gU54dWQKaXUhU3qPRAkucaSTNYKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687976007; 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=9Y2YZ20d4moBwornTlNEPWAE6BSYrlTAR+o5BEMWC2Y=; b=uldoPXoVeiTEGrYXi/L3Gh1Wpjd+/gmwA9+N1F9k9+6JEQNreEHBc4Bhf90MTT1av4x3Kd 7I3z3y5TQoBkU59SEg0/LHvSqAYUkgv2A9LIXBHip449/wVubsxX7XsfhBFLBcav1tn/0I B3p7/7X9gzo7uPXBcwTI6Qoi+U4O8jLkp5lJiZEfrpKUrF3gvpcpjBd4lNC3z44aH/7r7A JY5/sBWq7a47hW3oljATIq6Ht+Ghopfrfot87Nc0rMj+YhQ40yy1vtvxUjspcTXjYJ8688 LCPUvd7YJZofgbg8PVok0ZKY/wMrsunlyDJSFP56dlUSWq7UswtWiJtgAcjMsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687976007; a=rsa-sha256; cv=none; b=NmSN2dct45fifjw6/og3iZHNB44FsWQ4xDfJPtTd07BNZ/UicNJbZuvANnSYGwVHYGlAXC kp0b7Yqgyc1vR8Q8p74LYJb9aKRvfSKTO+bbFON1DSZLac1oAPX4XPIJYrQmXH2pveNlE2 TfIk0erE/6FT7EEhLEGZH5olY5L4yB1SrgnUbuoZ60x3Vvy6YU8ZIqWrfQ3cGH0GidjElB 7+zvUenT9gbNfgG9DYhh2o0AFZX1GxWncthS4f0sNfzA8RCH26SPPKzCJvU0GymTvMPM5+ XMwqBj5+r+JdUeTe7JJQDrsE0AzQjdS967/TbasklAdqMNNctSZbXAeiKSO96Q== 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 4QrqT33WGZzkDx; Wed, 28 Jun 2023 18:13:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35SIDREK008883; Wed, 28 Jun 2023 18:13:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35SIDRmR008882; Wed, 28 Jun 2023 18:13:27 GMT (envelope-from git) Date: Wed, 28 Jun 2023 18:13:27 GMT Message-Id: <202306281813.35SIDRmR008882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a80e5bdff5d8 - main - camdd: Remove some dead code but also make -E functional. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a80e5bdff5d8093da4a93b081781c57b8d0243a3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a80e5bdff5d8093da4a93b081781c57b8d0243a3 commit a80e5bdff5d8093da4a93b081781c57b8d0243a3 Author: John Baldwin AuthorDate: 2023-06-28 18:12:50 +0000 Commit: John Baldwin CommitDate: 2023-06-28 18:12:50 +0000 camdd: Remove some dead code but also make -E functional. - Pass down the top-level arglist from main down to camdd_rw and use it in place of the hardcoded CAMDD_ARG_ERR_RECOVER when calling camdd_probe_pass. This now disables error recovery by default unless -E is specified. - Use the return value of parse_btl to determine if an explicit LUN was specified. - Remove most CAMDD_ARG_* flags that are only set and never checked. CAMDD_ARG_VERBOSE remains, but could perhaps be removed (and possibly -v should be removed as well since it is currently a no-op). Reported by: clang -Wunused-but-set-variable (arglist in main) Differential Revision: https://reviews.freebsd.org/D40666 --- usr.sbin/camdd/camdd.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c index f6c4baff763c..1be2ca0f59a0 100644 --- a/usr.sbin/camdd/camdd.c +++ b/usr.sbin/camdd/camdd.c @@ -95,14 +95,7 @@ typedef enum { typedef enum { CAMDD_ARG_NONE = 0x00000000, CAMDD_ARG_VERBOSE = 0x00000001, - CAMDD_ARG_DEVICE = 0x00000002, - CAMDD_ARG_BUS = 0x00000004, - CAMDD_ARG_TARGET = 0x00000008, - CAMDD_ARG_LUN = 0x00000010, - CAMDD_ARG_UNIT = 0x00000020, - CAMDD_ARG_TIMEOUT = 0x00000040, CAMDD_ARG_ERR_RECOVER = 0x00000080, - CAMDD_ARG_RETRIES = 0x00000100 } camdd_argmask; typedef enum { @@ -444,8 +437,7 @@ static sig_atomic_t need_status = 0; #define CAMDD_PASS_DEFAULT_DEPTH 6 #define CAMDD_PASS_RW_TIMEOUT 60 * 1000 -static int parse_btl(char *tstr, int *bus, int *target, int *lun, - camdd_argmask *arglst); +static int parse_btl(char *tstr, int *bus, int *target, int *lun); void camdd_free_dev(struct camdd_dev *dev); struct camdd_dev *camdd_alloc_dev(camdd_dev_type dev_type, struct kevent *new_ke, int num_ke, @@ -500,8 +492,8 @@ void camdd_sig_handler(int sig); void camdd_print_status(struct camdd_dev *camdd_dev, struct camdd_dev *other_dev, struct timespec *start_time); -int camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, - uint64_t max_io, int retry_count, int timeout); +int camdd_rw(struct camdd_io_opts *io_opts, camdd_argmask arglist, + int num_io_opts, uint64_t max_io, int retry_count, int timeout); int camdd_parse_io_opts(char *args, int is_write, struct camdd_io_opts *io_opts); void usage(void); @@ -516,7 +508,7 @@ void usage(void); * Returns the number of parsed components, or 0. */ static int -parse_btl(char *tstr, int *bus, int *target, int *lun, camdd_argmask *arglst) +parse_btl(char *tstr, int *bus, int *target, int *lun) { char *tmpstr; int convs = 0; @@ -527,17 +519,14 @@ parse_btl(char *tstr, int *bus, int *target, int *lun, camdd_argmask *arglst) tmpstr = (char *)strtok(tstr, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { *bus = strtol(tmpstr, NULL, 0); - *arglst |= CAMDD_ARG_BUS; convs++; tmpstr = (char *)strtok(NULL, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { *target = strtol(tmpstr, NULL, 0); - *arglst |= CAMDD_ARG_TARGET; convs++; tmpstr = (char *)strtok(NULL, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { *lun = strtol(tmpstr, NULL, 0); - *arglst |= CAMDD_ARG_LUN; convs++; } } @@ -3208,8 +3197,8 @@ camdd_print_status(struct camdd_dev *camdd_dev, struct camdd_dev *other_dev, } int -camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io, - int retry_count, int timeout) +camdd_rw(struct camdd_io_opts *io_opts, camdd_argmask arglist, int num_io_opts, + uint64_t max_io, int retry_count, int timeout) { struct cam_device *new_cam_dev = NULL; struct camdd_dev *devs[2]; @@ -3231,13 +3220,12 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io, switch (io_opts[i].dev_type) { case CAMDD_DEV_PASS: { if (isdigit(io_opts[i].dev_name[0])) { - camdd_argmask new_arglist = CAMDD_ARG_NONE; int bus = 0, target = 0, lun = 0; int rv; /* device specified as bus:target[:lun] */ rv = parse_btl(io_opts[i].dev_name, &bus, - &target, &lun, &new_arglist); + &target, &lun); if (rv < 2) { warnx("numeric device specification " "must be either bus:target, or " @@ -3246,9 +3234,8 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io, goto bailout; } /* default to 0 if lun was not specified */ - if ((new_arglist & CAMDD_ARG_LUN) == 0) { + if (rv == 2) { lun = 0; - new_arglist |= CAMDD_ARG_LUN; } new_cam_dev = cam_open_btl(bus, target, lun, O_RDWR, NULL); @@ -3273,7 +3260,7 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io, devs[i] = camdd_probe_pass(new_cam_dev, /*io_opts*/ &io_opts[i], - CAMDD_ARG_ERR_RECOVER, + arglist, /*probe_retry_count*/ 3, /*probe_timeout*/ 5000, /*io_retry_count*/ retry_count, @@ -3578,7 +3565,6 @@ main(int argc, char **argv) if (retry_count < 0) errx(1, "retry count %d is < 0", retry_count); - arglist |= CAMDD_ARG_RETRIES; break; case 'E': arglist |= CAMDD_ARG_ERR_RECOVER; @@ -3611,7 +3597,6 @@ main(int argc, char **argv) errx(1, "invalid timeout %d", timeout); /* Convert the timeout from seconds to ms */ timeout *= 1000; - arglist |= CAMDD_ARG_TIMEOUT; break; case 'v': arglist |= CAMDD_ARG_VERBOSE; @@ -3634,7 +3619,7 @@ main(int argc, char **argv) if (timeout == 0) timeout = CAMDD_PASS_RW_TIMEOUT; - error = camdd_rw(opt_list, 2, max_io, retry_count, timeout); + error = camdd_rw(opt_list, arglist, 2, max_io, retry_count, timeout); bailout: free(opt_list);