git: 519b24f02968 - main - CAM: Replace random sbuf_printf() with cheaper cat/putc.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Wed, 22 Nov 2023 23:04:28 UTC
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=519b24f02968da4930d859288c2f5263c1ad17e1

commit 519b24f02968da4930d859288c2f5263c1ad17e1
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2023-11-22 23:04:05 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2023-11-22 23:04:05 +0000

    CAM: Replace random sbuf_printf() with cheaper cat/putc.
---
 sys/cam/ata/ata_all.c            | 24 +++++++--------
 sys/cam/ata/ata_da.c             |  4 +--
 sys/cam/ata/ata_xpt.c            | 12 ++++----
 sys/cam/cam.c                    |  8 ++---
 sys/cam/cam_periph.c             | 16 +++++-----
 sys/cam/cam_xpt.c                | 16 +++++-----
 sys/cam/ctl/ctl.c                | 48 ++++++++++++++---------------
 sys/cam/ctl/ctl_backend_block.c  |  4 +--
 sys/cam/ctl/ctl_frontend_iscsi.c |  4 +--
 sys/cam/ctl/ctl_scsi_all.c       |  2 +-
 sys/cam/ctl/ctl_util.c           |  2 +-
 sys/cam/mmc/mmc_xpt.c            |  6 ++--
 sys/cam/nvme/nvme_all.c          | 10 +++---
 sys/cam/nvme/nvme_da.c           |  2 +-
 sys/cam/nvme/nvme_xpt.c          |  2 +-
 sys/cam/scsi/scsi_all.c          | 66 ++++++++++++++++++++--------------------
 sys/cam/scsi/scsi_da.c           |  4 +--
 sys/cam/scsi/scsi_enc_ses.c      | 18 +++++------
 sys/cam/scsi/scsi_xpt.c          |  8 ++---
 sys/cam/scsi/smp_all.c           | 14 ++++-----
 20 files changed, 135 insertions(+), 135 deletions(-)

diff --git a/sys/cam/ata/ata_all.c b/sys/cam/ata/ata_all.c
index aff7cafcdbad..f9a2b86f0c06 100644
--- a/sys/cam/ata/ata_all.c
+++ b/sys/cam/ata/ata_all.c
@@ -464,7 +464,7 @@ ata_print_ident_sbuf(struct ata_params *ident_data, struct sbuf *sb)
 	int version;
 
 	ata_print_ident_short_sbuf(ident_data, sb);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 
 	proto = (ident_data->config == ATA_PROTO_CFA) ? "CFA" :
 		(ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA";
@@ -521,11 +521,11 @@ void
 ata_print_ident_short_sbuf(struct ata_params *ident_data, struct sbuf *sb)
 {
 
-	sbuf_printf(sb, "<");
+	sbuf_putc(sb, '<');
 	cam_strvis_sbuf(sb, ident_data->model, sizeof(ident_data->model), 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, ident_data->revision, sizeof(ident_data->revision), 0);
-	sbuf_printf(sb, ">");
+	sbuf_putc(sb, '>');
 }
 
 void
@@ -545,11 +545,11 @@ semb_print_ident_sbuf(struct sep_identify_data *ident_data, struct sbuf *sb)
 
 	semb_print_ident_short_sbuf(ident_data, sb);
 
-	sbuf_printf(sb, " SEMB ");
+	sbuf_cat(sb, " SEMB ");
 	cam_strvis_sbuf(sb, ident_data->interface_id, 6, 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, ident_data->interface_rev, 4, 0);
-	sbuf_printf(sb, " device\n");
+	sbuf_cat(sb, " device\n");
 }
 
 void
@@ -568,15 +568,15 @@ void
 semb_print_ident_short_sbuf(struct sep_identify_data *ident_data, struct sbuf *sb)
 {
 
-	sbuf_printf(sb, "<");
+	sbuf_putc(sb, '<');
 	cam_strvis_sbuf(sb, ident_data->vendor_id, 8, 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, ident_data->product_id, 16, 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, ident_data->product_rev, 4, 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, ident_data->firmware_rev, 4, 0);
-	sbuf_printf(sb, ">");
+	sbuf_putc(sb, '>');
 }
 
 uint32_t
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index caaded5be7ba..ba02f33082b0 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -1447,7 +1447,7 @@ adazonesupsysctl(SYSCTL_HANDLER_ARGS)
 	}
 
 	if (first == 1)
-		sbuf_printf(&sb, "None");
+		sbuf_cat(&sb, "None");
 
 	error = sbuf_finish(&sb);
 	sbuf_delete(&sb);
@@ -1677,7 +1677,7 @@ adaflagssysctl(SYSCTL_HANDLER_ARGS)
 	if (softc->flags != 0)
 		sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, ADA_FLAG_STRING);
 	else
-		sbuf_printf(&sbuf, "0");
+		sbuf_putc(&sbuf, '0');
 	error = sbuf_finish(&sbuf);
 	sbuf_delete(&sbuf);
 
diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c
index 1b759f55ee8a..7bdddc98511b 100644
--- a/sys/cam/ata/ata_xpt.c
+++ b/sys/cam/ata/ata_xpt.c
@@ -2141,33 +2141,33 @@ ata_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
 		struct ccb_trans_settings_pata *pata =
 		    &cts.xport_specific.ata;
 
