From nobody Mon Jan 12 17:18: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 4dqfH96kR7z6NrSF for ; Mon, 12 Jan 2026 17:18: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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dqfH95mQKz40lN for ; Mon, 12 Jan 2026 17:18:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768238325; 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=rxYeZMHhoyxCjeIsamwyUnO/CRPDEqrpbT8GZUzsN0Y=; b=EkDYH+G+EZbtq9dhLZdnpO1LF6CLU38EqNQ9cklDSHE3r3BY00uwJBNvh1HJ27+vdstLV8 9+Oj1m1cLGrECauEuJrIAyWOGRyI8nPZbtZXhxgZ2pzhRKw+Gt+sssYgk7KwnaqVHJ5hBY 5qQgtEkV1P8jQHxJw61IteJLASpKu9xPm+DIBSAcHOSKqZ7RYfRtsp3TbBB1i04GiDAEpE 2KGkJj5e0Q46gWsqytxc8KOLTh/9cyTlb/amvEuRPhsG4lekxw4WxhU7EBt8Vee+PCgS1v 83Dwdv734EUgS0Kz44UGRiXWzEY9r6fxH7t5s/wWZVjemC4iNbzt6T/K8B5+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768238325; 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=rxYeZMHhoyxCjeIsamwyUnO/CRPDEqrpbT8GZUzsN0Y=; b=E6OhexXkGNzWostVh+S9z8HPQRU8J8yY+neiZIMOyVIo/QwhBX1stPA3k94iNGoIlIHdoG xlxmINgfm0oPgEEN313vikHD9Z5a+vGo+dGBvx2eR8Lx5fBKQoinM9eGZQw+JnR3Qh/c6k 9y3BG8MlE1bdUL9zS0aR0u0e0TS3R7dYRRfN+1Hia3UyXoHLZqOhwSy0ccITOww0pOGGwF M+xAcjOD4Aqj+wfebpF6yqpbH9Q9F8Gyz2Ma+HNkk33WH3ZlQ2AJ0PwyqjHM1D8vCTU1FS zLvPPC/uoHxITlfJ6Q1geJiEE0DctNZnR6VArMVXSPmXydkyUKbRj+o5of59TA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768238325; a=rsa-sha256; cv=none; b=hV7XVla2YbKD6EhXTzMI5OOoUxqlNY47A39X3dXspjpJKhIols/jxyVxbcduILaXO3Pyb1 AArFVKxxF5TmtFNgDBhkIWkEAw8vQXJz+R7w1gxF+BEpAzrGwt3wk/yUcpCB4hhPu2Nhhx D4i1/HygyFUzpuFSbv7+8konEYf+g55d3Qi5SFErZGFKBe/lqk/UBIb2/bmcSzl9E/jxWF yGyAZSNkx59JsiiOs4z/E1kwuKyRpPHZJK/QvkgfExp7hCbJWfJpgT1DJf/xRjaCHAz/jE JxzcInnWPf48AYG3dwv5G58BXwv2jdQZjlrTLFcr0A6sskOlegUEbxF7tp4u1A== 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 4dqfH9518vzcMq for ; Mon, 12 Jan 2026 17:18:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37fb1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 12 Jan 2026 17:18:45 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 4b6cab42defc - stable/15 - libgeom: Clean up xml2tree code 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 4b6cab42defc58ed0a73bfdb7cdcdaff2d9cfef0 Auto-Submitted: auto-generated Date: Mon, 12 Jan 2026 17:18:45 +0000 Message-Id: <69652cf5.37fb1.c4c664a@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4b6cab42defc58ed0a73bfdb7cdcdaff2d9cfef0 commit 4b6cab42defc58ed0a73bfdb7cdcdaff2d9cfef0 Author: Dag-Erling Smørgrav AuthorDate: 2026-01-03 09:09:58 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-01-12 17:18:22 +0000 libgeom: Clean up xml2tree code MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D54453 (cherry picked from commit fad6707e2589d8557ceb6b6bf11f22323b265f01) --- lib/libgeom/geom_xml2tree.c | 100 ++++++++++++++++++++++---------------------- lib/libgeom/libgeom.h | 2 +- 2 files changed, 52 insertions(+), 50 deletions(-) diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c index 161425d9fadf..81f7de1be263 100644 --- a/lib/libgeom/geom_xml2tree.c +++ b/lib/libgeom/geom_xml2tree.c @@ -29,21 +29,24 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include +#include #include + +#include #include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -75,17 +78,14 @@ StartElement(void *userData, const char *name, const char **attr) id = NULL; ref = NULL; for (i = 0; attr[i] != NULL; i += 2) { - if (!strcmp(attr[i], "id")) { + if (strcmp(attr[i], "id") == 0) { id = (void *)strtoumax(attr[i + 1], NULL, 0); mt->nident++; - } else if (!strcmp(attr[i], "ref")) { + } else if (strcmp(attr[i], "ref") == 0) { ref = (void *)strtoumax(attr[i + 1], NULL, 0); - } else - printf("%*.*s[%s = %s]\n", - mt->level + 1, mt->level + 1, "", - attr[i], attr[i + 1]); + } } - if (!strcmp(name, "class") && mt->class == NULL) { + if (strcmp(name, "class") == 0 && mt->class == NULL) { mt->class = calloc(1, sizeof *mt->class); if (mt->class == NULL) { mt->error = errno; @@ -100,7 +100,7 @@ StartElement(void *userData, const char *name, const char **attr) LIST_INIT(&mt->class->lg_config); return; } - if (!strcmp(name, "geom") && mt->geom == NULL) { + if (strcmp(name, "geom") == 0 && mt->geom == NULL) { mt->geom = calloc(1, sizeof *mt->geom); if (mt->geom == NULL) { mt->error = errno; @@ -116,11 +116,11 @@ StartElement(void *userData, const char *name, const char **attr) LIST_INIT(&mt->geom->lg_config); return; } - if (!strcmp(name, "class") && mt->geom != NULL) { + if (strcmp(name, "class") == 0 && mt->geom != NULL) { mt->geom->lg_class = ref; return; } - if (!strcmp(name, "consumer") && mt->consumer == NULL) { + if (strcmp(name, "consumer") == 0 && mt->consumer == NULL) { mt->consumer = calloc(1, sizeof *mt->consumer); if (mt->consumer == NULL) { mt->error = errno; @@ -135,15 +135,15 @@ StartElement(void *userData, const char *name, const char **attr) LIST_INIT(&mt->consumer->lg_config); return; } - if (!strcmp(name, "geom") && mt->consumer != NULL) { + if (strcmp(name, "geom") == 0 && mt->consumer != NULL) { mt->consumer->lg_geom = ref; return; } - if (!strcmp(name, "provider") && mt->consumer != NULL) { + if (strcmp(name, "provider") == 0 && mt->consumer != NULL) { mt->consumer->lg_provider = ref; return; } - if (!strcmp(name, "provider") && mt->provider == NULL) { + if (strcmp(name, "provider") == 0 && mt->provider == NULL) { mt->provider = calloc(1, sizeof *mt->provider); if (mt->provider == NULL) { mt->error = errno; @@ -159,11 +159,11 @@ StartElement(void *userData, const char *name, const char **attr) LIST_INIT(&mt->provider->lg_config); return; } - if (!strcmp(name, "geom") && mt->provider != NULL) { + if (strcmp(name, "geom") == 0 && mt->provider != NULL) { mt->provider->lg_geom = ref; return; } - if (!strcmp(name, "config")) { + if (strcmp(name, "config") == 0) { if (mt->provider != NULL) { mt->config = &mt->provider->lg_config; return; @@ -210,7 +210,7 @@ EndElement(void *userData, const char *name) p = NULL; } - if (!strcmp(name, "name")) { + if (strcmp(name, "name") == 0) { if (mt->provider != NULL) { mt->provider->lg_name = p; return; @@ -222,47 +222,47 @@ EndElement(void *userData, const char *name) return; } } - if (!strcmp(name, "rank") && mt->geom != NULL) { + if (strcmp(name, "rank") == 0 && mt->geom != NULL) { mt->geom->lg_rank = strtoul(p, NULL, 0); free(p); return; } - if (!strcmp(name, "mode") && mt->provider != NULL) { + if (strcmp(name, "mode") == 0 && mt->provider != NULL) { mt->provider->lg_mode = p; return; } - if (!strcmp(name, "mode") && mt->consumer != NULL) { + if (strcmp(name, "mode") == 0 && mt->consumer != NULL) { mt->consumer->lg_mode = p; return; } - if (!strcmp(name, "mediasize") && mt->provider != NULL) { + if (strcmp(name, "mediasize") == 0 && mt->provider != NULL) { mt->provider->lg_mediasize = strtoumax(p, NULL, 0); free(p); return; } - if (!strcmp(name, "sectorsize") && mt->provider != NULL) { + if (strcmp(name, "sectorsize") == 0 && mt->provider != NULL) { mt->provider->lg_sectorsize = strtoul(p, NULL, 0); free(p); return; } - if (!strcmp(name, "stripesize") && mt->provider != NULL) { + if (strcmp(name, "stripesize") == 0 && mt->provider != NULL) { mt->provider->lg_stripesize = strtoumax(p, NULL, 0); free(p); return; } - if (!strcmp(name, "stripeoffset") && mt->provider != NULL) { + if (strcmp(name, "stripeoffset") == 0 && mt->provider != NULL) { mt->provider->lg_stripeoffset = strtoumax(p, NULL, 0); free(p); return; } - if (!strcmp(name, "config")) { + if (strcmp(name, "config") == 0) { mt->config = NULL; free(p); return; } - if (mt->config != NULL || (!strcmp(name, "wither") && + if (mt->config != NULL || (strcmp(name, "wither") == 0 && (mt->provider != NULL || mt->geom != NULL))) { if (mt->config != NULL) c = mt->config; @@ -301,28 +301,28 @@ EndElement(void *userData, const char *name) free(p); } - if (!strcmp(name, "consumer") && mt->consumer != NULL) { + if (strcmp(name, "consumer") == 0 && mt->consumer != NULL) { mt->consumer = NULL; return; } - if (!strcmp(name, "provider") && mt->provider != NULL) { + if (strcmp(name, "provider") == 0 && mt->provider != NULL) { mt->provider = NULL; return; } - if (!strcmp(name, "geom") && mt->consumer != NULL) { + if (strcmp(name, "geom") == 0 && mt->consumer != NULL) { return; } - if (!strcmp(name, "geom") && mt->provider != NULL) { + if (strcmp(name, "geom") == 0 && mt->provider != NULL) { return; } - if (!strcmp(name, "geom") && mt->geom != NULL) { + if (strcmp(name, "geom") == 0 && mt->geom != NULL) { mt->geom = NULL; return; } - if (!strcmp(name, "class") && mt->geom != NULL) { + if (strcmp(name, "class") == 0 && mt->geom != NULL) { return; } - if (!strcmp(name, "class") && mt->class != NULL) { + if (strcmp(name, "class") == 0 && mt->class != NULL) { mt->class = NULL; return; } @@ -347,7 +347,7 @@ CharData(void *userData , const XML_Char *s , int len) } struct gident * -geom_lookupid(struct gmesh *gmp, const void *id) +geom_lookupid(const struct gmesh *gmp, const void *id) { struct gident *gip; @@ -413,6 +413,7 @@ geom_xml2tree(struct gmesh *gmp, char *p) return (ENOMEM); i = 0; /* Collect all identifiers */ + /* XXX we should check for duplicate identifiers */ LIST_FOREACH(cl, &gmp->lg_class, lg_class) { gmp->lg_ident[i].lg_id = cl->lg_id; gmp->lg_ident[i].lg_ptr = cl; @@ -441,8 +442,9 @@ geom_xml2tree(struct gmesh *gmp, char *p) LIST_FOREACH(cl, &gmp->lg_class, lg_class) { LIST_FOREACH(ge, &cl->lg_geom, lg_geom) { ge->lg_class = geom_lookupidptr(gmp, ge->lg_class); - LIST_FOREACH(pr, &ge->lg_provider, lg_provider) + LIST_FOREACH(pr, &ge->lg_provider, lg_provider) { pr->lg_geom = geom_lookupidptr(gmp, pr->lg_geom); + } LIST_FOREACH(co, &ge->lg_consumer, lg_consumer) { co->lg_geom = geom_lookupidptr(gmp, co->lg_geom); if (co->lg_provider != NULL) { @@ -522,22 +524,22 @@ geom_deletetree(struct gmesh *gmp) break; LIST_REMOVE(cl, lg_class); delete_config(&cl->lg_config); - if (cl->lg_name) free(cl->lg_name); + free(cl->lg_name); for (;;) { ge = LIST_FIRST(&cl->lg_geom); if (ge == NULL) break; LIST_REMOVE(ge, lg_geom); delete_config(&ge->lg_config); - if (ge->lg_name) free(ge->lg_name); + free(ge->lg_name); for (;;) { pr = LIST_FIRST(&ge->lg_provider); if (pr == NULL) break; LIST_REMOVE(pr, lg_provider); delete_config(&pr->lg_config); - if (pr->lg_name) free(pr->lg_name); - if (pr->lg_mode) free(pr->lg_mode); + free(pr->lg_name); + free(pr->lg_mode); free(pr); } for (;;) { @@ -546,7 +548,7 @@ geom_deletetree(struct gmesh *gmp) break; LIST_REMOVE(co, lg_consumer); delete_config(&co->lg_config); - if (co->lg_mode) free(co->lg_mode); + free(co->lg_mode); free(co); } free(ge); diff --git a/lib/libgeom/libgeom.h b/lib/libgeom/libgeom.h index 950508fd3637..2116645bd496 100644 --- a/lib/libgeom/libgeom.h +++ b/lib/libgeom/libgeom.h @@ -133,7 +133,7 @@ struct gprovider { struct gconf lg_config; }; -struct gident * geom_lookupid(struct gmesh *, const void *); +struct gident *geom_lookupid(const struct gmesh *, const void *); int geom_xml2tree(struct gmesh *, char *); int geom_gettree(struct gmesh *); int geom_gettree_geom(struct gmesh *, const char *, const char *, int);