treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / perf / arch / nds32 / util / header.c
blobef9dbdbe7968e6b1f7e81e8e7cd22611df2c106d
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <api/fs/fs.h>
7 #include "header.h"
9 #define STR_LEN 1024
11 char *get_cpuid_str(struct perf_pmu *pmu)
13 /* In nds32, we only have one cpu */
14 char *buf = NULL;
15 struct cpu_map *cpus;
16 const char *sysfs = sysfs__mountpoint();
18 if (!sysfs || !pmu || !pmu->cpus)
19 return NULL;
21 buf = malloc(STR_LEN);
22 if (!buf)
23 return NULL;
25 cpus = cpu_map__get(pmu->cpus);
26 sprintf(buf, "0x%x", cpus->nr - 1);
27 cpu_map__put(cpus);
28 return buf;