Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2019 15:36:02 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349195 - in head/sys: geom geom/concat geom/eli geom/journal geom/mirror geom/multipath geom/part geom/raid geom/raid3 geom/stripe kern
Message-ID:  <201906191536.x5JFa2EO090757@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Jun 19 15:36:02 2019
New Revision: 349195
URL: https://svnweb.freebsd.org/changeset/base/349195

Log:
  Use sbuf_cat() in GEOM confxml generation.
  
  When it comes to megabytes of text, difference between sbuf_printf() and
  sbuf_cat() becomes substantial.
  
  MFC after:	2 weeks
  Sponsored by:	iXsystems, Inc.

Modified:
  head/sys/geom/concat/g_concat.c
  head/sys/geom/eli/g_eli.c
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_dump.c
  head/sys/geom/geom_int.h
  head/sys/geom/journal/g_journal.c
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/multipath/g_multipath.c
  head/sys/geom/part/g_part_apm.c
  head/sys/geom/part/g_part_bsd64.c
  head/sys/geom/part/g_part_gpt.c
  head/sys/geom/part/g_part_mbr.c
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid3/g_raid3.c
  head/sys/geom/stripe/g_stripe.c
  head/sys/kern/kern_uuid.c

Modified: head/sys/geom/concat/g_concat.c
==============================================================================
--- head/sys/geom/concat/g_concat.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/concat/g_concat.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -1004,24 +1004,24 @@ g_concat_dumpconf(struct sbuf *sb, const char *indent,
 		sbuf_printf(sb, "%s<Type>", indent);
 		switch (sc->sc_type) {
 		case G_CONCAT_TYPE_AUTOMATIC:
-			sbuf_printf(sb, "AUTOMATIC");
+			sbuf_cat(sb, "AUTOMATIC");
 			break;
 		case G_CONCAT_TYPE_MANUAL:
-			sbuf_printf(sb, "MANUAL");
+			sbuf_cat(sb, "MANUAL");
 			break;
 		default:
-			sbuf_printf(sb, "UNKNOWN");
+			sbuf_cat(sb, "UNKNOWN");
 			break;
 		}
-		sbuf_printf(sb, "</Type>\n");
+		sbuf_cat(sb, "</Type>\n");
 		sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
 		    indent, sc->sc_ndisks, g_concat_nvalid(sc));
 		sbuf_printf(sb, "%s<State>", indent);
 		if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
-			sbuf_printf(sb, "UP");
+			sbuf_cat(sb, "UP");
 		else
-			sbuf_printf(sb, "DOWN");
-		sbuf_printf(sb, "</State>\n");
+			sbuf_cat(sb, "DOWN");
+		sbuf_cat(sb, "</State>\n");
 	}
 }
 

Modified: head/sys/geom/eli/g_eli.c
==============================================================================
--- head/sys/geom/eli/g_eli.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/eli/g_eli.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -1328,17 +1328,17 @@ g_eli_dumpconf(struct sbuf *sb, const char *indent, st
 	    (uintmax_t)sc->sc_ekeys_allocated);
 	sbuf_printf(sb, "%s<Flags>", indent);
 	if (sc->sc_flags == 0)
-		sbuf_printf(sb, "NONE");
+		sbuf_cat(sb, "NONE");
 	else {
 		int first = 1;
 
 #define ADD_FLAG(flag, name)	do {					\
 	if (sc->sc_flags & (flag)) {					\
 		if (!first)						\
-			sbuf_printf(sb, ", ");				\
+			sbuf_cat(sb, ", ");				\
 		else							\
 			first = 0;					\
-		sbuf_printf(sb, name);					\
+		sbuf_cat(sb, name);					\
 	}								\
 } while (0)
 		ADD_FLAG(G_ELI_FLAG_SUSPEND, "SUSPEND");
@@ -1358,7 +1358,7 @@ g_eli_dumpconf(struct sbuf *sb, const char *indent, st
 		ADD_FLAG(G_ELI_FLAG_AUTORESIZE, "AUTORESIZE");
 #undef  ADD_FLAG
 	}
