From nobody Wed Nov 22 20:33:55 2023 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 4SbCdH39kkz51r3p; Wed, 22 Nov 2023 20:33:55 +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 4SbCdH2kLLz4VRD; Wed, 22 Nov 2023 20:33:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700685235; 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=jCGo3lipq/ixRQWmFs3RmlO8TuyseXNdn+h5WbuhLFE=; b=KXpH/Qil6/33FPaYsVYTpZapqE/BA78A5b2uQmXEDMeuLGM3EbKKA068Tvqoo8cD92mtce aCM1gEp/Jj5YlEs09kzwG6qAK6mwehBXrTmjfv5PeGXjq0Oq4Aq4TCbZX5CgtAr2IeSOt3 o7DGTd6YOalwjMuox7vu2vZMAEP3qvkPAQaU0MBy2xy20EYQh9KeSP7A8Tx2WfdV+SvCVC kp1OpLLIwwxyGnq1WuWmtqMuzaE9B1gj0wdNauRisEsAauLV64N2usqrukdsQuSJCCIxek h+VThtxxeBEWv93VXU2UIZYs75sp5vd8uX0TbKtrEVPJFcI+HVN1k9xdHJkOqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700685235; 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=jCGo3lipq/ixRQWmFs3RmlO8TuyseXNdn+h5WbuhLFE=; b=PZAqnuJpJIUlxSviHTUcXFeRY8lGlvCIKLWWX0OeP4rW7lbcdliq9a+DciFmlZkbyHrwCY N9F7kHvsJ//ICewjKEn6xLIO3g9hC1fl5+1GeFngZs7sHcsj+O7uZ6nFnDtkHfQ7Mfss9H lEBuqKxJkjPo814bRExitEojycQbcf4xUPWib+2DeinJ3CX143pBJ6C5RAkC53LSz8exnU AYMzSPZH3KBz0hewegA/mhiS7BXkV7TnawFaXnMCI1RNyGlCi+pvWtR5e4BMv5SwIqt7n/ RJuVijhsZWTlEN6P4drDNfytRyaLP0pwKrkW9rZqT1BjLnSDKXGqKgN46hwHNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700685235; a=rsa-sha256; cv=none; b=SBIBlaRumTGneGAYd+oQenPsLPzC71rvoXy/J5qIVTVVUEcqOUsG3S8sfwrZ4g27f2b6sV vyjyewcbsPprB6TC6XNwSx3g6jXCRIUvMDVvAQIEjrGPT9swhx901vHz/HU41DFkwmVxvb wCoWLbb2/YMcEFF//9BEnkP2cNbWuOGnLYDE/ckyeX8NvloSg5d1cu3y6B/HV6GAT8qMgl gt/l/9YXNdoJbujpIH9jUsSkxdcP6mMRJ9cFZfm24pRNXyDw82ed/uTZzJanfUYGUPUy4o LwstwTU0khRVCWQwEhfFw2FuWDzpiqpXhsSU+z4orDVsI4zc1tv2FKX6iG3/bA== 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 4SbCdH1VbgzZ8t; Wed, 22 Nov 2023 20:33:55 +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 3AMKXt5B053251; Wed, 22 Nov 2023 20:33:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AMKXtqM053248; Wed, 22 Nov 2023 20:33:55 GMT (envelope-from git) Date: Wed, 22 Nov 2023 20:33:55 GMT Message-Id: <202311222033.3AMKXtqM053248@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 1b44079584dc - main - CAM: Use sbuf_new_for_sysctl() in more places 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b44079584dc317230cf810c0fe0a8c401a5c791 Auto-Submitted: auto-generated The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=1b44079584dc317230cf810c0fe0a8c401a5c791 commit 1b44079584dc317230cf810c0fe0a8c401a5c791 Author: Alexander Motin AuthorDate: 2023-11-22 20:32:16 +0000 Commit: Alexander Motin CommitDate: 2023-11-22 20:33:48 +0000 CAM: Use sbuf_new_for_sysctl() in more places There is no need to allocate buffer, worry about overflows, etc. MFC after: 2 weeks --- sys/cam/ata/ata_da.c | 12 ++++-------- sys/cam/scsi/scsi_da.c | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index db2dc3a23b34..caaded5be7ba 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1425,7 +1425,6 @@ adazonemodesysctl(SYSCTL_HANDLER_ARGS) static int adazonesupsysctl(SYSCTL_HANDLER_ARGS) { - char tmpbuf[180]; struct ada_softc *softc; struct sbuf sb; int error, first; @@ -1433,15 +1432,14 @@ adazonesupsysctl(SYSCTL_HANDLER_ARGS) softc = (struct ada_softc *)arg1; - error = 0; first = 1; - sbuf_new(&sb, tmpbuf, sizeof(tmpbuf), 0); + sbuf_new_for_sysctl(&sb, NULL, 0, req); for (i = 0; i < sizeof(ada_zone_desc_table) / sizeof(ada_zone_desc_table[0]); i++) { if (softc->zone_flags & ada_zone_desc_table[i].value) { if (first == 0) - sbuf_printf(&sb, ", "); + sbuf_cat(&sb, ", "); else first = 0; sbuf_cat(&sb, ada_zone_desc_table[i].desc); @@ -1451,10 +1449,8 @@ adazonesupsysctl(SYSCTL_HANDLER_ARGS) if (first == 1) sbuf_printf(&sb, "None"); - sbuf_finish(&sb); - - error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); - + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index e795cecb5d11..175774d83015 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2734,7 +2734,6 @@ dazonemodesysctl(SYSCTL_HANDLER_ARGS) static int dazonesupsysctl(SYSCTL_HANDLER_ARGS) { - char tmpbuf[180]; struct da_softc *softc; struct sbuf sb; int error, first; @@ -2742,15 +2741,14 @@ dazonesupsysctl(SYSCTL_HANDLER_ARGS) softc = (struct da_softc *)arg1; - error = 0; first = 1; - sbuf_new(&sb, tmpbuf, sizeof(tmpbuf), 0); + sbuf_new_for_sysctl(&sb, NULL, 0, req); for (i = 0; i < sizeof(da_zone_desc_table) / sizeof(da_zone_desc_table[0]); i++) { if (softc->zone_flags & da_zone_desc_table[i].value) { if (first == 0) - sbuf_printf(&sb, ", "); + sbuf_cat(&sb, ", "); else first = 0; sbuf_cat(&sb, da_zone_desc_table[i].desc); @@ -2760,10 +2758,8 @@ dazonesupsysctl(SYSCTL_HANDLER_ARGS) if (first == 1) sbuf_printf(&sb, "None"); - sbuf_finish(&sb); - - error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); - + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); }