-		sbuf_printf(sb, " (");
+		sbuf_cat(sb, " (");
 		if (pata->valid & CTS_ATA_VALID_MODE)
 			sbuf_printf(sb, "%s, ", ata_mode2string(pata->mode));
 		if ((pata->valid & CTS_ATA_VALID_ATAPI) && pata->atapi != 0)
 			sbuf_printf(sb, "ATAPI %dbytes, ", pata->atapi);
 		if (pata->valid & CTS_ATA_VALID_BYTECOUNT)
 			sbuf_printf(sb, "PIO %dbytes", pata->bytecount);
-		sbuf_printf(sb, ")");
+		sbuf_putc(sb, ')');
 	}
 	if (cts.transport == XPORT_SATA) {
 		struct ccb_trans_settings_sata *sata =
 		    &cts.xport_specific.sata;
 
-		sbuf_printf(sb, " (");
+		sbuf_cat(sb, " (");
 		if (sata->valid & CTS_SATA_VALID_REVISION)
 			sbuf_printf(sb, "SATA %d.x, ", sata->revision);
 		else
-			sbuf_printf(sb, "SATA, ");
+			sbuf_cat(sb, "SATA, ");
 		if (sata->valid & CTS_SATA_VALID_MODE)
 			sbuf_printf(sb, "%s, ", ata_mode2string(sata->mode));
 		if ((sata->valid & CTS_ATA_VALID_ATAPI) && sata->atapi != 0)
 			sbuf_printf(sb, "ATAPI %dbytes, ", sata->atapi);
 		if (sata->valid & CTS_SATA_VALID_BYTECOUNT)
 			sbuf_printf(sb, "PIO %dbytes", sata->bytecount);
-		sbuf_printf(sb, ")");
+		sbuf_putc(sb, ')');
 	}
-	sbuf_printf(sb, "\n");
+	sbuf_putc(sb, '\n');
 }
 
 static void
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
index 01a5b3c3b36c..d9cff3468da0 100644
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -418,7 +418,7 @@ cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
 			    ccb->ccb_h.func_code);
 			break;
 		}
-		sbuf_printf(&sb, "\n");
+		sbuf_putc(&sb, '\n');
 	}
 
 	if (flags & CAM_ESF_CAM_STATUS) {
@@ -449,13 +449,13 @@ cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
 			if (proto_flags & CAM_EAF_PRINT_STATUS) {
 				sbuf_cat(&sb, path_str);
 				ata_status_sbuf(&ccb->ataio, &sb);
-				sbuf_printf(&sb, "\n");
+				sbuf_putc(&sb, '\n');
 			}
 			if (proto_flags & CAM_EAF_PRINT_RESULT) {
 				sbuf_cat(&sb, path_str);
-				sbuf_printf(&sb, "RES: ");
+				sbuf_cat(&sb, "RES: ");
 				ata_res_sbuf(&ccb->ataio.res, &sb);
-				sbuf_printf(&sb, "\n");
+				sbuf_putc(&sb, '\n');
 			}
 
 			break;
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 165929347a68..920e5f0471c7 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -2139,7 +2139,7 @@ cam_periph_devctl_notify(union ccb *ccb)
 	sbuf_printf(&sb, "device=%s%d ", periph->periph_name,
 	    periph->unit_number);
 
-	sbuf_printf(&sb, "serial=\"");
+	sbuf_cat(&sb, "serial=\"");
 	if ((cgd = (struct ccb_getdev *)xpt_alloc_ccb_nowait()) != NULL) {
 		xpt_setup_ccb(&cgd->ccb_h, ccb->ccb_h.path,
 		    CAM_PRIORITY_NORMAL);
@@ -2150,7 +2150,7 @@ cam_periph_devctl_notify(union ccb *ccb)
 			sbuf_bcat(&sb, cgd->serial_num, cgd->serial_num_len);
 		xpt_free_ccb((union ccb *)cgd);
 	}
-	sbuf_printf(&sb, "\" ");
+	sbuf_cat(&sb, "\" ");
 	sbuf_printf(&sb, "cam_status=\"0x%x\" ", ccb->ccb_h.status);
 
 	switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
@@ -2166,9 +2166,9 @@ cam_periph_devctl_notify(union ccb *ccb)
 		type = "error";
 		break;
 	case CAM_ATA_STATUS_ERROR:
-		sbuf_printf(&sb, "RES=\"");
+		sbuf_cat(&sb, "RES=\"");
 		ata_res_sbuf(&ccb->ataio.res, &sb);
-		sbuf_printf(&sb, "\" ");
+		sbuf_cat(&sb, "\" ");
 		type = "error";
 		break;
 	case CAM_NVME_STATUS_ERROR:
@@ -2189,14 +2189,14 @@ cam_periph_devctl_notify(union ccb *ccb)
 
 	switch (ccb->ccb_h.func_code) {
 	case XPT_SCSI_IO:
-		sbuf_printf(&sb, "CDB=\"");
+		sbuf_cat(&sb, "CDB=\"");
 		scsi_cdb_sbuf(scsiio_cdb_ptr(&ccb->csio), &sb);
-		sbuf_printf(&sb, "\" ");
+		sbuf_cat(&sb, "\" ");
 		break;
 	case XPT_ATA_IO:
-		sbuf_printf(&sb, "ACB=\"");
+		sbuf_cat(&sb, "ACB=\"");
 		ata_cmd_sbuf(&ccb->ataio.cmd, &sb);
-		sbuf_printf(&sb, "\" ");
+		sbuf_cat(&sb, "\" ");
 		break;
 	case XPT_NVME_IO:
 	case XPT_NVME_ADMIN:
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 22d6c89f5b46..de3630c35374 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1150,7 +1150,7 @@ xpt_denounce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
 		    path->device->protocol);
 	if (path->device->serial_num_len > 0)
 		sbuf_printf(sb, " s/n %.60s", path->device->serial_num);
-	sbuf_printf(sb, " detached\n");
+	sbuf_cat(sb, " detached\n");
 }
 
 int