-	sbuf_printf(sb, "</Flags>\n");
+	sbuf_cat(sb, "</Flags>\n");
 
 	if (!(sc->sc_flags & G_ELI_FLAG_ONETIME)) {
 		sbuf_printf(sb, "%s<UsedKey>%u</UsedKey>\n", indent,
@@ -1368,16 +1368,16 @@ g_eli_dumpconf(struct sbuf *sb, const char *indent, st
 	sbuf_printf(sb, "%s<Crypto>", indent);
 	switch (sc->sc_crypto) {
 	case G_ELI_CRYPTO_HW:
-		sbuf_printf(sb, "hardware");
+		sbuf_cat(sb, "hardware");
 		break;
 	case G_ELI_CRYPTO_SW:
-		sbuf_printf(sb, "software");
+		sbuf_cat(sb, "software");
 		break;
 	default:
-		sbuf_printf(sb, "UNKNOWN");
+		sbuf_cat(sb, "UNKNOWN");
 		break;
 	}
-	sbuf_printf(sb, "</Crypto>\n");
+	sbuf_cat(sb, "</Crypto>\n");
 	if (sc->sc_flags & G_ELI_FLAG_AUTH) {
 		sbuf_printf(sb,
 		    "%s<AuthenticationAlgorithm>%s</AuthenticationAlgorithm>\n",

Modified: head/sys/geom/geom_disk.c
==============================================================================
--- head/sys/geom/geom_disk.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/geom_disk.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -599,15 +599,15 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, s
 		 */
 		sbuf_printf(sb, "%s<rotationrate>", indent);
 		if (dp->d_rotation_rate == DISK_RR_UNKNOWN) /* Old drives */
-			sbuf_printf(sb, "unknown");	/* don't report RPM. */
+			sbuf_cat(sb, "unknown");	/* don't report RPM. */
 		else if (dp->d_rotation_rate == DISK_RR_NON_ROTATING)
-			sbuf_printf(sb, "0");
+			sbuf_cat(sb, "0");
 		else if ((dp->d_rotation_rate >= DISK_RR_MIN) &&
 		    (dp->d_rotation_rate <= DISK_RR_MAX))
 			sbuf_printf(sb, "%u", dp->d_rotation_rate);
 		else
-			sbuf_printf(sb, "invalid");
-		sbuf_printf(sb, "</rotationrate>\n");
+			sbuf_cat(sb, "invalid");
+		sbuf_cat(sb, "</rotationrate>\n");
 		if (dp->d_getattr != NULL) {
 			buf = g_malloc(DISK_IDENT_SIZE, M_WAITOK);
 			bp = g_alloc_bio();
@@ -617,35 +617,34 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, s
 			bp->bio_data = buf;
 			res = dp->d_getattr(bp);
 			sbuf_printf(sb, "%s<ident>", indent);
-			g_conf_printf_escaped(sb, "%s",
-			    res == 0 ? buf: dp->d_ident);
-			sbuf_printf(sb, "</ident>\n");
+			g_conf_cat_escaped(sb, res == 0 ? buf : dp->d_ident);
+			sbuf_cat(sb, "</ident>\n");
 			bp->bio_attribute = "GEOM::lunid";
 			bp->bio_length = DISK_IDENT_SIZE;
 			bp->bio_data = buf;
 			if (dp->d_getattr(bp) == 0) {
 				sbuf_printf(sb, "%s<lunid>", indent);
-				g_conf_printf_escaped(sb, "%s", buf);
-				sbuf_printf(sb, "</lunid>\n");
+				g_conf_cat_escaped(sb, buf);
+				sbuf_cat(sb, "</lunid>\n");
 			}
 			bp->bio_attribute = "GEOM::lunname";
 			bp->bio_length = DISK_IDENT_SIZE;
 			bp->bio_data = buf;
 			if (dp->d_getattr(bp) == 0) {
 				sbuf_printf(sb, "%s<lunname>", indent);
-				g_conf_printf_escaped(sb, "%s", buf);
-				sbuf_printf(sb, "</lunname>\n");
+				g_conf_cat_escaped(sb, buf);
+				sbuf_cat(sb, "</lunname>\n");
 			}
 			g_destroy_bio(bp);
 			g_free(buf);
 		} else {
 			sbuf_printf(sb, "%s<ident>", indent);
-			g_conf_printf_escaped(sb, "%s", dp->d_ident);
-			sbuf_printf(sb, "</ident>\n");
+			g_conf_cat_escaped(sb, dp->d_ident);
+			sbuf_cat(sb, "</ident>\n");
 		}
 		sbuf_printf(sb, "%s<descr>", indent);
-		g_conf_printf_escaped(sb, "%s", dp->d_descr);
-		sbuf_printf(sb, "</descr>\n");
+		g_conf_cat_escaped(sb, dp->d_descr);
+		sbuf_cat(sb, "</descr>\n");
 	}
 }
 

Modified: head/sys/geom/geom_dump.c
==============================================================================
--- head/sys/geom/geom_dump.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/geom_dump.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -105,10 +105,10 @@ g_confdot(void *p, int flag )
 	KASSERT(flag != EV_CANCEL, ("g_confdot was cancelled"));
 	sb = p;
 	g_topology_assert();
-	sbuf_printf(sb, "digraph geom {\n");
+	sbuf_cat(sb, "digraph geom {\n");
 	LIST_FOREACH(mp, &g_classes, class)
 		g_confdot_class(sb, mp);
-	sbuf_printf(sb, "}\n");
+	sbuf_cat(sb, "}\n");
 	sbuf_finish(sb);
 }
 
@@ -125,7 +125,7 @@ g_conftxt_geom(struct sbuf *sb, struct g_geom *gp, int
 		    pp->name, (uintmax_t)pp->mediasize, pp->sectorsize);
 		if (gp->dumpconf != NULL)
 			gp->dumpconf(sb, NULL, gp, NULL, pp);
-		sbuf_printf(sb, "\n");
+		sbuf_cat(sb, "\n");
 		LIST_FOREACH(cp, &pp->consumers, consumers)
 			g_conftxt_geom(sb, cp->geom, level + 1);
 	}
@@ -156,12 +156,26 @@ g_conftxt(void *p, int flag)
 	sbuf_finish(sb);
 }
 
