From nobody Fri May 29 17:00:25 2026 X-Original-To: dev-commits-src-main@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 4gRqNv1WXSz6fqFS for ; Fri, 29 May 2026 17:00:31 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gRqNt5jTWz3fdM for ; Fri, 29 May 2026 17:00:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780074030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7gq34NYJTm0ObEoCxAEaUl36dUfoI0LnYMcgLkPWUw8=; b=UyheD1jTaPaCGDvHdBIcKxEeo6rFwD+RSOZaN0Id20Hop3U7M6v8QMaIKz0AQQ+kHWMjlW UccRm8KBZXhwSsoSrtmWtgryOzoanNcP/SS6GOr95Mp+6w2jnf2+BS0B9b4PwbMYjgnMgB G7BwHSNAiiPam9Nd4lrSeZPDA+hVJ4vOoayvpz2G0kF9F44CsDGN0Yi0rVQiLqzYDMXvEi XZNZ4xNv9dgssokaKFETvOvsE3LkWTaxyxI6VNVwJP6eiRouCnxpaF4UycwhEO2gBjbx9q XXYcTFIHdiurRXRgJoNwvWWEPrxVlP8FZBmcMclO7+e1l1LbZZMYZkLWgkfZhQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780074030; a=rsa-sha256; cv=none; b=ruX+OyuY7EgUzWxojTWJvvuVOxT6fdcNYf/UDWJuM52sAWZgmYHr3fTljdWcsqkHcsLzuJ keqqg5JROI2hDlEVmwlBDuu/xTYDSQ72uBhTwY+HJOv2/JMAtkOy0pXFz+hQ/g8TVdFzn5 Kn1YUolvgFHl3QV72b+N3zO4RQtfQS2HEN5M/4XrNQfLsRqw0r8dxeXrwfhX7lte6XK4u9 Y/HSTdPhncCk89jbF/ZCpadfzV7+jbOMW12CbmQ5koIqfAXyKGMAj19jtHBCUAXiZgWTTj AGiYXMKGcpfkJv9H1cpzYw+bqfiOsxIGLWfe/0Gq43oEFHWpYmyqnPhGulbqmw== 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=1780074030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7gq34NYJTm0ObEoCxAEaUl36dUfoI0LnYMcgLkPWUw8=; b=nZuNvAw6EpqW/sPLaztHXdtjhNTlgOH3cgW6Rt47Bj2Cn+pa/aRkWQGfYry3rPE31FVQEP OQxRwOL/mKSeeNX8jMS1SjuxnDLCLQkk+jEb0N2rXQlH5yf90IqyzhKC8ow28OJIlzEPFB JbZU6x8chkweykzhFRcCDvc/FiW8BAaC0wWObVhu6f0dOYXKqH1JJex5MyBHsn6Q+xB3B/ +reFR4SzxEr4o8dZYaYRVTJ5jS9m2SveYBV88VQmrs4nkrF1XZWDT3Q1m8NDtHtFT+tQ33 TvsrLk+x8o9shb6ZlVe/GtkEEHeMMqOch3tAXBgfF5f8ax8zinyHCBaeoiIT0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gRqNt4nlTzjBh for ; Fri, 29 May 2026 17:00:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3b0b1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 29 May 2026 17:00:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Sulev-Madis Silber From: Adrian Chadd Subject: git: ee41a882054c - main - spi: switch to switch List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee41a882054c0761853971f8742607b3eae06784 Auto-Submitted: auto-generated Date: Fri, 29 May 2026 17:00:25 +0000 Message-Id: <6a19c629.3b0b1.63ab913@gitrepo.freebsd.org> The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=ee41a882054c0761853971f8742607b3eae06784 commit ee41a882054c0761853971f8742607b3eae06784 Author: Sulev-Madis Silber AuthorDate: 2026-05-29 16:58:50 +0000 Commit: Adrian Chadd CommitDate: 2026-05-29 16:58:50 +0000 spi: switch to switch use recommended switch with default case to catch invalid values Reviewed by: kevans, adrian Differential Revision: https://reviews.freebsd.org/D54759 --- usr.sbin/spi/spi.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/usr.sbin/spi/spi.c b/usr.sbin/spi/spi.c index 1ced2371e3d0..bbbc3d322b00 100644 --- a/usr.sbin/spi/spi.c +++ b/usr.sbin/spi/spi.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -364,30 +365,24 @@ main(int argc, char *argv[], char *envp[] __unused) /* do data transfer */ - if (stream) { - while (!err && !feof(stdin)) { - if (fdir == DIR_READ) { - err = perform_read(hdev, &opt); - } - else if (fdir == DIR_WRITE) { - err = perform_write(hdev, &opt); - } - else if (fdir == DIR_READWRITE) { - err = perform_readwrite(hdev, &opt); - } - } - } - else { - if (fdir == DIR_READ) { + assert(fdir != DIR_NONE); + do { + switch (fdir) { + case DIR_READ: err = perform_read(hdev, &opt); - } - else if (fdir == DIR_WRITE) { + break; + case DIR_WRITE: err = perform_write(hdev, &opt); - } - else if (fdir == DIR_READWRITE) { + break; + case DIR_READWRITE: err = perform_readwrite(hdev, &opt); + break; + default: + fprintf(stderr, "Invalid state (%d)\n", fdir); + err = EINVAL; + break; } - } + } while (stream && !err && !feof(stdin)); the_end: