From nobody Tue May 21 23:56:19 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 4VkWYJ1sM3z5L6lQ; Tue, 21 May 2024 23:56:20 +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 4VkWYH6lqcz4jHJ; Tue, 21 May 2024 23:56:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716335779; 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=1Dn1wn6vsoeUFIbq8vSDtkRP7cSlzlZKH0GfUhZPeHc=; b=aOy/sgWKGF/gQvEeEe+6y3qecHM6QID16JGnhJO1fQ96aJbX4bUWIpSgsp+8BFtKOG7qm8 5DQPy4N45psMmLJr2mGnR7fvYxT3g1wEDK7ju6xls2cJWfENRRAA5qu9/BNdEfAMsPwYZQ 0GR77CLAAg9jVU1SpmBPMkJo101SF3GfhkZ+MyTuVaOnsVLqQjBN8Gxc1Dei8POZ75USOT NrxehYazOnFe2yyzh15fzs8dKhWVO4XXDpOOvq8n7B+MhxFpr56FDZgag6xPh0otI2ALlu laDwBw+07RGC+L+yO/dgLHA25/eGnE2kxKsDoMhyvP5fvQ6kcEm+mZJaAbJDCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716335779; a=rsa-sha256; cv=none; b=ec2YGPN7G9AwwEA5jwzGcyjjn4W3ix8I0qC8BQTsuAHeXkt0Pf7+DNioeMR/jnophLZE05 J1az6UxKh24lnan8YVA5Uhg1ERbiXkLmQ4zYL2mdnvRv/j/4oygKwjgZK+uIoxPagTQ5is c3P5E2hYNmmAZW491cCdqb+q4/8Uy/0SPjEPkm7a6q1RoSlZmw77HNjOb7g4uWd0RAfCYI zjpoCvd9yw2R5gU3x1rTDvvt8A1n6eYA3I9QApKPdFEwCd0nK6jPdS5bg0futawcmkQhfo V0p4vG3n4OsX0u3OVgHLqg5uUYMvBxSk8RkjJZYfH6iFwbJA9rz6Sl7GQL3uOg== 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=1716335779; 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=1Dn1wn6vsoeUFIbq8vSDtkRP7cSlzlZKH0GfUhZPeHc=; b=phPWluQ+TLz9sCfueMBOLOx61QOVc+yW7mikqMNlhsxgqWPnISux6mUm6EFyd8qrztecRA O/JH9JBHUEffv42lq98Oc3t6NuXYOn0xG3YqN3iZs5yPJSdn4nyhNJ0rXoQXOLPau5tu7B xPrBR8xwjch9TwsHr5sXlPVmI7zJ4cnIXSW2VRQN6wKJNa5fKC8rZlPLJpi5XqZo7q0buL vvVWPVEa8JRumvu+T/mM5tLhdDnD07hA/6hXFBi6omlyieUOOrwnujvm1VixuU1umyOXXf QIuWHlHMgUih+H8MgAakc6HLk2pRMgYApeATus93SMBqOfdGP4zAB5Vg0F5j3w== 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 4VkWYH64n5zj4p; Tue, 21 May 2024 23:56:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44LNuJbB032126; Tue, 21 May 2024 23:56:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44LNuJRg032123; Tue, 21 May 2024 23:56:19 GMT (envelope-from git) Date: Tue, 21 May 2024 23:56:19 GMT Message-Id: <202405212356.44LNuJRg032123@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 973c32297f3b - main - kern/rman: update DPRINTF() macro, avoid semicolon swallowing match function 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 973c32297f3b43deae37d8e26b25d1133daa2a38 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=973c32297f3b43deae37d8e26b25d1133daa2a38 commit 973c32297f3b43deae37d8e26b25d1133daa2a38 Author: Elliott Mitchell AuthorDate: 2024-05-09 05:34:49 +0000 Commit: Warner Losh CommitDate: 2024-05-21 23:52:15 +0000 kern/rman: update DPRINTF() macro, avoid semicolon swallowing match function Using a variadic macro allows passing everything properly to printf(). Using the do { } while(0) construct ensures the macro acts like any other single statement. This shows just how long some of this has existed. Reviewed by: imp,jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1224 --- sys/kern/subr_rman.c | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 1393781a66fe..ffd8def66b5c 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -98,7 +98,7 @@ static int rman_debug = 0; SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RWTUN, &rman_debug, 0, "rman debug"); -#define DPRINTF(params) if (rman_debug) printf params +#define DPRINTF(...) do { if (rman_debug) printf(__VA_ARGS__); } while (0) static MALLOC_DEFINE(M_RMAN, "rman", "Resource manager"); @@ -154,8 +154,8 @@ rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end) struct resource_i *r, *s, *t; int rv = 0; - DPRINTF(("rman_manage_region: <%s> request: start %#jx, end %#jx\n", - rm->rm_descr, start, end)); + DPRINTF("rman_manage_region: <%s> request: start %#jx, end %#jx\n", + rm->rm_descr, start, end); if (start < rm->rm_start || end > rm->rm_end) return EINVAL; r = int_alloc_resource(M_NOWAIT); @@ -439,10 +439,10 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, rv = NULL; - DPRINTF(("rman_reserve_resource_bound: <%s> request: [%#jx, %#jx], " + DPRINTF("rman_reserve_resource_bound: <%s> request: [%#jx, %#jx], " "length %#jx, flags %x, device %s\n", rm->rm_descr, start, end, count, flags, - dev == NULL ? "" : device_get_nameunit(dev))); + dev == NULL ? "" : device_get_nameunit(dev)); KASSERT(count != 0, ("%s: attempted to allocate an empty range", __func__)); KASSERT((flags & RF_FIRSTSHARE) == 0, @@ -453,21 +453,21 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, r = TAILQ_FIRST(&rm->rm_list); if (r == NULL) { - DPRINTF(("NULL list head\n")); + DPRINTF("NULL list head\n"); } else { - DPRINTF(("rman_reserve_resource_bound: trying %#jx <%#jx,%#jx>\n", - r->r_end, start, count-1)); + DPRINTF("rman_reserve_resource_bound: trying %#jx <%#jx,%#jx>\n", + r->r_end, start, count-1); } for (r = TAILQ_FIRST(&rm->rm_list); r && r->r_end < start + count - 1; r = TAILQ_NEXT(r, r_link)) { ; - DPRINTF(("rman_reserve_resource_bound: tried %#jx <%#jx,%#jx>\n", - r->r_end, start, count-1)); + DPRINTF("rman_reserve_resource_bound: tried %#jx <%#jx,%#jx>\n", + r->r_end, start, count-1); } if (r == NULL) { - DPRINTF(("could not find a region\n")); + DPRINTF("could not find a region\n"); goto out; } @@ -481,23 +481,23 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, * First try to find an acceptable totally-unshared region. */ for (s = r; s; s = TAILQ_NEXT(s, r_link)) { - DPRINTF(("considering [%#jx, %#jx]\n", s->r_start, s->r_end)); + DPRINTF("considering [%#jx, %#jx]\n", s->r_start, s->r_end); /* * The resource list is sorted, so there is no point in * searching further once r_start is too large. */ if (s->r_start > end - (count - 1)) { - DPRINTF(("s->r_start (%#jx) + count - 1> end (%#jx)\n", - s->r_start, end)); + DPRINTF("s->r_start (%#jx) + count - 1> end (%#jx)\n", + s->r_start, end); break; } if (s->r_start > RM_MAX_END - amask) { - DPRINTF(("s->r_start (%#jx) + amask (%#jx) too large\n", - s->r_start, amask)); + DPRINTF("s->r_start (%#jx) + amask (%#jx) too large\n", + s->r_start, amask); break; } if (s->r_flags & RF_ALLOCATED) { - DPRINTF(("region is allocated\n")); + DPRINTF("region is allocated\n"); continue; } rstart = ummax(s->r_start, start); @@ -514,17 +514,17 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, rstart < s->r_end); rend = ummin(s->r_end, ummax(rstart + count - 1, end)); if (rstart > rend) { - DPRINTF(("adjusted start exceeds end\n")); + DPRINTF("adjusted start exceeds end\n"); continue; } - DPRINTF(("truncated region: [%#jx, %#jx]; size %#jx (requested %#jx)\n", - rstart, rend, (rend - rstart + 1), count)); + DPRINTF("truncated region: [%#jx, %#jx]; size %#jx (requested %#jx)\n", + rstart, rend, (rend - rstart + 1), count); if ((rend - rstart) >= (count - 1)) { - DPRINTF(("candidate region: [%#jx, %#jx], size %#jx\n", - rstart, rend, (rend - rstart + 1))); + DPRINTF("candidate region: [%#jx, %#jx], size %#jx\n", + rstart, rend, (rend - rstart + 1)); if ((s->r_end - s->r_start + 1) == count) { - DPRINTF(("candidate region is entire chunk\n")); + DPRINTF("candidate region is entire chunk\n"); rv = s; rv->r_flags = new_rflags; rv->r_dev = dev; @@ -551,11 +551,11 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, rv->r_rm = rm; if (s->r_start < rv->r_start && s->r_end > rv->r_end) { - DPRINTF(("splitting region in three parts: " + DPRINTF("splitting region in three parts: " "[%#jx, %#jx]; [%#jx, %#jx]; [%#jx, %#jx]\n", s->r_start, rv->r_start - 1, rv->r_start, rv->r_end, - rv->r_end + 1, s->r_end)); + rv->r_end + 1, s->r_end); /* * We are allocating in the middle. */ @@ -575,14 +575,14 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, TAILQ_INSERT_AFTER(&rm->rm_list, rv, r, r_link); } else if (s->r_start == rv->r_start) { - DPRINTF(("allocating from the beginning\n")); + DPRINTF("allocating from the beginning\n"); /* * We are allocating at the beginning. */ s->r_start = rv->r_end + 1; TAILQ_INSERT_BEFORE(s, rv, r_link); } else { - DPRINTF(("allocating at the end\n")); + DPRINTF("allocating at the end\n"); /* * We are allocating at the end. */ @@ -602,7 +602,7 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, * former restriction could probably be lifted without too much * additional work, but this does not seem warranted.) */ - DPRINTF(("no unshared regions found\n")); + DPRINTF("no unshared regions found\n"); if ((flags & RF_SHAREABLE) == 0) goto out;