+void
+g_conf_cat_escaped(struct sbuf *sb, const char *buf)
+{
+	const u_char *c;
 
+	for (c = buf; *c != '\0'; c++) {
+		if (*c == '&' || *c == '<' || *c == '>' ||
+		    *c == '\'' || *c == '"' || *c > 0x7e)
+			sbuf_printf(sb, "&#x%X;", *c);
+		else if (*c == '\t' || *c == '\n' || *c == '\r' || *c > 0x1f)
+			sbuf_putc(sb, *c);
+		else
+			sbuf_putc(sb, '?');
+	}
+}
+
 void
 g_conf_printf_escaped(struct sbuf *sb, const char *fmt, ...)
 {
 	struct sbuf *s;
-	const u_char *c;
 	va_list ap;
 
 	s = sbuf_new_auto();
@@ -170,15 +184,7 @@ g_conf_printf_escaped(struct sbuf *sb, const char *fmt
 	va_end(ap);
 	sbuf_finish(s);
 
-	for (c = sbuf_data(s); *c != '\0'; c++) {
-		if (*c == '&' || *c == '<' || *c == '>' ||
-		    *c == '\'' || *c == '"' || *c > 0x7e)
-			sbuf_printf(sb, "&#x%X;", *c);
-		else if (*c == '\t' || *c == '\n' || *c == '\r' || *c > 0x1f)
-			sbuf_putc(sb, *c);
-		else
-			sbuf_putc(sb, '?');
-	}
+	g_conf_cat_escaped(sb, sbuf_data(s));
 	sbuf_delete(s);
 }
 
@@ -195,11 +201,11 @@ g_conf_consumer(struct sbuf *sb, struct g_consumer *cp
 	if (cp->geom->flags & G_GEOM_WITHER)
 		;
 	else if (cp->geom->dumpconf != NULL) {
-		sbuf_printf(sb, "\t  <config>\n");
+		sbuf_cat(sb, "\t  <config>\n");
 		cp->geom->dumpconf(sb, "\t    ", cp->geom, cp, NULL);
-		sbuf_printf(sb, "\t  </config>\n");
+		sbuf_cat(sb, "\t  </config>\n");
 	}
-	sbuf_printf(sb, "\t</consumer>\n");
+	sbuf_cat(sb, "\t</consumer>\n");
 }
 
 static void
@@ -210,24 +216,24 @@ g_conf_provider(struct sbuf *sb, struct g_provider *pp
 	sbuf_printf(sb, "\t  <geom ref=\"%p\"/>\n", pp->geom);
 	sbuf_printf(sb, "\t  <mode>r%dw%de%d</mode>\n",
 	    pp->acr, pp->acw, pp->ace);
-	sbuf_printf(sb, "\t  <name>");
-	g_conf_printf_escaped(sb, "%s", pp->name);
-	sbuf_printf(sb, "</name>\n");
+	sbuf_cat(sb, "\t  <name>");
+	g_conf_cat_escaped(sb, pp->name);
+	sbuf_cat(sb, "</name>\n");
 	sbuf_printf(sb, "\t  <mediasize>%jd</mediasize>\n",
 	    (intmax_t)pp->mediasize);
 	sbuf_printf(sb, "\t  <sectorsize>%u</sectorsize>\n", pp->sectorsize);
 	sbuf_printf(sb, "\t  <stripesize>%ju</stripesize>\n", (uintmax_t)pp->stripesize);
 	sbuf_printf(sb, "\t  <stripeoffset>%ju</stripeoffset>\n", (uintmax_t)pp->stripeoffset);
 	if (pp->flags & G_PF_WITHER)
-		sbuf_printf(sb, "\t  <wither/>\n");
+		sbuf_cat(sb, "\t  <wither/>\n");
 	else if (pp->geom->flags & G_GEOM_WITHER)
 		;
 	else if (pp->geom->dumpconf != NULL) {
-		sbuf_printf(sb, "\t  <config>\n");
+		sbuf_cat(sb, "\t  <config>\n");
 		pp->geom->dumpconf(sb, "\t    ", pp->geom, NULL, pp);
-		sbuf_printf(sb, "\t  </config>\n");
+		sbuf_cat(sb, "\t  </config>\n");
 	}
-	sbuf_printf(sb, "\t</provider>\n");
+	sbuf_cat(sb, "\t</provider>\n");
 }
 
 
@@ -240,16 +246,16 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct
 
 	sbuf_printf(sb, "    <geom id=\"%p\">\n", gp);
 	sbuf_printf(sb, "      <class ref=\"%p\"/>\n", gp->class);
-	sbuf_printf(sb, "      <name>");
-	g_conf_printf_escaped(sb, "%s", gp->name);
-	sbuf_printf(sb, "</name>\n");
+	sbuf_cat(sb, "      <name>");
+	g_conf_cat_escaped(sb, gp->name);
+	sbuf_cat(sb, "</name>\n");
 	sbuf_printf(sb, "      <rank>%d</rank>\n", gp->rank);
 	if (gp->flags & G_GEOM_WITHER)
-		sbuf_printf(sb, "      <wither/>\n");
+		sbuf_cat(sb, "      <wither/>\n");
 	else if (gp->dumpconf != NULL) {
-		sbuf_printf(sb, "      <config>\n");
+		sbuf_cat(sb, "      <config>\n");
 		gp->dumpconf(sb, "\t", gp, NULL, NULL);
-		sbuf_printf(sb, "      </config>\n");
+		sbuf_cat(sb, "      </config>\n");
 	}
 	LIST_FOREACH(cp2, &gp->consumer, consumer) {
 		if (cp != NULL && cp != cp2)
@@ -263,11 +269,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct
 		g_conf_provider(sb, pp2);
 	}
 	LIST_FOREACH(gap, &gp->aliases, ga_next) {
-		sbuf_printf(sb, "      <alias>\n");
-		g_conf_printf_escaped(sb, "%s", gap->ga_alias);
-		sbuf_printf(sb, "      </alias>\n");
+		sbuf_cat(sb, "      <alias>\n");
+		g_conf_cat_escaped(sb, gap->ga_alias);
+		sbuf_cat(sb, "      </alias>\n");
 	}
-	sbuf_printf(sb, "    </geom>\n");
+	sbuf_cat(sb, "    </geom>\n");
 }
 
 static void
