diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -905,8 +905,6 @@ 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 @@ 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 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -416,9 +416,7 @@ 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)); @@ -426,11 +424,10 @@ ("[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 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -384,9 +384,7 @@ 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)); @@ -394,11 +392,10 @@ ("[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_cmn600.c b/sys/dev/hwpmc/hwpmc_cmn600.c --- a/sys/dev/hwpmc/hwpmc_cmn600.c +++ b/sys/dev/hwpmc/hwpmc_cmn600.c @@ -587,9 +587,8 @@ static int cmn600_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { + struct pmc_descr *pd; struct pmc_hw *phw; - size_t copied; - int error; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[cmn600,%d] illegal CPU %d", __LINE__, cpu)); @@ -597,12 +596,10 @@ ri)); phw = cmn600desc(ri)->pd_phw; + pd = &cmn600desc(ri)->pd_descr; - if ((error = copystr(cmn600desc(ri)->pd_descr.pd_name, - pi->pm_name, PMC_NAME_MAX, &copied)) != 0) - return (error); - - pi->pm_class = cmn600desc(ri)->pd_descr.pd_class; + strlcpy(pi->pm_name, pd->pd_name, sizeof(pi->pm_name)); + pi->pm_class = pd->pd_class; 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 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -330,17 +330,11 @@ 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 @@ 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_dmc620.c b/sys/dev/hwpmc/hwpmc_dmc620.c --- a/sys/dev/hwpmc/hwpmc_dmc620.c +++ b/sys/dev/hwpmc/hwpmc_dmc620.c @@ -454,9 +454,8 @@ CLASSDEP_FN4(dmc620_describe, int, cpu, int, ri, struct pmc_info *, pi, struct pmc **, ppmc) { + struct pmc_descr *pd; struct pmc_hw *phw; - size_t copied; - int error; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[dmc620,%d] illegal CPU %d", __LINE__, cpu)); @@ -464,12 +463,10 @@ ri)); phw = dmc620desc(class, cpu, ri)->pd_phw; + pd = &dmc620desc(class, cpu, ri)->pd_descr; - if ((error = copystr(dmc620desc(class, cpu, ri)->pd_descr.pd_name, - pi->pm_name, PMC_NAME_MAX, &copied)) != 0) - return (error); - - pi->pm_class = dmc620desc(class, cpu, ri)->pd_descr.pd_class; + strlcpy(pi->pm_name, pd->pd_name, sizeof(pi->pm_name)); + pi->pm_class = pd->pd_class; 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 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -122,19 +122,16 @@ 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 --- a/sys/dev/hwpmc/hwpmc_soft.c +++ b/sys/dev/hwpmc/hwpmc_soft.c @@ -159,8 +159,6 @@ 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 @@ 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 --- a/sys/dev/hwpmc/hwpmc_tsc.c +++ b/sys/dev/hwpmc/hwpmc_tsc.c @@ -115,8 +115,6 @@ 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 @@ 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 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -233,17 +233,11 @@ 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) { @@ -560,17 +554,11 @@ 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) {