@@ -3713,7 +3713,7 @@ static void
 xpt_device_sbuf(struct cam_ed *device, struct sbuf *sb)
 {
 	if (device == NULL)
-		sbuf_printf(sb, "(nopath): ");
+		sbuf_cat(sb, "(nopath): ");
 	else {
 		sbuf_printf(sb, "(noperiph:%s%d:%d:%d:%jx): ",
 		    device->sim->sim_name,
@@ -3759,31 +3759,31 @@ xpt_path_sbuf(struct cam_path *path, struct sbuf *sb)
 {
 
 	if (path == NULL)
-		sbuf_printf(sb, "(nopath): ");
+		sbuf_cat(sb, "(nopath): ");
 	else {
 		if (path->periph != NULL)
 			sbuf_printf(sb, "(%s%d:", path->periph->periph_name,
 				    path->periph->unit_number);
 		else
-			sbuf_printf(sb, "(noperiph:");
+			sbuf_cat(sb, "(noperiph:");
 
 		if (path->bus != NULL)
 			sbuf_printf(sb, "%s%d:%d:", path->bus->sim->sim_name,
 				    path->bus->sim->unit_number,
 				    path->bus->sim->bus_id);
 		else
-			sbuf_printf(sb, "nobus:");
+			sbuf_cat(sb, "nobus:");
 
 		if (path->target != NULL)
 			sbuf_printf(sb, "%d:", path->target->target_id);
 		else
-			sbuf_printf(sb, "X:");
+			sbuf_cat(sb, "X:");
 
 		if (path->device != NULL)
 			sbuf_printf(sb, "%jx): ",
 			    (uintmax_t)path->device->lun_id);
 		else
-			sbuf_printf(sb, "X): ");
+			sbuf_cat(sb, "X): ");
 	}
 }
 
@@ -5585,7 +5585,7 @@ xpt_cam_debug(const char *fmt, ...)
 	va_list ap;
 
 	sbuf_set_drain(sb, sbuf_printf_drain, NULL);
-	sbuf_printf(sb, "cam_debug: ");
+	sbuf_cat(sb, "cam_debug: ");
 	va_start(ap, fmt);
 	sbuf_vprintf(sb, fmt, ap);
 	va_end(ap);
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 7ad7912ef323..3d6eb0382cc9 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -2534,13 +2534,13 @@ ctl_sbuf_printf_esc(struct sbuf *sb, char *str, int size)
 	for (; *str && str < end; str++) {
 		switch (*str) {
 		case '&':
-			retval = sbuf_printf(sb, "&amp;");
+			retval = sbuf_cat(sb, "&amp;");
 			break;
 		case '>':
-			retval = sbuf_printf(sb, "&gt;");
+			retval = sbuf_cat(sb, "&gt;");
 			break;
 		case '<':
-			retval = sbuf_printf(sb, "&lt;");
+			retval = sbuf_cat(sb, "&lt;");
 			break;
 		default:
 			retval = sbuf_putc(sb, *str);
@@ -2565,13 +2565,13 @@ ctl_id_sbuf(struct ctl_devid *id, struct sbuf *sb)
 	desc = (struct scsi_vpd_id_descriptor *)id->data;
 	switch (desc->id_type & SVPD_ID_TYPE_MASK) {
 	case SVPD_ID_TYPE_T10:
-		sbuf_printf(sb, "t10.");
+		sbuf_cat(sb, "t10.");
 		break;
 	case SVPD_ID_TYPE_EUI64:
-		sbuf_printf(sb, "eui.");
+		sbuf_cat(sb, "eui.");
 		break;
 	case SVPD_ID_TYPE_NAA:
-		sbuf_printf(sb, "naa.");
+		sbuf_cat(sb, "naa.");
 		break;
 	case SVPD_ID_TYPE_SCSI_NAME:
 		break;
@@ -2586,7 +2586,7 @@ ctl_id_sbuf(struct ctl_devid *id, struct sbuf *sb)
 		    (char *)desc->identifier);
 		break;
 	case SVPD_ID_CODESET_UTF8:
-		sbuf_printf(sb, "%s", (char *)desc->identifier);
+		sbuf_cat(sb, (char *)desc->identifier);
 		break;
 	}
 }
@@ -3088,7 +3088,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			break;
 		}
 
-		sbuf_printf(sb, "<ctllunlist>\n");
+		sbuf_cat(sb, "<ctllunlist>\n");
 
 		mtx_lock(&softc->ctl_lock);
 		STAILQ_FOREACH(lun, &softc->lun_list, links) {
@@ -3118,7 +3118,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 				break;
 
 			if (lun->backend == NULL) {
-				retval = sbuf_printf(sb, "</lun>\n");
+				retval = sbuf_cat(sb, "</lun>\n");
 				if (retval != 0)
 					break;
 				continue;
@@ -3137,7 +3137,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			if (retval != 0)
 				break;
 
-			retval = sbuf_printf(sb, "\t<serial_number>");
+			retval = sbuf_cat(sb, "\t<serial_number>");
 
 			if (retval != 0)
 				break;
@@ -3149,12 +3149,12 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			if (retval != 0)
 				break;
 
-			retval = sbuf_printf(sb, "</serial_number>\n");
+			retval = sbuf_cat(sb, "</serial_number>\n");
 		
 			if (retval != 0)
 				break;
 
-			retval = sbuf_printf(sb, "\t<device_id>");
+			retval = sbuf_cat(sb, "\t<device_id>");
 
 			if (retval != 0)
 				break;
@@ -3166,7 +3166,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			if (retval != 0)
 				break;
 
-			retval = sbuf_printf(sb, "</device_id>\n");
+			retval = sbuf_cat(sb, "</device_id>\n");
 
 			if (retval != 0)
 				break;
@@ -3186,13 +3186,13 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 					value = dnvlist_get_string(
 					    lun->be_lun->options, name, NULL);
 					if (value != NULL)
-						sbuf_printf(sb, "%s", value);
+						sbuf_cat(sb, value);
 				}
 
 				sbuf_printf(sb, "</%s>\n", name);
 			}
 
-			retval = sbuf_printf(sb, "</lun>\n");
+			retval = sbuf_cat(sb, "</lun>\n");
 
 			if (retval != 0)
 				break;
@@ -3203,7 +3203,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 		mtx_unlock(&softc->ctl_lock);
 
 		if ((retval != 0)
-		 || ((retval = sbuf_printf(sb, "</ctllunlist>\n")) != 0)) {
+		 || ((retval = sbuf_cat(sb, "</ctllunlist>\n")) != 0)) {
 			retval = 0;
 			sbuf_delete(sb);
 			list->status = CTL_LUN_LIST_NEED_MORE_SPACE;
@@ -3353,7 +3353,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			break;
 		}
 
-		sbuf_printf(sb, "<ctlportlist>\n");
+		sbuf_cat(sb, "<ctlportlist>\n");
 
 		mtx_lock(&softc->ctl_lock);
 		STAILQ_FOREACH(port, &softc->port_list, links) {
@@ -3398,15 +3398,15 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 				break;
 
 			if (port->target_devid != NULL) {
-				sbuf_printf(sb, "\t<target>");
+				sbuf_cat(sb, "\t<target>");
 				ctl_id_sbuf(port->target_devid, sb);
-				sbuf_printf(sb, "</target>\n");
+				sbuf_cat(sb, "</target>\n");
 			}
 
 			if (port->port_devid != NULL) {
-				sbuf_printf(sb, "\t<port>");
+				sbuf_cat(sb, "\t<port>");
 				ctl_id_sbuf(port->port_devid, sb);
-				sbuf_printf(sb, "</port>\n");
+				sbuf_cat(sb, "</port>\n");
 			}
 
 			if (port->port_info != NULL) {
@@ -3431,7 +3431,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			}
 
 			if (port->lun_map != NULL) {
-				sbuf_printf(sb, "\t<lun_map>on</lun_map>\n");
+				sbuf_cat(sb, "\t<lun_map>on</lun_map>\n");
 				for (j = 0; j < port->lun_map_size; j++) {
 					plun = ctl_lun_map_from_port(port, j);
 					if (plun == UINT32_MAX)
@@ -3462,14 +3462,14 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 			if (retval != 0)
 				break;
 
-			retval = sbuf_printf(sb, "</targ_port>\n");
+			retval = sbuf_cat(sb, "</targ_port>\n");
 			if (retval != 0)
 				break;
 		}
 		mtx_unlock(&softc->ctl_lock);
 
 		if ((retval != 0)
-		 || ((retval = sbuf_printf(sb, "</ctlportlist>\n")) != 0)) {
+		 || ((retval = sbuf_cat(sb, "</ctlportlist>\n")) != 0)) {
 			retval = 0;
 			sbuf_delete(sb);
 			list->status = CTL_LUN_LIST_NEED_MORE_SPACE;
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index 4b8ea04cca27..7381202e2c54 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -2826,13 +2826,13 @@ ctl_be_block_lun_info(struct ctl_be_lun *cbe_lun, struct sbuf *sb)
 	struct ctl_be_block_lun *lun = (struct ctl_be_block_lun *)cbe_lun;
 	int retval;
 
-	retval = sbuf_printf(sb, "\t<num_threads>");
+	retval = sbuf_cat(sb, "\t<num_threads>");
 	if (retval != 0)
 		goto bailout;
 	retval = sbuf_printf(sb, "%d", lun->num_threads);
 	if (retval != 0)
 		goto bailout;
-	retval = sbuf_printf(sb, "</num_threads>\n");
+	retval = sbuf_cat(sb, "</num_threads>\n");
 
 bailout:
 	return (retval);
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 019026d78d67..fe3b1a943206 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -1721,7 +1721,7 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
 		return;
 	}
 
-	sbuf_printf(sb, "<ctlislist>\n");
+	sbuf_cat(sb, "<ctlislist>\n");
 	mtx_lock(&softc->lock);
 	TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
 		if (cs->cs_target == NULL)
@@ -1760,7 +1760,7 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
 			break;
 	}
 	mtx_unlock(&softc->lock);
-	error = sbuf_printf(sb, "</ctlislist>\n");
+	error = sbuf_cat(sb, "</ctlislist>\n");
 	if (error != 0) {
 		sbuf_delete(sb);
 		ci->status = CTL_ISCSI_LIST_NEED_MORE_SPACE;
diff --git a/sys/cam/ctl/ctl_scsi_all.c b/sys/cam/ctl/ctl_scsi_all.c
index d712377e3389..5c55907cb27c 100644
--- a/sys/cam/ctl/ctl_scsi_all.c
+++ b/sys/cam/ctl/ctl_scsi_all.c
@@ -137,7 +137,7 @@ ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio,
 
 		ctl_scsi_command_string(ctsio, inq_data, sb);
 
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 	}
 
 	scsi_sense_only_sbuf(&ctsio->sense_data, ctsio->sense_len, sb,
diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c
index 3b0e40311213..76f4aff6bb3d 100644
--- a/sys/cam/ctl/ctl_util.c
+++ b/sys/cam/ctl/ctl_util.c
@@ -755,7 +755,7 @@ ctl_io_sbuf(union ctl_io *io, struct sbuf *sb)
 			    io->taskio.tag_num, io->taskio.tag_type);
 			break;
 		default:
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 			break;
 		}
 		break;
diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c
index c8b57c2d8d86..0947e0addf59 100644
--- a/sys/cam/mmc/mmc_xpt.c
+++ b/sys/cam/mmc/mmc_xpt.c
@@ -428,9 +428,9 @@ mmc_print_ident(struct mmc_params *ident_data, struct sbuf *sb)
 	bool space = false;
 
 	sbuf_printf(sb, "Relative addr: %08x\n", ident_data->card_rca);
-	sbuf_printf(sb, "Card features: <");
+	sbuf_cat(sb, "Card features: <");
 	if (ident_data->card_features & CARD_FEATURE_MMC) {
-		sbuf_printf(sb, "MMC");
+		sbuf_cat(sb, "MMC");
 		space = true;
 	}
 	if (ident_data->card_features & CARD_FEATURE_MEMORY) {
@@ -452,7 +452,7 @@ mmc_print_ident(struct mmc_params *ident_data, struct sbuf *sb)
 	if (ident_data->card_features & CARD_FEATURE_18V) {
 		sbuf_printf(sb, "%s1.8-Signaling", space ? " " : "");
 	}
-	sbuf_printf(sb, ">\n");
+	sbuf_cat(sb, ">\n");
 
 	if (ident_data->card_features & CARD_FEATURE_MEMORY)
 		sbuf_printf(sb, "Card memory OCR: %08x\n",
diff --git a/sys/cam/nvme/nvme_all.c b/sys/cam/nvme/nvme_all.c
index 7f0878c0f288..a3c3d676b349 100644
--- a/sys/cam/nvme/nvme_all.c
+++ b/sys/cam/nvme/nvme_all.c
@@ -87,23 +87,23 @@ nvme_print_ident(const struct nvme_controller_data *cdata,
     const struct nvme_namespace_data *data, struct sbuf *sb)
 {
 	nvme_print_ident_short(cdata, data, sb);
-	sbuf_printf(sb, "\n");
+	sbuf_putc(sb, '\n');
 }
 
 void
 nvme_print_ident_short(const struct nvme_controller_data *cdata,
     const struct nvme_namespace_data *data, struct sbuf *sb)
 {
-	sbuf_printf(sb, "<");
+	sbuf_putc(sb, '<');
 	cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn),
 	    CAM_STRVIS_FLAG_NONASCII_SPC);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr),
 	    CAM_STRVIS_FLAG_NONASCII_SPC);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn),
 	    CAM_STRVIS_FLAG_NONASCII_SPC);