@@ -276,15 +282,15 @@ g_conf_class(struct sbuf *sb, struct g_class *mp, stru
 	struct g_geom *gp2;
 
 	sbuf_printf(sb, "  <class id=\"%p\">\n", mp);
-	sbuf_printf(sb, "    <name>");
-	g_conf_printf_escaped(sb, "%s", mp->name);
-	sbuf_printf(sb, "</name>\n");
+	sbuf_cat(sb, "    <name>");
+	g_conf_cat_escaped(sb, mp->name);
+	sbuf_cat(sb, "</name>\n");
 	LIST_FOREACH(gp2, &mp->geom, geom) {
 		if (gp != NULL && gp != gp2)
 			continue;
 		g_conf_geom(sb, gp2, pp, cp);
 	}
-	sbuf_printf(sb, "  </class>\n");
+	sbuf_cat(sb, "  </class>\n");
 }
 
 void
@@ -293,13 +299,13 @@ g_conf_specific(struct sbuf *sb, struct g_class *mp, s
 	struct g_class *mp2;
 
 	g_topology_assert();
-	sbuf_printf(sb, "<mesh>\n");
+	sbuf_cat(sb, "<mesh>\n");
 	LIST_FOREACH(mp2, &g_classes, class) {
 		if (mp != NULL && mp != mp2)
 			continue;
 		g_conf_class(sb, mp2, gp, pp, cp);
 	}
-	sbuf_printf(sb, "</mesh>\n");
+	sbuf_cat(sb, "</mesh>\n");
 	sbuf_finish(sb);
 }
 

Modified: head/sys/geom/geom_int.h
==============================================================================
--- head/sys/geom/geom_int.h	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/geom_int.h	Wed Jun 19 15:36:02 2019	(r349195)
@@ -59,6 +59,7 @@ extern int g_debugflags;
 /* geom_dump.c */
 void g_confxml(void *, int flag);
 void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
+void g_conf_cat_escaped(struct sbuf *sb, const char *buf);
 void g_conf_printf_escaped(struct sbuf *sb, const char *fmt, ...);
 void g_confdot(void *, int flag);
 void g_conftxt(void *, int flag);

