Found using scan-build, Clang static analyzer.
Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
---
src/lib.cpp | 8 ++++----
src/main.cpp | 6 ++++--
src/process/do_process.cpp | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/lib.cpp b/src/lib.cpp
index a8f3746..b482296 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -472,10 +472,10 @@ int read_msr(int cpu, uint64_t offset, uint64_t *value)
int fd;
char msr_path[256];
- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
+ sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
if (access(msr_path, R_OK) != 0){
- fd = sprintf(msr_path, "/dev/msr%d", cpu);
+ sprintf(msr_path, "/dev/msr%d", cpu);
if (access(msr_path, R_OK) != 0){
fprintf(stderr,
@@ -504,10 +504,10 @@ int write_msr(int cpu, uint64_t offset, uint64_t value)
int fd;
char msr_path[256];
- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
+ sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
if (access(msr_path, R_OK) != 0){
- fd = sprintf(msr_path, "/dev/msr%d", cpu);
+ sprintf(msr_path, "/dev/msr%d", cpu);
if (access(msr_path, R_OK) != 0){
fprintf(stderr,
diff --git a/src/main.cpp b/src/main.cpp
index cf4e547..99a985f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -315,8 +315,10 @@ static void powertop_init(void)
rlmt.rlim_cur = rlmt.rlim_max = get_nr_open();
setrlimit (RLIMIT_NOFILE, &rlmt);
- ret = system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1");
- ret = system("/sbin/modprobe msr > /dev/null 2>&1");
+ if (system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1"))
+ fprintf(stderr, _("modprobe cpufreq_stats failed"));
+ if (system("/sbin/modprobe msr > /dev/null 2>&1"))
+ fprintf(stderr, _("modprobe msr failed"));
statfs("/sys/kernel/debug", &st_fs);
if (st_fs.f_type != (long) DEBUGFS_MAGIC) {
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index 15115c3..6f9b80a 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -579,7 +579,7 @@ void perf_process_bundle::handle_trace_point(void *trace, int cpu,
uint64_t time
consumer_child_time(cpu, t);
}
else if (strcmp(event->name, "cpu_idle") == 0) {
- ret = pevent_get_field_val(NULL, event, "state", &rec, &val, 0);
+ pevent_get_field_val(NULL, event, "state", &rec, &val, 0);
if (val == (unsigned int)-1)
consume_blame(cpu);
else
--
2.0.3