-	sbuf_printf(sb, ">");
+	sbuf_putc(sb, '>');
 }
 
 /* XXX need to do nvme admin opcodes too, but those aren't used yet by nda */
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 89984e3aaf36..73c385b2fe1c 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -810,7 +810,7 @@ ndaflagssysctl(SYSCTL_HANDLER_ARGS)
 	if (softc->flags != 0)
 		sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, NDA_FLAG_STRING);
 	else
-		sbuf_printf(&sbuf, "0");
+		sbuf_putc(&sbuf, '0');
 	error = sbuf_finish(&sbuf);
 	sbuf_delete(&sbuf);
 
diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c
index 8b9fbcd21291..86127aca7b0f 100644
--- a/sys/cam/nvme/nvme_xpt.c
+++ b/sys/cam/nvme/nvme_xpt.c
@@ -814,7 +814,7 @@ nvme_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
 			    nvmex->lanes, nvmex->max_lanes,
 			    nvmex->speed, nvmex->max_speed);
 	}
-	sbuf_printf(sb, "\n");
+	sbuf_putc(sb, '\n');
 }
 
 static void
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 7cc323595566..07295f313cca 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -4570,9 +4570,9 @@ scsi_stream_sbuf(struct sbuf *sb, uint8_t stream_bits)
 	/*
 	 * XXX KDM this needs more descriptive decoding.
 	 */