Modified: head/sys/geom/journal/g_journal.c
==============================================================================
--- head/sys/geom/journal/g_journal.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/journal/g_journal.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -2623,15 +2623,15 @@ g_journal_dumpconf(struct sbuf *sb, const char *indent
 
 		sbuf_printf(sb, "%s<Role>", indent);
 		if (cp == sc->sc_dconsumer) {
-			sbuf_printf(sb, "Data");
+			sbuf_cat(sb, "Data");
 			first = 0;
 		}
 		if (cp == sc->sc_jconsumer) {
 			if (!first)
-				sbuf_printf(sb, ",");
-			sbuf_printf(sb, "Journal");
+				sbuf_cat(sb, ",");
+			sbuf_cat(sb, "Journal");
 		}
-		sbuf_printf(sb, "</Role>\n");
+		sbuf_cat(sb, "</Role>\n");
 		if (cp == sc->sc_jconsumer) {
 			sbuf_printf(sb, "<Jstart>%jd</Jstart>\n",
 			    (intmax_t)sc->sc_jstart);

Modified: head/sys/geom/mirror/g_mirror.c
==============================================================================
--- head/sys/geom/mirror/g_mirror.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/mirror/g_mirror.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -3373,12 +3373,12 @@ g_mirror_dumpconf(struct sbuf *sb, const char *indent,
 		if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) {
 			sbuf_printf(sb, "%s<Synchronized>", indent);
 			if (disk->d_sync.ds_offset == 0)
-				sbuf_printf(sb, "0%%");
+				sbuf_cat(sb, "0%");
 			else
 				sbuf_printf(sb, "%u%%",
 				    (u_int)((disk->d_sync.ds_offset * 100) /
 				    sc->sc_mediasize));
-			sbuf_printf(sb, "</Synchronized>\n");
+			sbuf_cat(sb, "</Synchronized>\n");
 			if (disk->d_sync.ds_offset > 0)
 				sbuf_printf(sb, "%s<BytesSynced>%jd"
 				    "</BytesSynced>\n", indent,
@@ -3390,17 +3390,17 @@ g_mirror_dumpconf(struct sbuf *sb, const char *indent,
 		    disk->d_genid);
 		sbuf_printf(sb, "%s<Flags>", indent);
 		if (disk->d_flags == 0)
-			sbuf_printf(sb, "NONE");
+			sbuf_cat(sb, "NONE");
 		else {
 			int first = 1;
 
 #define	ADD_FLAG(flag, name)	do {					\
 	if ((disk->d_flags & (flag)) != 0) {				\
 		if (!first)						\
-			sbuf_printf(sb, ", ");				\
+			sbuf_cat(sb, ", ");				\
 		else							\
 			first = 0;					\
-		sbuf_printf(sb, name);					\
+		sbuf_cat(sb, name);					\
 	}								\
 } while (0)
 			ADD_FLAG(G_MIRROR_DISK_FLAG_DIRTY, "DIRTY");
@@ -3412,7 +3412,7 @@ g_mirror_dumpconf(struct sbuf *sb, const char *indent,
 			ADD_FLAG(G_MIRROR_DISK_FLAG_BROKEN, "BROKEN");
 #undef	ADD_FLAG
 		}
-		sbuf_printf(sb, "</Flags>\n");
+		sbuf_cat(sb, "</Flags>\n");
 		sbuf_printf(sb, "%s<Priority>%u</Priority>\n", indent,
 		    disk->d_priority);
 		sbuf_printf(sb, "%s<State>%s</State>\n", indent,
@@ -3421,39 +3421,39 @@ g_mirror_dumpconf(struct sbuf *sb, const char *indent,
 		sbuf_printf(sb, "%s<Type>", indent);
 		switch (sc->sc_type) {
 		case G_MIRROR_TYPE_AUTOMATIC:
-			sbuf_printf(sb, "AUTOMATIC");
+			sbuf_cat(sb, "AUTOMATIC");
 			break;
 		case G_MIRROR_TYPE_MANUAL:
-			sbuf_printf(sb, "MANUAL");
+			sbuf_cat(sb, "MANUAL");
 			break;
 		default:
-			sbuf_printf(sb, "UNKNOWN");
+			sbuf_cat(sb, "UNKNOWN");
 			break;
 		}
-		sbuf_printf(sb, "</Type>\n");
+		sbuf_cat(sb, "</Type>\n");
 		sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
 		sbuf_printf(sb, "%s<SyncID>%u</SyncID>\n", indent, sc->sc_syncid);
 		sbuf_printf(sb, "%s<GenID>%u</GenID>\n", indent, sc->sc_genid);
 		sbuf_printf(sb, "%s<Flags>", indent);
 		if (sc->sc_flags == 0)
-			sbuf_printf(sb, "NONE");
+			sbuf_cat(sb, "NONE");
 		else {
 			int first = 1;
 
 #define	ADD_FLAG(flag, name)	do {					\
 	if ((sc->sc_flags & (flag)) != 0) {				\
 		if (!first)						\
-			sbuf_printf(sb, ", ");				\
+			sbuf_cat(sb, ", ");				\
 		else							\
 			first = 0;					\
-		sbuf_printf(sb, name);					\
+		sbuf_cat(sb, name);					\
 	}								\
 } while (0)
 			ADD_FLAG(G_MIRROR_DEVICE_FLAG_NOFAILSYNC, "NOFAILSYNC");
 			ADD_FLAG(G_MIRROR_DEVICE_FLAG_NOAUTOSYNC, "NOAUTOSYNC");
 #undef	ADD_FLAG
 		}
-		sbuf_printf(sb, "</Flags>\n");
+		sbuf_cat(sb, "</Flags>\n");
 		sbuf_printf(sb, "%s<Slice>%u</Slice>\n", indent,
 		    (u_int)sc->sc_slice);
 		sbuf_printf(sb, "%s<Balance>%s</Balance>\n", indent,
@@ -3468,7 +3468,7 @@ g_mirror_dumpconf(struct sbuf *sb, const char *indent,
 			sbuf_printf(sb, "%s", "COMPLETE");
 		else
 			sbuf_printf(sb, "%s", "DEGRADED");
-		sbuf_printf(sb, "</State>\n");
+		sbuf_cat(sb, "</State>\n");
 	}
 }
 

Modified: head/sys/geom/multipath/g_multipath.c
==============================================================================
--- head/sys/geom/multipath/g_multipath.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/multipath/g_multipath.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -1450,7 +1450,7 @@ g_multipath_ctl_getactive(struct gctl_req *req, struct
 	} else if (sc->sc_active && sc->sc_active->provider) {
 		sbuf_printf(sb, "%s\n", sc->sc_active->provider->name);
 	} else {
-		sbuf_printf(sb, "none\n");
+		sbuf_cat(sb, "none\n");
 	}
 	sbuf_finish(sb);
 	gctl_set_param_err(req, "output", sbuf_data(sb), sbuf_len(sb) + 1);

Modified: head/sys/geom/part/g_part_apm.c
==============================================================================
--- head/sys/geom/part/g_part_apm.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/part/g_part_apm.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -310,13 +310,13 @@ g_part_apm_dumpconf(struct g_part_table *table, struct
 		strncpy(u.name, entry->ent.ent_name, APM_ENT_NAMELEN);
 		u.name[APM_ENT_NAMELEN] = '\0';
 		sbuf_printf(sb, "%s<label>", indent);
-		g_conf_printf_escaped(sb, "%s", u.name);
-		sbuf_printf(sb, "</label>\n");
+		g_conf_cat_escaped(sb, u.name);
+		sbuf_cat(sb, "</label>\n");
 		strncpy(u.type, entry->ent.ent_type, APM_ENT_TYPELEN);
 		u.type[APM_ENT_TYPELEN] = '\0';
 		sbuf_printf(sb, "%s<rawtype>", indent);
-		g_conf_printf_escaped(sb, "%s", u.type);
-		sbuf_printf(sb, "</rawtype>\n");
+		g_conf_cat_escaped(sb, u.type);
+		sbuf_cat(sb, "</rawtype>\n");
 	} else {
 		/* confxml: scheme information */
 	}

Modified: head/sys/geom/part/g_part_bsd64.c
==============================================================================
--- head/sys/geom/part/g_part_bsd64.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/part/g_part_bsd64.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -386,11 +386,11 @@ g_part_bsd64_dumpconf(struct g_part_table *basetable,
 		if (!EQUUID(&bsd64_uuid_unused, &entry->type_uuid)) {
 			sbuf_printf(sb, "%s<type_uuid>", indent);
 			sbuf_printf_uuid(sb, &entry->type_uuid);
-			sbuf_printf(sb, "</type_uuid>\n");
+			sbuf_cat(sb, "</type_uuid>\n");
 		}
 		sbuf_printf(sb, "%s<stor_uuid>", indent);
 		sbuf_printf_uuid(sb, &entry->stor_uuid);
-		sbuf_printf(sb, "</stor_uuid>\n");
+		sbuf_cat(sb, "</stor_uuid>\n");
 	} else {
 		/* confxml: scheme information */
 		table = (struct g_part_bsd64_table *)basetable;
@@ -401,12 +401,12 @@ g_part_bsd64_dumpconf(struct g_part_table *basetable,
 			    indent, (uintmax_t)table->d_abase);
 		sbuf_printf(sb, "%s<stor_uuid>", indent);
 		sbuf_printf_uuid(sb, &table->d_stor_uuid);
-		sbuf_printf(sb, "</stor_uuid>\n");
+		sbuf_cat(sb, "</stor_uuid>\n");
 		sbuf_printf(sb, "%s<label>", indent);
 		strncpy(buf, table->d_packname, sizeof(buf) - 1);
 		buf[sizeof(buf) - 1] = '\0';
-		g_conf_printf_escaped(sb, "%s", buf);
-		sbuf_printf(sb, "</label>\n");
+		g_conf_cat_escaped(sb, buf);
+		sbuf_cat(sb, "</label>\n");
 	}
 }
 

Modified: head/sys/geom/part/g_part_gpt.c
==============================================================================
--- head/sys/geom/part/g_part_gpt.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/part/g_part_gpt.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -713,14 +713,14 @@ g_part_gpt_dumpconf(struct g_part_table *table, struct
 	entry = (struct g_part_gpt_entry *)baseentry;
 	if (indent == NULL) {
 		/* conftxt: libdisk compatibility */
-		sbuf_printf(sb, " xs GPT xt ");
+		sbuf_cat(sb, " xs GPT xt ");
 		sbuf_printf_uuid(sb, &entry->ent.ent_type);
 	} else if (entry != NULL) {
 		/* confxml: partition entry information */
 		sbuf_printf(sb, "%s<label>", indent);
 		g_gpt_printf_utf16(sb, entry->ent.ent_name,
 		    sizeof(entry->ent.ent_name) >> 1);
-		sbuf_printf(sb, "</label>\n");
+		sbuf_cat(sb, "</label>\n");
 		if (entry->ent.ent_attr & GPT_ENT_ATTR_BOOTME)
 			sbuf_printf(sb, "%s<attrib>bootme</attrib>\n", indent);
 		if (entry->ent.ent_attr & GPT_ENT_ATTR_BOOTONCE) {
@@ -733,16 +733,16 @@ g_part_gpt_dumpconf(struct g_part_table *table, struct
 		}
 		sbuf_printf(sb, "%s<rawtype>", indent);
 		sbuf_printf_uuid(sb, &entry->ent.ent_type);
-		sbuf_printf(sb, "</rawtype>\n");
+		sbuf_cat(sb, "</rawtype>\n");
 		sbuf_printf(sb, "%s<rawuuid>", indent);
 		sbuf_printf_uuid(sb, &entry->ent.ent_uuid);
-		sbuf_printf(sb, "</rawuuid>\n");
+		sbuf_cat(sb, "</rawuuid>\n");
 		sbuf_printf(sb, "%s<efimedia>", indent);
 		sbuf_printf(sb, "HD(%d,GPT,", entry->base.gpe_index);
 		sbuf_printf_uuid(sb, &entry->ent.ent_uuid);
 		sbuf_printf(sb, ",%#jx,%#jx)", (intmax_t)entry->base.gpe_start,
 		    (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1));
-		sbuf_printf(sb, "</efimedia>\n");
+		sbuf_cat(sb, "</efimedia>\n");
 	} else {
 		/* confxml: scheme information */
 	}

Modified: head/sys/geom/part/g_part_mbr.c
==============================================================================
--- head/sys/geom/part/g_part_mbr.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/part/g_part_mbr.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -330,7 +330,7 @@ g_part_mbr_dumpconf(struct g_part_table *basetable, st
 		sbuf_printf(sb, "%s<efimedia>HD(%d,MBR,%#08x,%#jx,%#jx)", indent,
 		    entry->base.gpe_index, dsn, (intmax_t)entry->base.gpe_start,
 		    (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1));
-		sbuf_printf(sb, "</efimedia>\n");
+		sbuf_cat(sb, "</efimedia>\n");
 	} else {
 		/* confxml: scheme information */
 	}

Modified: head/sys/geom/raid/g_raid.c
==============================================================================
--- head/sys/geom/raid/g_raid.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/raid/g_raid.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -2372,7 +2372,7 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, s
 				sbuf_printf(sb, "%s ",
 				    g_raid_get_diskname(sd->sd_disk));
 			} else {
-				sbuf_printf(sb, "NONE ");
+				sbuf_cat(sb, "NONE ");
 			}
 			sbuf_printf(sb, "(%s",
 			    g_raid_subdisk_state2str(sd->sd_state));
@@ -2382,11 +2382,11 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, s
 				    (int)(sd->sd_rebuild_pos * 100 /
 				     sd->sd_size));
 			}
-			sbuf_printf(sb, ")");
+			sbuf_cat(sb, ")");
 			if (i + 1 < vol->v_disks_count)
-				sbuf_printf(sb, ", ");
+				sbuf_cat(sb, ", ");
 		}
-		sbuf_printf(sb, "</Subdisks>\n");
+		sbuf_cat(sb, "</Subdisks>\n");
 		sx_xunlock(&sc->sc_lock);
 		g_topology_lock();
 	} else if (cp != NULL) {
@@ -2398,7 +2398,7 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, s
 		sbuf_printf(sb, "%s<State>%s", indent,
 		    g_raid_disk_state2str(disk->d_state));
 		if (!TAILQ_EMPTY(&disk->d_subdisks)) {
-			sbuf_printf(sb, " (");
+			sbuf_cat(sb, " (");
 			TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) {
 				sbuf_printf(sb, "%s",
 				    g_raid_subdisk_state2str(sd->sd_state));
@@ -2409,11 +2409,11 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, s
 					     sd->sd_size));
 				}
 				if (TAILQ_NEXT(sd, sd_next))
