Skip to contentSkip to conversation

Fix all warnings

PATCH In review Alexandra Yates 2 participants 5 messages Jun 13, 2014 – Jun 17, 2014

lore
Share & tools
lore

Alexandra Yates

author
#0 lore raw

cover Fix all warnings

This patch fixes all warning encountered when building PowerTOP.

Alexandra Yates (3):
fix-warnings: Ignoring return value of system()
fix-warnings: Ignoring return value
fix-warnings: Ignoring return value

 src/calibrate/calibrate.cpp |   16 +++++++++++-----
 src/measurement/extech.cpp  |   13 +++++++------
 src/tuning/bluetooth.cpp    |    6 ++++--
 3 files changed, 22 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/3 fix-warnings: Ignoring return value of system()

Added error handling to system() for bluetooth.cpp.

Signed-off-by Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/tuning/bluetooth.cpp |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
src/tuning/bluetooth.cpp +4 -2
index 2b34277..92f5835 100644
@@ -176,10 +176,12 @@ void bt_tunable::toggle(void)
 	good = good_bad();
 
 	if (good == TUNE_GOOD) {
-		system("/usr/sbin/hciconfig hci0 up &> /dev/null &");
+		if(!system("/usr/sbin/hciconfig hci0 up &> /dev/null &"))
+			printf("System is not available\n");
 		return;
 	}
-	system("/usr/sbin/hciconfig hci0 down &> /dev/null");
+	if(!system("/usr/sbin/hciconfig hci0 down &> /dev/null"))
+		printf("System is not available\n");
 }
 
 const char *bt_tunable::toggle_script(void)
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/3 fix-warnings: Ignoring return value

In reply to Alexandra Yates

Added error handling to system() and write() calls.

Signed-off-by Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/calibrate/calibrate.cpp |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
src/calibrate/calibrate.cpp +11 -5
index db368e0..a9a0a7c 100644
@@ -33,6 +33,7 @@
 #include <pthread.h>
 #include <math.h>
 #include <sys/types.h>
+#include <errno.h>
 
 #include "../parameters/parameters.h"
 extern "C" {
@@ -239,7 +240,8 @@ static void *burn_disk(void *dummy)
 
 	while (!stop_measurement) {
 		lseek(fd, 0, SEEK_SET);
-		write(fd, buffer, 64*1024);
+		if(write(fd, buffer, 64*1024) == -1)
+			printf("Error: %s\n", strerror(errno));
 		fdatasync(fd);
 	}
 	close(fd);
@@ -350,17 +352,21 @@ static void backlight_calibration(void)
 		sleep(1);
 	}
 	printf(_("Calibrating idle\n"));
-	system("DISPLAY=:0 /usr/bin/xset dpms force off");
+	if(!system("DISPLAY=:0 /usr/bin/xset dpms force off"))
+		printf("System is not available\n");
 	one_measurement(15, NULL);
-	system("DISPLAY=:0 /usr/bin/xset dpms force on");
+	if(!system("DISPLAY=:0 /usr/bin/xset dpms force on"))
+		printf("System is not available\n");
 }
 
 static void idle_calibration(void)
 {
 	printf(_("Calibrating idle\n"));
-	system("DISPLAY=:0 /usr/bin/xset dpms force off");
+	if(!system("DISPLAY=:0 /usr/bin/xset dpms force off"))
+		printf("System is not available\n");
 	one_measurement(15, NULL);
-	system("DISPLAY=:0 /usr/bin/xset dpms force on");
+	if(!system("DISPLAY=:0 /usr/bin/xset dpms force on"))
+		printf("System is not available\n");
 }
 
 
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/3 fix-warnings: Ignoring return value

In reply to Alexandra Yates

Added error handling to write() calls.

Signed-off-by Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/measurement/extech.cpp |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
src/measurement/extech.cpp +7 -6
index 4e8bf8a..e014a5d 100644
@@ -287,13 +287,14 @@ extech_power_meter::extech_power_meter(const char *extech_name)
 void extech_power_meter::measure(void)
 {
 	/* trigger the extech to send data */
-	write(fd, " ", 1);
+	if(write(fd, " ", 1) == -1)
+		 printf("Error: %s\n", strerror(errno));
 
 	rate = extech_read(fd);
 
 }
 
-void extech_power_meter::sample(void) 
+void extech_power_meter::sample(void)
 {
 	ssize_t ret;
 	struct timespec tv;
@@ -306,16 +307,16 @@ void extech_power_meter::sample(void)
 		ret = write(fd, " ", 1);
 		if (ret < 0)
 			continue;
-		
+
 		sum += extech_read(fd);
 		samples++;
-	
+
 	}
 }
 
 extern "C"
 {
-	void* thread_proc(void *arg) 
+	void* thread_proc(void *arg)
 	{
 		class extech_power_meter *parent;
 		parent = (class extech_power_meter*)arg;
@@ -339,7 +340,7 @@ void extech_power_meter::start_measurement(void)
 {
 	end_thread = 0;
 	sum = samples = 0;
-	
+
 	if (pthread_create(&thread, NULL, thread_proc, this))
 		fprintf(stderr, "ERROR: extech measurement thread creation failed\n");
 
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Alexandra Yates

I confirm there are no warning when building PowerTop with the 3 patches applied. Tested with PowerTOP versionv2.6.1 commit dfc2ba97ffba44b51379fd3617a4f6fead40037d

-----Original Message-----
From: PowerTop [mailto:powertop-bounces(a)lists.01.org] On Behalf Of Alexandra Yates
Sent: Saturday, June 14, 2014 12:18 AM
To: powertop(a)lists.01.org
Subject: [Powertop] [PATCH 0/3] Fix all warnings

This patch fixes all warning encountered when building PowerTOP.

Alexandra Yates (3):
fix-warnings: Ignoring return value of system()
fix-warnings: Ignoring return value
fix-warnings: Ignoring return value

 src/calibrate/calibrate.cpp |   16 +++++++++++-----
 src/measurement/extech.cpp  |   13 +++++++------
 src/tuning/bluetooth.cpp    |    6 ++++--
 3 files changed, 22 insertions(+), 13 deletions(-)
Signature · 17 lines
1.7.9.5

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.