-	sbuf_printf(sb, "Stream Command Sense Data: ");
+	sbuf_cat(sb, "Stream Command Sense Data: ");
 	if (stream_bits & SSD_DESC_STREAM_FM) {
-		sbuf_printf(sb, "Filemark");
+		sbuf_cat(sb, "Filemark");
 		need_comma = 1;
 	}
 
@@ -4589,9 +4589,9 @@ void
 scsi_block_sbuf(struct sbuf *sb, uint8_t block_bits)
 {
 
-	sbuf_printf(sb, "Block Command Sense Data: ");
+	sbuf_cat(sb, "Block Command Sense Data: ");
 	if (block_bits & SSD_DESC_BLOCK_ILI)
-		sbuf_printf(sb, "ILI");
+		sbuf_cat(sb, "ILI");
 }
 
 void
@@ -4925,7 +4925,7 @@ scsi_print_desc_func(struct scsi_sense_data_desc *sense, u_int sense_len,
 				     (struct scsi_sense_data *)sense, sense_len,
 				     print_info->cdb, print_info->cdb_len,
 				     print_info->inq_data, header);
-		sbuf_printf(print_info->sb, "\n");
+		sbuf_putc(print_info->sb, '\n');
 		break;
 	}
 	}
@@ -4950,11 +4950,11 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 	scsi_extract_sense_len(sense, sense_len, &error_code, &sense_key,
 			       &asc, &ascq, /*show_errors*/ 1);
 
