From nobody Thu Oct 08 20:43:45 2026 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 4j125Z1Lz4z6wCmj for ; Thu, 08 Oct 2026 20:43:46 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4j125Y5fWVz4bVY for ; Thu, 08 Oct 2026 20:43:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791492225; 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=O4azKjxesuK4FxbC4gudE9HsY9bHWgF+sLAbYBl4SnQ=; b=bASLrIY9Z0CsjjrRLi7d8Yfw5pOF9nNwTxh305qxnjxL0hib4CuT5tDO3DA2BWJj0ynwcD oiHZlc3lEsFsiOtwgHbnW0H66803/9/CdgoDLLqShbUGpVkrCQHf4N6wTJPTg+hjngjwC5 fOhDm1R9jZ1I/R96I4SYrSGRgwz/BFqlTI24AJala+2A/rTIJV1JwWxqngdIXbknsOc3tS WUGn7C/3soHKJjy5Qxq7ZXWCKtBSwc+BsiEvRvFaiZvA7SfKSXkqUl/c0L+fJPUOE8p4Mf QsaJJ+FuiuZv0HU3ZIfaWK3/NEP0ewyohWSgH0jhQ5UBb7YHmenMe/SNtBWgjw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791492225; b=fhFzmK7PmRyEYsbbQZBEe0DQJ9h/sFf0b/F9G9kPGMsbHA6FI0D4x35/V/RBxbV1A/lz51 6VfUZvGnYaPbVu1jHzNu3o0xZ7wWdbXJtahgNl+AWw4B9vbp+y4uZTbqRXnnlhlnvCl0pN hEV9b1N3CjSJEH7wxTmbsdtl93otHxJWZQgUV7pbSY3jZVPhW6NjCdPTTWPm/n8dZNljHF Za1Tn7ctrUW+wwtKo+ioAxaCr15WpgLdgYfAPGK/rqqvi8h4lDdyLb3UpQY8jpT8D5UcTm dKFxxvaYzttkoVILeKlmz4azTChXizPSc2mVSydzVbtzESTIhwV0JcGxgPpeNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791492225; 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=O4azKjxesuK4FxbC4gudE9HsY9bHWgF+sLAbYBl4SnQ=; b=fnThpGoMTmTFrD3kcAgx7hQpRL2Qwq8NxtRd89xiYsMppPQPs1oIF8kUEFVTkCHf2Pzf0N eBAm24uZ7fwvtPGfxL3O8SH8QGUD2H37YdWoB2Swve7AcU5gG+pYG/G7USjbaVr8TO6qc7 2jzqPAhZtOk29YLvxwjMBqVHK9d7jeHzve4CmTNjh+4PpavKsxf2LbFYI9XxoWvFwIaeXk Zq0exniZ4a5Hs0e6dgpCCxeSHpyr3/RDFnE450esIu+vqacuSjUobWzmroAmCE7c+k406v 53AycJkF30WuD1qqKkJghZSCUsspdzWNZtmr+t6EGbuVWGdTLadshVXyglos/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j125Y4fKZzwmN for ; Thu, 08 Oct 2026 20:43:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32449 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 08 Oct 2026 20:43:45 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 489af4764fa9 - stable/15 - pciconf: Minor cleanups in the config register methods 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 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 489af4764fa96fdca9e36f5ec873b77837a34482 Auto-Submitted: auto-generated Date: Thu, 08 Oct 2026 20:43:45 +0000 Message-Id: <6ac80081.32449.45f4759f@gitrepo.freebsd.org> The branch stable/15 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=489af4764fa96fdca9e36f5ec873b77837a34482 commit 489af4764fa96fdca9e36f5ec873b77837a34482 Author: John Baldwin AuthorDate: 2026-06-23 15:51:43 +0000 Commit: John Baldwin CommitDate: 2026-10-08 20:42:31 +0000 pciconf: Minor cleanups in the config register methods This is mostly to provide cleaner code for future changes to copy from. - Use NULL instead of casting 0 to pointer types. - Inline readone() in the sole caller now that it is just a single line. - Use a helper variable for the count of items on each line of output in readit(). - Fix the double space in the middle of byte output to only trigger for width 1. For other widths it would output spurious spaces at the end of the line which doesn't really hurt, but is buggy nonetheless. - Avoid using implicit booleans by explicitly comparing integer expressions against zero. - Don't compare the endptr returned from strtol() against NULL. Differential Revision: https://reviews.freebsd.org/D57535 (cherry picked from commit c6eb9f16cf0e19b54b382aa44f0c9a7bcec5fc40) --- usr.sbin/pciconf/pciconf.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index b40c7dce4e40..acbd268c8be4 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -1290,13 +1290,6 @@ getsel(const char *str) return (parsesel(str)); } -static void -readone(int fd, struct pcisel *sel, long reg, int width) -{ - - printf("%0*x", width*2, read_config(fd, sel, reg, width)); -} - static void readit(const char *name, const char *reg, int width) { @@ -1304,7 +1297,7 @@ readit(const char *name, const char *reg, int width) long rend; long r; char *end; - int i; + int i, items_per_line; int fd; struct pcisel sel; @@ -1313,18 +1306,22 @@ readit(const char *name, const char *reg, int width) err(1, "%s", _PATH_DEVPCI); rend = rstart = strtol(reg, &end, 0); - if (end && *end == ':') { + if (*end == ':') { end++; - rend = strtol(end, (char **) 0, 0); + rend = strtol(end, NULL, 0); } sel = getsel(name); + items_per_line = 16 / width; for (i = 1, r = rstart; r <= rend; i++, r += width) { - readone(fd, &sel, r, width); - if (i && !(i % 8)) + printf("%0*x", width * 2, read_config(fd, &sel, r, width)); + + /* Use a double space in the middle when outputting bytes. */ + if (width == 1 && i % 16 == 8) putchar(' '); - putchar(i % (16/width) ? ' ' : '\n'); + + putchar(i % items_per_line == 0 ? '\n' : ' '); } - if (i % (16/width) != 1) + if (i % items_per_line != 1) putchar('\n'); close(fd); } @@ -1336,9 +1333,9 @@ writeit(const char *name, const char *reg, const char *data, int width) struct pci_io pi; pi.pi_sel = getsel(name); - pi.pi_reg = strtoul(reg, (char **)0, 0); /* XXX error check */ + pi.pi_reg = strtoul(reg, NULL, 0); /* XXX error check */ pi.pi_width = width; - pi.pi_data = strtoul(data, (char **)0, 0); /* XXX error check */ + pi.pi_data = strtoul(data, NULL, 0); /* XXX error check */ fd = open(_PATH_DEVPCI, O_RDWR, 0); if (fd < 0)