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
This commit is contained in:
parent
aba91805aa
commit
31610e34b7
@ -905,8 +905,6 @@ amd_intr(struct trapframe *tf)
|
|||||||
static int
|
static int
|
||||||
amd_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
amd_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
size_t copied;
|
|
||||||
const struct amd_descr *pd;
|
const struct amd_descr *pd;
|
||||||
struct pmc_hw *phw;
|
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];
|
phw = &amd_pcpu[cpu]->pc_amdpmcs[ri];
|
||||||
pd = &amd_pmcdesc[ri];
|
pd = &amd_pmcdesc[ri];
|
||||||
|
|
||||||
if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name,
|
strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name));
|
||||||
PMC_NAME_MAX, &copied)) != 0)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
pi->pm_class = pd->pm_descr.pd_class;
|
pi->pm_class = pd->pm_descr.pd_class;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
|
@ -416,9 +416,7 @@ arm64_intr(struct trapframe *tf)
|
|||||||
static int
|
static int
|
||||||
arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
char arm64_name[PMC_NAME_MAX];
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
int error;
|
|
||||||
|
|
||||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||||
("[arm64,%d], illegal CPU %d", __LINE__, cpu));
|
("[arm64,%d], illegal CPU %d", __LINE__, cpu));
|
||||||
@ -426,11 +424,10 @@ arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
|||||||
("[arm64,%d] row-index %d out of range", __LINE__, ri));
|
("[arm64,%d] row-index %d out of range", __LINE__, ri));
|
||||||
|
|
||||||
phw = &arm64_pcpu[cpu]->pc_arm64pmcs[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,
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "ARMV8-%d", ri);
|
||||||
NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
pi->pm_class = PMC_CLASS_ARMV8;
|
pi->pm_class = PMC_CLASS_ARMV8;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
pi->pm_enabled = TRUE;
|
pi->pm_enabled = TRUE;
|
||||||
*ppmc = phw->phw_pmc;
|
*ppmc = phw->phw_pmc;
|
||||||
|
@ -384,9 +384,7 @@ armv7_intr(struct trapframe *tf)
|
|||||||
static int
|
static int
|
||||||
armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
char armv7_name[PMC_NAME_MAX];
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
int error;
|
|
||||||
|
|
||||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||||
("[armv7,%d], illegal CPU %d", __LINE__, cpu));
|
("[armv7,%d], illegal CPU %d", __LINE__, cpu));
|
||||||
@ -394,11 +392,10 @@ armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
|||||||
("[armv7,%d] row-index %d out of range", __LINE__, ri));
|
("[armv7,%d] row-index %d out of range", __LINE__, ri));
|
||||||
|
|
||||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[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,
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "ARMV7-%d", ri);
|
||||||
NULL)) != 0)
|
|
||||||
return error;
|
|
||||||
pi->pm_class = PMC_CLASS_ARMV7;
|
pi->pm_class = PMC_CLASS_ARMV7;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
pi->pm_enabled = TRUE;
|
pi->pm_enabled = TRUE;
|
||||||
*ppmc = phw->phw_pmc;
|
*ppmc = phw->phw_pmc;
|
||||||
|
@ -587,9 +587,8 @@ cmn600_stop_pmc(int cpu, int ri)
|
|||||||
static int
|
static int
|
||||||
cmn600_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
cmn600_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
|
struct pmc_descr *pd;
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
size_t copied;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||||
("[cmn600,%d] illegal CPU %d", __LINE__, cpu));
|
("[cmn600,%d] illegal CPU %d", __LINE__, cpu));
|
||||||
@ -597,12 +596,10 @@ cmn600_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
|||||||
ri));
|
ri));
|
||||||
|
|
||||||
phw = cmn600desc(ri)->pd_phw;
|
phw = cmn600desc(ri)->pd_phw;
|
||||||
|
pd = &cmn600desc(ri)->pd_descr;
|
||||||
|
|
||||||
if ((error = copystr(cmn600desc(ri)->pd_descr.pd_name,
|
strlcpy(pi->pm_name, pd->pd_name, sizeof(pi->pm_name));
|
||||||
pi->pm_name, PMC_NAME_MAX, &copied)) != 0)
|
pi->pm_class = pd->pd_class;
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = cmn600desc(ri)->pd_descr.pd_class;
|
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
pi->pm_enabled = TRUE;
|
pi->pm_enabled = TRUE;
|
||||||
|
@ -330,17 +330,11 @@ iaf_config_pmc(int cpu, int ri, struct pmc *pm)
|
|||||||
static int
|
static int
|
||||||
iaf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
iaf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
char iaf_name[PMC_NAME_MAX];
|
|
||||||
|
|
||||||
phw = &core_pcpu[cpu]->pc_corepmcs[ri + core_iaf_ri];
|
phw = &core_pcpu[cpu]->pc_corepmcs[ri + core_iaf_ri];
|
||||||
|
|
||||||
(void) snprintf(iaf_name, sizeof(iaf_name), "IAF-%d", ri);
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "IAF-%d", ri);
|
||||||
if ((error = copystr(iaf_name, pi->pm_name, PMC_NAME_MAX,
|
|
||||||
NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = PMC_CLASS_IAF;
|
pi->pm_class = PMC_CLASS_IAF;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
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
|
static int
|
||||||
iap_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
iap_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
char iap_name[PMC_NAME_MAX];
|
|
||||||
|
|
||||||
phw = &core_pcpu[cpu]->pc_corepmcs[ri];
|
phw = &core_pcpu[cpu]->pc_corepmcs[ri];
|
||||||
|
|
||||||
(void) snprintf(iap_name, sizeof(iap_name), "IAP-%d", ri);
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "IAP-%d", ri);
|
||||||
if ((error = copystr(iap_name, pi->pm_name, PMC_NAME_MAX,
|
|
||||||
NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = PMC_CLASS_IAP;
|
pi->pm_class = PMC_CLASS_IAP;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
|
@ -454,9 +454,8 @@ CLASSDEP_FN2(dmc620_stop_pmc, int, cpu, int, ri)
|
|||||||
CLASSDEP_FN4(dmc620_describe, int, cpu, int, ri, struct pmc_info *, pi,
|
CLASSDEP_FN4(dmc620_describe, int, cpu, int, ri, struct pmc_info *, pi,
|
||||||
struct pmc **, ppmc)
|
struct pmc **, ppmc)
|
||||||
{
|
{
|
||||||
|
struct pmc_descr *pd;
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
size_t copied;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||||
("[dmc620,%d] illegal CPU %d", __LINE__, cpu));
|
("[dmc620,%d] illegal CPU %d", __LINE__, cpu));
|
||||||
@ -464,12 +463,10 @@ CLASSDEP_FN4(dmc620_describe, int, cpu, int, ri, struct pmc_info *, pi,
|
|||||||
ri));
|
ri));
|
||||||
|
|
||||||
phw = dmc620desc(class, cpu, ri)->pd_phw;
|
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,
|
strlcpy(pi->pm_name, pd->pd_name, sizeof(pi->pm_name));
|
||||||
pi->pm_name, PMC_NAME_MAX, &copied)) != 0)
|
pi->pm_class = pd->pd_class;
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = dmc620desc(class, cpu, ri)->pd_descr.pd_class;
|
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
pi->pm_enabled = TRUE;
|
pi->pm_enabled = TRUE;
|
||||||
|
@ -122,19 +122,16 @@ powerpc_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
|
|||||||
int
|
int
|
||||||
powerpc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
powerpc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
char powerpc_name[PMC_NAME_MAX];
|
|
||||||
|
|
||||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||||
("[powerpc,%d], illegal CPU %d", __LINE__, cpu));
|
("[powerpc,%d], illegal CPU %d", __LINE__, cpu));
|
||||||
|
|
||||||
phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri];
|
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,
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "POWERPC-%d", ri);
|
||||||
NULL)) != 0)
|
|
||||||
return error;
|
|
||||||
pi->pm_class = powerpc_pcpu[cpu]->pc_class;
|
pi->pm_class = powerpc_pcpu[cpu]->pc_class;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
pi->pm_enabled = TRUE;
|
pi->pm_enabled = TRUE;
|
||||||
*ppmc = phw->phw_pmc;
|
*ppmc = phw->phw_pmc;
|
||||||
|
@ -159,8 +159,6 @@ soft_config_pmc(int cpu, int ri, struct pmc *pm)
|
|||||||
static int
|
static int
|
||||||
soft_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
soft_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
size_t copied;
|
|
||||||
const struct soft_descr *pd;
|
const struct soft_descr *pd;
|
||||||
struct pmc_hw *phw;
|
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];
|
phw = &soft_pcpu[cpu]->soft_hw[ri];
|
||||||
pd = &soft_pmcdesc[ri];
|
pd = &soft_pmcdesc[ri];
|
||||||
|
|
||||||
if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name,
|
strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name));
|
||||||
PMC_NAME_MAX, &copied)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = pd->pm_descr.pd_class;
|
pi->pm_class = pd->pm_descr.pd_class;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
|
@ -115,8 +115,6 @@ tsc_config_pmc(int cpu, int ri, struct pmc *pm)
|
|||||||
static int
|
static int
|
||||||
tsc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
tsc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
size_t copied;
|
|
||||||
const struct tsc_descr *pd;
|
const struct tsc_descr *pd;
|
||||||
struct pmc_hw *phw;
|
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;
|
phw = &tsc_pcpu[cpu]->tc_hw;
|
||||||
pd = &tsc_pmcdesc[ri];
|
pd = &tsc_pmcdesc[ri];
|
||||||
|
|
||||||
if ((error = copystr(pd->pm_descr.pd_name, pi->pm_name,
|
strlcpy(pi->pm_name, pd->pm_descr.pd_name, sizeof(pi->pm_name));
|
||||||
PMC_NAME_MAX, &copied)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = pd->pm_descr.pd_class;
|
pi->pm_class = pd->pm_descr.pd_class;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
|
@ -233,17 +233,11 @@ ucf_config_pmc(int cpu, int ri, struct pmc *pm)
|
|||||||
static int
|
static int
|
||||||
ucf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
ucf_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
char ucf_name[PMC_NAME_MAX];
|
|
||||||
|
|
||||||
phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri + uncore_ucf_ri];
|
phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri + uncore_ucf_ri];
|
||||||
|
|
||||||
(void) snprintf(ucf_name, sizeof(ucf_name), "UCF-%d", ri);
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "UCF-%d", ri);
|
||||||
if ((error = copystr(ucf_name, pi->pm_name, PMC_NAME_MAX,
|
|
||||||
NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = PMC_CLASS_UCF;
|
pi->pm_class = PMC_CLASS_UCF;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
@ -560,17 +554,11 @@ ucp_config_pmc(int cpu, int ri, struct pmc *pm)
|
|||||||
static int
|
static int
|
||||||
ucp_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
ucp_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct pmc_hw *phw;
|
struct pmc_hw *phw;
|
||||||
char ucp_name[PMC_NAME_MAX];
|
|
||||||
|
|
||||||
phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri];
|
phw = &uncore_pcpu[cpu]->pc_uncorepmcs[ri];
|
||||||
|
|
||||||
(void) snprintf(ucp_name, sizeof(ucp_name), "UCP-%d", ri);
|
snprintf(pi->pm_name, sizeof(pi->pm_name), "UCP-%d", ri);
|
||||||
if ((error = copystr(ucp_name, pi->pm_name, PMC_NAME_MAX,
|
|
||||||
NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
pi->pm_class = PMC_CLASS_UCP;
|
pi->pm_class = PMC_CLASS_UCP;
|
||||||
|
|
||||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||||
|
Loading…
Reference in New Issue
Block a user