-					sbuf_printf(sb, ", ");
+					sbuf_cat(sb, ", ");
 			}
-			sbuf_printf(sb, ")");
+			sbuf_cat(sb, ")");
 		}
-		sbuf_printf(sb, "</State>\n");
+		sbuf_cat(sb, "</State>\n");
 		sbuf_printf(sb, "%s<Subdisks>", indent);
 		TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) {
 			sbuf_printf(sb, "r%d(%s):%d@%ju",
@@ -2421,9 +2421,9 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, s
 			    sd->sd_volume->v_name,
 			    sd->sd_pos, (uintmax_t)sd->sd_offset);
 			if (TAILQ_NEXT(sd, sd_next))
-				sbuf_printf(sb, ", ");
+				sbuf_cat(sb, ", ");
 		}
-		sbuf_printf(sb, "</Subdisks>\n");
+		sbuf_cat(sb, "</Subdisks>\n");
 		sbuf_printf(sb, "%s<ReadErrors>%d</ReadErrors>\n", indent,
 		    disk->d_read_errs);
 		sx_xunlock(&sc->sc_lock);

Modified: head/sys/geom/raid3/g_raid3.c
==============================================================================
--- head/sys/geom/raid3/g_raid3.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/raid3/g_raid3.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -3424,22 +3424,22 @@ g_raid3_dumpconf(struct sbuf *sb, const char *indent, 
 		sx_xlock(&sc->sc_lock);
 		sbuf_printf(sb, "%s<Type>", indent);
 		if (disk->d_no == sc->sc_ndisks - 1)
-			sbuf_printf(sb, "PARITY");
+			sbuf_cat(sb, "PARITY");
 		else
-			sbuf_printf(sb, "DATA");
-		sbuf_printf(sb, "</Type>\n");
+			sbuf_cat(sb, "DATA");
+		sbuf_cat(sb, "</Type>\n");
 		sbuf_printf(sb, "%s<Number>%u</Number>\n", indent,
 		    (u_int)disk->d_no);
 		if (disk->d_state == G_RAID3_DISK_STATE_SYNCHRONIZING) {
 			sbuf_printf(sb, "%s<Synchronized>", indent);
 			if (disk->d_sync.ds_offset == 0)
-				sbuf_printf(sb, "0%%");
+				sbuf_cat(sb, "0%");
 			else {
 				sbuf_printf(sb, "%u%%",
 				    (u_int)((disk->d_sync.ds_offset * 100) /
 				    (sc->sc_mediasize / (sc->sc_ndisks - 1))));
 			}
-			sbuf_printf(sb, "</Synchronized>\n");
+			sbuf_cat(sb, "</Synchronized>\n");
 			if (disk->d_sync.ds_offset > 0) {
 				sbuf_printf(sb, "%s<BytesSynced>%jd"
 				    "</BytesSynced>\n", indent,
@@ -3451,17 +3451,17 @@ g_raid3_dumpconf(struct sbuf *sb, const char *indent, 
 		sbuf_printf(sb, "%s<GenID>%u</GenID>\n", indent, disk->d_genid);
 		sbuf_printf(sb, "%s<Flags>", indent);
 		if (disk->d_flags == 0)
-			sbuf_printf(sb, "NONE");
+			sbuf_cat(sb, "NONE");
 		else {
 			int first = 1;
 
 #define	ADD_FLAG(flag, name)	do {					\
 	if ((disk->d_flags & (flag)) != 0) {				\
 		if (!first)						\
-			sbuf_printf(sb, ", ");				\
+			sbuf_cat(sb, ", ");				\
 		else							\
 			first = 0;					\
-		sbuf_printf(sb, name);					\
+		sbuf_cat(sb, name);					\
 	}								\
 } while (0)
 			ADD_FLAG(G_RAID3_DISK_FLAG_DIRTY, "DIRTY");
@@ -3472,7 +3472,7 @@ g_raid3_dumpconf(struct sbuf *sb, const char *indent, 
 			ADD_FLAG(G_RAID3_DISK_FLAG_BROKEN, "BROKEN");
 #undef	ADD_FLAG
 		}
-		sbuf_printf(sb, "</Flags>\n");
+		sbuf_cat(sb, "</Flags>\n");
 		sbuf_printf(sb, "%s<State>%s</State>\n", indent,
 		    g_raid3_disk_state2str(disk->d_state));
 		sx_xunlock(&sc->sc_lock);
@@ -3505,17 +3505,17 @@ g_raid3_dumpconf(struct sbuf *sb, const char *indent, 
 		sbuf_printf(sb, "%s<GenID>%u</GenID>\n", indent, sc->sc_genid);
 		sbuf_printf(sb, "%s<Flags>", indent);
 		if (sc->sc_flags == 0)
-			sbuf_printf(sb, "NONE");
+			sbuf_cat(sb, "NONE");
 		else {
 			int first = 1;
 
 #define	ADD_FLAG(flag, name)	do {					\
 	if ((sc->sc_flags & (flag)) != 0) {				\
 		if (!first)						\
-			sbuf_printf(sb, ", ");				\
+			sbuf_cat(sb, ", ");				\
 		else							\
 			first = 0;					\
-		sbuf_printf(sb, name);					\
+		sbuf_cat(sb, name);					\
 	}								\
 } while (0)
 			ADD_FLAG(G_RAID3_DEVICE_FLAG_NOFAILSYNC, "NOFAILSYNC");
@@ -3525,7 +3525,7 @@ g_raid3_dumpconf(struct sbuf *sb, const char *indent, 
 			ADD_FLAG(G_RAID3_DEVICE_FLAG_VERIFY, "VERIFY");
 #undef	ADD_FLAG
 		}
-		sbuf_printf(sb, "</Flags>\n");
+		sbuf_cat(sb, "</Flags>\n");
 		sbuf_printf(sb, "%s<Components>%u</Components>\n", indent,
 		    sc->sc_ndisks);
 		sbuf_printf(sb, "%s<State>%s</State>\n", indent,

Modified: head/sys/geom/stripe/g_stripe.c
==============================================================================
--- head/sys/geom/stripe/g_stripe.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/geom/stripe/g_stripe.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -1249,24 +1249,24 @@ g_stripe_dumpconf(struct sbuf *sb, const char *indent,
 		sbuf_printf(sb, "%s<Type>", indent);
 		switch (sc->sc_type) {
 		case G_STRIPE_TYPE_AUTOMATIC:
-			sbuf_printf(sb, "AUTOMATIC");
+			sbuf_cat(sb, "AUTOMATIC");
 			break;
 		case G_STRIPE_TYPE_MANUAL:
-			sbuf_printf(sb, "MANUAL");
+			sbuf_cat(sb, "MANUAL");
 			break;
 		default:
-			sbuf_printf(sb, "UNKNOWN");
+			sbuf_cat(sb, "UNKNOWN");
 			break;
 		}
-		sbuf_printf(sb, "</Type>\n");
+		sbuf_cat(sb, "</Type>\n");
 		sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
 		    indent, sc->sc_ndisks, g_stripe_nvalid(sc));
 		sbuf_printf(sb, "%s<State>", indent);
 		if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
-			sbuf_printf(sb, "UP");
+			sbuf_cat(sb, "UP");
 		else
-			sbuf_printf(sb, "DOWN");
-		sbuf_printf(sb, "</State>\n");
+			sbuf_cat(sb, "DOWN");
+		sbuf_cat(sb, "</State>\n");
 	}
 }
 

Modified: head/sys/kern/kern_uuid.c
==============================================================================
--- head/sys/kern/kern_uuid.c	Wed Jun 19 15:26:52 2019	(r349194)
+++ head/sys/kern/kern_uuid.c	Wed Jun 19 15:36:02 2019	(r349195)
@@ -297,7 +297,7 @@ sbuf_printf_uuid(struct sbuf *sb, struct uuid *uuid)
 	char buf[38];
 
 	snprintf_uuid(buf, sizeof(buf), uuid);
-	return (sbuf_printf(sb, "%s", buf));
+	return (sbuf_cat(sb, buf));
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906191536.x5JFa2EO090757>