-	sbuf_printf(sb, "SCSI sense: ");
+	sbuf_cat(sb, "SCSI sense: ");
 	switch (error_code) {
 	case SSD_DEFERRED_ERROR:
 	case SSD_DESC_DEFERRED_ERROR:
-		sbuf_printf(sb, "Deferred error: ");
+		sbuf_cat(sb, "Deferred error: ");
 
 		/* FALLTHROUGH */
 	case SSD_CURRENT_ERROR:
@@ -4991,12 +4991,12 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 		    &bits) == 0 && bits != 0) {
 			sbuf_cat(sb, path_str);
 			scsi_block_sbuf(sb, bits);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		} else if (scsi_get_stream_info(sense, sense_len, inq_data,
 		    &bits) == 0 && bits != 0) {
 			sbuf_cat(sb, path_str);
 			scsi_stream_sbuf(sb, bits);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		}
 
 		/*
@@ -5006,7 +5006,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 					&val, NULL) == 0) {
 			sbuf_cat(sb, path_str);
 			scsi_info_sbuf(sb, cdb, cdb_len, inq_data, val);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		}
 
 		/*
@@ -5016,7 +5016,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 					&val, NULL) == 0) {
 			sbuf_cat(sb, path_str);
 			scsi_fru_sbuf(sb, val);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		}
 
 		/*
@@ -5026,7 +5026,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 					&val, NULL) == 0) {
 			sbuf_cat(sb, path_str);
 			scsi_command_sbuf(sb, cdb, cdb_len, inq_data, val);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		}
 
 		/*
@@ -5035,7 +5035,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 		if (scsi_get_sks(sense, sense_len, sks) == 0) {
 			sbuf_cat(sb, path_str);
 			scsi_sks_sbuf(sb, sense_key, sks);
-			sbuf_printf(sb, "\n");
+			sbuf_putc(sb, '\n');
 		}
 
 		/*
@@ -5067,7 +5067,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 		 * show_errors flag is set and they aren't present in the
 		 * sense data.  This means that sense_len is 0.
 		 */
-		sbuf_printf(sb, "No sense data present\n");
+		sbuf_cat(sb, "No sense data present\n");
 		break;
 	default: {
 		sbuf_printf(sb, "Error code 0x%x", error_code);
@@ -5085,7 +5085,7 @@ scsi_sense_only_sbuf(struct scsi_sense_data *sense, u_int sense_len,
 					    info);
 			}
 		}
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 		break;
 	}
 	}
