From nobody Fri Jun 09 19:58:06 2023 X-Original-To: dev-commits-src-branches@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 4QdBhZ6xrQz4cKSn; Fri, 9 Jun 2023 19:58:06 +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 4QdBhZ6HNbz4JMg; Fri, 9 Jun 2023 19:58:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686340686; 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=Fqa0RD/OcXmWf0uUC5HCBadDWV3wzHRJ4F/K244csVk=; b=C/6Z4OFeBUdrF1nTFs77Z191EijZyLeJno/ZWuMHgbMhwsGnmq6sYGjCgPnVSiE48cjfpB 30AR/PJHGNXm14oRDq8L4bhRkbG75DyFQRKZei7bNWBO02Sw09zXrxZKtszw50CWi6vgIE wZT7EERIt5roPaWwrm5CLUVDVy+xC22ujF4xZ08UEGHQUX2d6MSnmFN3aKfOZmhq8AhMpB M3HxImfb4jK7+A75/fe8jKOoOy6mkPipYq940DIbnanjFl+TCFIVGbEA4mohTNW6ToSB8A 6nsbQaotpG2jI86Of39h2vy9WpvEEDZRaDR4s/MPzW8VhK9ddECvO3C5/UIrQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686340686; 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=Fqa0RD/OcXmWf0uUC5HCBadDWV3wzHRJ4F/K244csVk=; b=dE9BJA6+z0JbfNYoiKYDnioBr6dawVJOG5lJ6hrZrzIzdzbz6yJQh3xDjz4+ftT4ZCTdd2 C7YMyOZc+4iWlhy5GmESc01LYh0Q40/XIZoEu061/eLMwHZdqhLg2vrNsTE3xnziU9CIHU HaG/vtEScrBAuAjfJOAUfzrWe24ZjJzlAc02NOwKKFVPlE+Y91HOS3VSBQmQX3hR1dDaTc 7ecDXaI2s7agYGH20b76QvVKHpxHE/cG5pIOBlvG4/ArqkxxQfsWoZpz/F28XNTnoqoxux GrFH51I/DsnG7PXryRXVci4//D01Jiv7yP9TTKXj2KEGoOm0ok8L7TiqDmOZlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686340686; a=rsa-sha256; cv=none; b=OmpFG/31AKh5bBpKNPXXZvXXs7nTHlfXQZ6pbq+p5I1riRQGlrI03snWpGDqtsQp8RROSe kzUfzYzUdj4Nj8hk6vh7PFaaoRDAUlj9/Nl9UPbjOhF9Vpf2fEXt44zZZ21yl2iqNFpTTb 08tisGkr2CDQPoJYBhvT4eqysKNJ9L8TqUJzp8d2+zn3GiRO5gsAwCCA0Q6b5l62H/Tn3R CYpXpqvJsbLcCklTdVZDA1R8XjLDMin0kI4qBwyjp0HRUgOq9Hpg0pfumuGRZbCGOY9tJw CJhdlHVQzuT0w6qGqdJdu55FaZXLGSx48daeW8zQry+07moNrUUflDlOFGTAjw== 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 4QdBhZ5MY8znf0; Fri, 9 Jun 2023 19:58:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 359Jw6TN072138; Fri, 9 Jun 2023 19:58:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 359Jw6P3072137; Fri, 9 Jun 2023 19:58:06 GMT (envelope-from git) Date: Fri, 9 Jun 2023 19:58:06 GMT Message-Id: <202306091958.359Jw6P3072137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 67239b0a33b2 - stable/13 - hwpmc: don't use deprecated copystr(9) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 67239b0a33b22f0e92b975378b060f82fef5593b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=67239b0a33b22f0e92b975378b060f82fef5593b commit 67239b0a33b22f0e92b975378b060f82fef5593b Author: Mitchell Horne AuthorDate: 2023-05-05 21:59:15 +0000 Commit: Mitchell Horne CommitDate: 2023-06-09 18:14:58 +0000 hwpmc: don't use deprecated copystr(9) It is just wrapper around strlcpy(), but results in more complicated code. Clean this up to use strlcpy() or snprintf() as appropriate. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39910 (cherry picked from commit 31610e34b7e39d573d927ea98346c88f23cabdab) --- sys/dev/hwpmc/hwpmc_amd.c | 7 +------ sys/dev/hwpmc/hwpmc_arm64.c | 9 +++------ sys/dev/hwpmc/hwpmc_armv7.c | 9 +++------ sys/dev/hwpmc/hwpmc_beri.c | 8 ++------ sys/dev/hwpmc/hwpmc_core.c | 16 ++-------------- sys/dev/hwpmc/hwpmc_mips.c | 8 ++------ sys/dev/hwpmc/hwpmc_powerpc.c | 9 +++------ sys/dev/hwpmc/hwpmc_soft.c | 7 +------ sys/dev/hwpmc/hwpmc_tsc.c | 7 +------ sys/dev/hwpmc/hwpmc_uncore.c | 16 ++-------------- 10 files changed, 20 insertions(+), 76 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index 2b5356924ae6..05584ee1660d 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -905,8 +905,6 @@ amd_intr(struct trapframe *tf) static int amd_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; - size_t copied; const struct amd_descr *pd; struct pmc_hw *phw; @@ -918,10 +916,7 @@ amd_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) phw = &amd_pcpu[cpu]->pc_amdpmcs[ri]; pd = &amd_pmcdesc[ri]; - if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name, - PMC_NAME_MAX, &copied)) != 0) - return error; - + strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name)); pi->pm_class = pd->pm_descr.pd_class; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 80d97070b913..a89f26f90dd0 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -425,9 +425,7 @@ arm64_intr(struct trapframe *tf) static int arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - char arm64_name[PMC_NAME_MAX]; struct pmc_hw *phw; - int error; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[arm64,%d], illegal CPU %d", __LINE__, cpu)); @@ -435,11 +433,10 @@ arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) ("[arm64,%d] row-index %d out of range", __LINE__, ri)); phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri]; - snprintf(arm64_name, sizeof(arm64_name), "ARMV8-%d", ri); - if ((error = copystr(arm64_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return (error); + + snprintf(pi->pm_name, sizeof(pi->pm_name), "ARMV8-%d", ri); pi->pm_class = PMC_CLASS_ARMV8; + if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { pi->pm_enabled = TRUE; *ppmc = phw->phw_pmc; diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c index cd4761df46be..2cfac1e857bd 100644 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -389,9 +389,7 @@ armv7_intr(struct trapframe *tf) static int armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - char armv7_name[PMC_NAME_MAX]; struct pmc_hw *phw; - int error; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[armv7,%d], illegal CPU %d", __LINE__, cpu)); @@ -399,11 +397,10 @@ armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) ("[armv7,%d] row-index %d out of range", __LINE__, ri)); phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri]; - snprintf(armv7_name, sizeof(armv7_name), "ARMV7-%d", ri); - if ((error = copystr(armv7_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return error; + + snprintf(pi->pm_name, sizeof(pi->pm_name), "ARMV7-%d", ri); pi->pm_class = PMC_CLASS_ARMV7; + if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { pi->pm_enabled = TRUE; *ppmc = phw->phw_pmc; diff --git a/sys/dev/hwpmc/hwpmc_beri.c b/sys/dev/hwpmc/hwpmc_beri.c index 4fec1b950299..ce15bb57fda4 100644 --- a/sys/dev/hwpmc/hwpmc_beri.c +++ b/sys/dev/hwpmc/hwpmc_beri.c @@ -366,8 +366,6 @@ static int beri_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { struct pmc_hw *phw; - char beri_name[PMC_NAME_MAX]; - int error; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[beri,%d], illegal CPU %d", __LINE__, cpu)); @@ -375,10 +373,8 @@ beri_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) ("[beri,%d] row-index %d out of range", __LINE__, ri)); phw = &beri_pcpu[cpu]->pc_beripmcs[ri]; - snprintf(beri_name, sizeof(beri_name), "MIPS-%d", ri); - if ((error = copystr(beri_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return error; + + snprintf(pi->pm_name, sizeof(pi->pm_name), "MIPS-%d", ri); pi->pm_class = beri_pmc_spec.ps_cpuclass; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { pi->pm_enabled = TRUE; diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 5d29931c90f0..ad9d323bdb9a 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -330,17 +330,11 @@ iaf_config_pmc(int cpu, int ri, struct pmc *pm) static int iaf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char iaf_name[PMC_NAME_MAX]; phw = &core_pcpu[cpu]->pc_corepmcs[ri + core_iaf_ri]; - (void) snprintf(iaf_name, sizeof(iaf_name), "IAF-%d", ri); - if ((error = copystr(iaf_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return (error); - + snprintf(pi->pm_name, sizeof(pi->pm_name), "IAF-%d", ri); pi->pm_class = PMC_CLASS_IAF; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { @@ -814,17 +808,11 @@ iap_config_pmc(int cpu, int ri, struct pmc *pm) static int iap_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char iap_name[PMC_NAME_MAX]; phw = &core_pcpu[cpu]->pc_corepmcs[ri]; - (void) snprintf(iap_name, sizeof(iap_name), "IAP-%d", ri); - if ((error = copystr(iap_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return (error); - + snprintf(pi->pm_name, sizeof(pi->pm_name), "IAP-%d", ri); pi->pm_class = PMC_CLASS_IAP; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { diff --git a/sys/dev/hwpmc/hwpmc_mips.c b/sys/dev/hwpmc/hwpmc_mips.c index edf83154dc57..1ed3fdea8915 100644 --- a/sys/dev/hwpmc/hwpmc_mips.c +++ b/sys/dev/hwpmc/hwpmc_mips.c @@ -319,9 +319,7 @@ mips_pmc_intr(struct trapframe *tf) static int mips_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char mips_name[PMC_NAME_MAX]; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[mips,%d], illegal CPU %d", __LINE__, cpu)); @@ -329,10 +327,8 @@ mips_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) ("[mips,%d] row-index %d out of range", __LINE__, ri)); phw = &mips_pcpu[cpu]->pc_mipspmcs[ri]; - snprintf(mips_name, sizeof(mips_name), "MIPS-%d", ri); - if ((error = copystr(mips_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return error; + + snprintf(pi->pm_name, sizeof(pi->pm_name), "MIPS-%d", ri); pi->pm_class = mips_pmc_spec.ps_cpuclass; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { pi->pm_enabled = TRUE; diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c index 7c6df5825399..4c2a9cf84ef4 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -122,19 +122,16 @@ powerpc_switch_out(struct pmc_cpu *pc, struct pmc_process *pp) int powerpc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char powerpc_name[PMC_NAME_MAX]; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[powerpc,%d], illegal CPU %d", __LINE__, cpu)); phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri]; - snprintf(powerpc_name, sizeof(powerpc_name), "POWERPC-%d", ri); - if ((error = copystr(powerpc_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return error; + + snprintf(pi->pm_name, sizeof(pi->pm_name), "POWERPC-%d", ri); pi->pm_class = powerpc_pcpu[cpu]->pc_class; + if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { pi->pm_enabled = TRUE; *ppmc = phw->phw_pmc; diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c index cf2401e9159e..f3a6ffc70677 100644 --- a/sys/dev/hwpmc/hwpmc_soft.c +++ b/sys/dev/hwpmc/hwpmc_soft.c @@ -159,8 +159,6 @@ soft_config_pmc(int cpu, int ri, struct pmc *pm) static int soft_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; - size_t copied; const struct soft_descr *pd; struct pmc_hw *phw; @@ -172,10 +170,7 @@ soft_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) phw = &soft_pcpu[cpu]->soft_hw[ri]; pd = &soft_pmcdesc[ri]; - if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name, - PMC_NAME_MAX, &copied)) != 0) - return (error); - + strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name)); pi->pm_class = pd->pm_descr.pd_class; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { diff --git a/sys/dev/hwpmc/hwpmc_tsc.c b/sys/dev/hwpmc/hwpmc_tsc.c index d59c8908f4ca..25b2e9f8fd57 100644 --- a/sys/dev/hwpmc/hwpmc_tsc.c +++ b/sys/dev/hwpmc/hwpmc_tsc.c @@ -115,8 +115,6 @@ tsc_config_pmc(int cpu, int ri, struct pmc *pm) static int tsc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; - size_t copied; const struct tsc_descr *pd; struct pmc_hw *phw; @@ -127,10 +125,7 @@ tsc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) phw = &tsc_pcpu[cpu]->tc_hw; pd = &tsc_pmcdesc[ri]; - if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name, - PMC_NAME_MAX, &copied)) != 0) - return (error); - + strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name)); pi->pm_class = pd->pm_descr.pd_class; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c index c9ae128b55cf..47d1e62e2698 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -237,17 +237,11 @@ ucf_config_pmc(int cpu, int ri, struct pmc *pm) static int ucf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char ucf_name[PMC_NAME_MAX]; phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri + uncore_ucf_ri]; - (void) snprintf(ucf_name, sizeof(ucf_name), "UCF-%d", ri); - if ((error = copystr(ucf_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return (error); - + snprintf(pi->pm_name, sizeof(pi->pm_name), "UCF-%d", ri); pi->pm_class = PMC_CLASS_UCF; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) { @@ -564,17 +558,11 @@ ucp_config_pmc(int cpu, int ri, struct pmc *pm) static int ucp_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { - int error; struct pmc_hw *phw; - char ucp_name[PMC_NAME_MAX]; phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri]; - (void) snprintf(ucp_name, sizeof(ucp_name), "UCP-%d", ri); - if ((error = copystr(ucp_name, pi->pm_name, PMC_NAME_MAX, - NULL)) != 0) - return (error); - + snprintf(pi->pm_name, sizeof(pi->pm_name), "UCP-%d", ri); pi->pm_class = PMC_CLASS_UCP; if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {