All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH 05/12] remove unnecessary assignments
@ 2014-08-02 11:54 Sami Kerola
  0 siblings, 0 replies; only message in thread
From: Sami Kerola @ 2014-08-02 11:54 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-02 11:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-02 11:54 [Powertop] [PATCH 05/12] remove unnecessary assignments Sami Kerola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.