From nobody Mon Jan 12 17:19:43 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 4dqfJK0q7xz6NrNy for ; Mon, 12 Jan 2026 17:19: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 4dqfJH3TjSz427W for ; Mon, 12 Jan 2026 17:19:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768238383; 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=nGsDR096SNZsvLMQAVQOG5Kg1IIB7ky62yxRMlVs/Ng=; b=pxIsYqV0d4h1r500QQR844QC5ArVuhlQRnyihT7LWINLbmtMrxeAmqsjeDD/wdH2hPNE/H Hv12OwCLd438dnD/gyMXAPDUCbOpsFb+FDDGwSukDU+wnox3t+FJpa2ORqcs+ESeYxtGjM MMo4KJoHDO03ugMTJMpgKbkTXxoVLa3ZxaiXQfQsAY/z1G5XK3NHw+lSozUG/jrJUFeeRF bHvq0R+6xXTNXG10mAkkAYpZIeLSWhCfd2ipPXu/eRnB+uer/prydj/eWFOkrVyG++fhbq mnrCgkTWl9d4yiqBs0Z0qLkEtAcsMwJHEDornfxtl1Gp96IULLuAzMewnAau5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768238383; 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=nGsDR096SNZsvLMQAVQOG5Kg1IIB7ky62yxRMlVs/Ng=; b=mghdOqmSdnvmYFtc70EJ+czN/6j8LlzPq87b4JfOXPri3kH6/RlMwrjA7tE15Zs5Wb78Gp gBicNA/DZ+Dt+XgsyGjNtv2Hu6E1m/krI/eIWxlS+PwUgneQapehQ3vF0IDvXLDEh5x+It Z8X9BpFoP6F22tUPQJKwT7XPjMeUTiOWyRwDRxFCX5gfJlf0Tap5JpHyl46BmHXKbZ/xLv OIx+Ch6G25+C5CTj70QL0Mowbqcubm4CaQo+LT7pTN9DBWRp80kTs6/RGJTS5tRRCSBAWP yqCmOlK2Xu8CZ651TH/V8My099jOE+v/SrE6M24lHDdhk+0fOyE6dhVnwXf39w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768238383; a=rsa-sha256; cv=none; b=dkGbgyvX/X7FZB4upJ7vES3H/NHBbjRP9xq7oa5CfDgW89G4e8Kb5SK7vIe0NNdRwZFlR5 5eXwDqo77NKmmhe40LXL8UO2Yip/fvyCCaQA6y15Yj8OYS33jfYXejlwiPTSbjLVWaQxgx Hg0m2TX3861RAJTlYA4Hc1Z1DD+mvYf/dZZNODKEaSWe6c+avQtHrdr2V/wqSmI+VL30mw lSU90O4vQrjvY/NjwfnC0F+C5ryHwVtfNz3fbTwhaOOkM/glw7VMgGW2LpRtkI8Tg/uLGz wCFckL+ZE74x2wZoI6mk2/GEgmRvjtJGUtpsVEPVhL2VKCGZfYiVdCkofsLB2Q== 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 4dqfJH32kYzcLM for ; Mon, 12 Jan 2026 17:19:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37fbe by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 12 Jan 2026 17:19:43 +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: f147d5ea78ab - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: f147d5ea78ab8466a0e94a0d386ebfb0b195d56b Auto-Submitted: auto-generated Date: Mon, 12 Jan 2026 17:19:43 +0000 Message-Id: <69652d2f.37fbe.4e04fd81@gitrepo.freebsd.org> The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=f147d5ea78ab8466a0e94a0d386ebfb0b195d56b commit f147d5ea78ab8466a0e94a0d386ebfb0b195d56b Author: Dag-Erling Smørgrav AuthorDate: 2026-01-03 09:09:58 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-01-11 02:30:46 +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);