@@ -5167,7 +5167,7 @@ scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
 #else /* !_KERNEL */
 		scsi_command_string(device, csio, sb);
 #endif /* _KERNEL/!_KERNEL */
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 	}
 
 	/*
@@ -5541,7 +5541,7 @@ scsi_print_inquiry_sbuf(struct sbuf *sb, struct scsi_inquiry_data *inq_data)
 	sbuf_printf(sb, "%s %s ", SID_IS_REMOVABLE(inq_data) ? "Removable" : "Fixed", dtype);
 
 	if (SID_ANSI_REV(inq_data) == SCSI_REV_0)
-		sbuf_printf(sb, "SCSI ");
+		sbuf_cat(sb, "SCSI ");
 	else if (SID_ANSI_REV(inq_data) <= SCSI_REV_SPC) {
 		sbuf_printf(sb, "SCSI-%d ", SID_ANSI_REV(inq_data));
 	} else {
@@ -5566,13 +5566,13 @@ void
 scsi_print_inquiry_short_sbuf(struct sbuf *sb, struct scsi_inquiry_data *inq_data)
 {
 
-	sbuf_printf(sb, "<");
+	sbuf_putc(sb, '<');
 	cam_strvis_sbuf(sb, inq_data->vendor, sizeof(inq_data->vendor), 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, inq_data->product, sizeof(inq_data->product), 0);
-	sbuf_printf(sb, " ");
+	sbuf_putc(sb, ' ');
 	cam_strvis_sbuf(sb, inq_data->revision, sizeof(inq_data->revision), 0);
-	sbuf_printf(sb, "> ");
+	sbuf_cat(sb, "> ");
 }
 
 void
@@ -5872,7 +5872,7 @@ scsi_transportid_sbuf(struct sbuf *sb, struct scsi_transportid_header *hdr,
 
 		rdma = (struct scsi_transportid_rdma *)hdr;
 
-		sbuf_printf(sb, "RDMA address: 0x");
+		sbuf_cat(sb, "RDMA address: 0x");
 		for (i = 0; i < sizeof(rdma->initiator_port_id); i++)
 			sbuf_printf(sb, "%02x", rdma->initiator_port_id[i]);
 		break;
@@ -5882,7 +5882,7 @@ scsi_transportid_sbuf(struct sbuf *sb, struct scsi_transportid_header *hdr,
 		uint8_t *iscsi_name = NULL;
 		int nul_found = 0;
 
-		sbuf_printf(sb, "iSCSI address: ");
+		sbuf_cat(sb, "iSCSI address: ");
 		if ((hdr->format_protocol & SCSI_TRN_FORMAT_MASK) ==
 		    SCSI_TRN_ISCSI_FORMAT_DEVICE) {
 			struct scsi_transportid_iscsi_device *dev;
@@ -5917,7 +5917,7 @@ scsi_transportid_sbuf(struct sbuf *sb, struct scsi_transportid_header *hdr,
 			break;
 		}
 		if (add_len == 0) {
-			sbuf_printf(sb, "not enough data");
+			sbuf_cat(sb, "not enough data");
 			break;
 		}
 		/*
@@ -7083,7 +7083,7 @@ scsi_attrib_volcoh_sbuf(struct sbuf *sb, struct scsi_mam_attribute_header *hdr,
 	vcr_len = *cur_ptr;
 	cur_ptr++;
 
-	sbuf_printf(sb, "\n\tVolume Change Reference Value:");
+	sbuf_cat(sb, "\n\tVolume Change Reference Value:");
 
 	switch (vcr_len) {
 	case 0:
@@ -7110,7 +7110,7 @@ scsi_attrib_volcoh_sbuf(struct sbuf *sb, struct scsi_mam_attribute_header *hdr,
 		tmp_val = scsi_8btou64(cur_ptr);
 		break;
 	default:
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 		sbuf_hexdump(sb, cur_ptr, vcr_len, NULL, 0);
 		break;
 	}
@@ -7133,11 +7133,11 @@ scsi_attrib_volcoh_sbuf(struct sbuf *sb, struct scsi_mam_attribute_header *hdr,
 	cur_ptr += sizeof(tmp_val);
 	as_len = scsi_2btoul(cur_ptr);
 	cur_ptr += sizeof(uint16_t);
-	sbuf_printf(sb, "\tApplication Client Specific Information: ");
+	sbuf_cat(sb, "\tApplication Client Specific Information: ");
 	if (((as_len == SCSI_LTFS_VER0_LEN)
 	  || (as_len == SCSI_LTFS_VER1_LEN))
 	 && (strncmp(cur_ptr, SCSI_LTFS_STR_NAME, SCSI_LTFS_STR_LEN) == 0)) {
-		sbuf_printf(sb, "LTFS\n");
+		sbuf_cat(sb, "LTFS\n");
 		cur_ptr += SCSI_LTFS_STR_LEN + 1;
 		if (cur_ptr[SCSI_LTFS_UUID_LEN] != '\0')
 			cur_ptr[SCSI_LTFS_UUID_LEN] = '\0';
@@ -7146,7 +7146,7 @@ scsi_attrib_volcoh_sbuf(struct sbuf *sb, struct scsi_mam_attribute_header *hdr,
 		/* XXX KDM check the length */
 		sbuf_printf(sb, "\tLTFS Version: %d\n", *cur_ptr);
 	} else {
-		sbuf_printf(sb, "Unknown\n");
+		sbuf_cat(sb, "Unknown\n");
 		sbuf_hexdump(sb, cur_ptr, as_len, NULL, 0);
 	}
 
@@ -7232,7 +7232,7 @@ scsi_attrib_hexdump_sbuf(struct sbuf *sb, struct scsi_mam_attribute_header *hdr,
 	num_ptr = hdr->attribute;
 
 	if (print_len > 0) {
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 		sbuf_hexdump(sb, num_ptr, print_len, NULL, 0);
 	}
 
@@ -7525,7 +7525,7 @@ scsi_attrib_prefix_sbuf(struct sbuf *sb, uint32_t output_flags,
 
 	if ((output_flags & SCSI_ATTR_OUTPUT_FIELD_DESC)
 	 && (desc != NULL)) {
-		sbuf_printf(sb, "%s", desc);
+		sbuf_cat(sb, desc);
 		need_space = 1;
 	}
 
@@ -7542,7 +7542,7 @@ scsi_attrib_prefix_sbuf(struct sbuf *sb, uint32_t output_flags,
 		sbuf_printf(sb, "%s(%s)", (need_space) ? " " : "",
 			    (hdr->byte2 & SMA_READ_ONLY) ? "RO" : "RW");
 	}
-	sbuf_printf(sb, ": ");
+	sbuf_cat(sb, ": ");
 }
 
 int
@@ -7620,7 +7620,7 @@ bailout:
 			sbuf_printf(sb, " %s", entry->suffix);
 
 		sbuf_trim(sb);
-		sbuf_printf(sb, "\n");
+		sbuf_putc(sb, '\n');
 	}
 
 	return (retval);
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 175774d83015..35bfd096f3e1 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -2664,7 +2664,7 @@ daflagssysctl(SYSCTL_HANDLER_ARGS)
 	if (softc->flags != 0)
 		sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, DA_FLAG_STRING);
 	else
-		sbuf_printf(&sbuf, "0");
+		sbuf_putc(&sbuf, '0');
 	error = sbuf_finish(&sbuf);
 	sbuf_delete(&sbuf);
 
@@ -2756,7 +2756,7 @@ dazonesupsysctl(SYSCTL_HANDLER_ARGS)
 	}
 
 	if (first == 1)
-		sbuf_printf(&sb, "None");
+		sbuf_cat(&sb, "None");
 
 	error = sbuf_finish(&sb);
 	sbuf_delete(&sb);
diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c
index e122e0d0e0d9..0a3136aa8d10 100644
--- a/sys/cam/scsi/scsi_enc_ses.c
+++ b/sys/cam/scsi/scsi_enc_ses.c
@@ -2268,12 +2268,12 @@ ses_get_elm_addlstatus_fc(enc_softc_t *enc, enc_cache_t *enc_cache,
 	if (((p) & SES_SASOBJ_DEV_PHY_PROTOMASK) != 0) {		\
 		sbuf_printf(sbp, " %s (", type);			\
 		if ((p) & SES_SASOBJ_DEV_PHY_SMP)			\
-			sbuf_printf(sbp, " SMP");			\
+			sbuf_cat(sbp, " SMP");				\
 		if ((p) & SES_SASOBJ_DEV_PHY_STP)			\
-			sbuf_printf(sbp, " STP");			\
+			sbuf_cat(sbp, " STP");				\
 		if ((p) & SES_SASOBJ_DEV_PHY_SSP)			\
-			sbuf_printf(sbp, " SSP");			\
-		sbuf_printf(sbp, " )");					\
+			sbuf_cat(sbp, " SSP");				\
+		sbuf_cat(sbp, " )");					\
 	}								\
 } while(0)
 
@@ -2302,7 +2302,7 @@ ses_print_addl_data_sas_type0(char *sesname, struct sbuf *sbp,
 	if (ses_elm_addlstatus_eip(addl->hdr))
 		sbuf_printf(sbp, " at slot %d",
 		    addl->proto_hdr.sas->type0_eip.dev_slot_num);
-	sbuf_printf(sbp, "\n");
+	sbuf_putc(sbp, '\n');
 	if (addl->proto_data.sasdev_phys == NULL)
 		return;
 	for (i = 0;i < addl->proto_hdr.sas->base_hdr.num_phys;i++) {
@@ -2310,13 +2310,13 @@ ses_print_addl_data_sas_type0(char *sesname, struct sbuf *sbp,
 		sbuf_printf(sbp, "%s:  phy %d:", sesname, i);
 		if (ses_elm_sas_dev_phy_sata_dev(phy))
 			/* Spec says all other fields are specific values */
-			sbuf_printf(sbp, " SATA device\n");
+			sbuf_cat(sbp, " SATA device\n");
 		else {
 			sbuf_printf(sbp, " SAS device type %d phy %d",
 			    ses_elm_sas_dev_phy_dev_type(phy), phy->phy_id);
 			SES_PRINT_PORTS(phy->initiator_ports, "Initiator");
 			SES_PRINT_PORTS(phy->target_ports, "Target");
-			sbuf_printf(sbp, "\n");
+			sbuf_putc(sbp, '\n');
 		}
 		sbuf_printf(sbp, "%s:  phy %d: parent %jx addr %jx\n",
 		    sesname, i,
@@ -2346,7 +2346,7 @@ ses_print_addl_data_sas_type1(char *sesname, struct sbuf *sbp,
 
 	elmpriv = obj->elm_private;
 	addl = &(elmpriv->addl);
-	sbuf_printf(sbp, ", SAS ");
+	sbuf_cat(sbp, ", SAS ");
 	if (obj->elm_type == ELMTYP_SAS_EXP) {
 		num_phys = addl->proto_hdr.sas->base_hdr.num_phys;
 		sbuf_printf(sbp, "Expander: %d phys", num_phys);
@@ -2419,7 +2419,7 @@ ses_print_addl_data(enc_softc_t *enc, enc_element_t *obj)
 	sbuf_new(&out, NULL, 512, SBUF_AUTOEXTEND);
 	ses_paths_iter(enc, obj, ses_elmdevname_callback, &name);
 	if (sbuf_len(&name) == 0)
*** 101 LINES SKIPPED ***