[Powertop] [PATCH 3/3] fix-warnings: Ignoring return value

Alexandra Yates <alexandra.yates at linux.intel.com>
Newsgroups dev.linux.lists.powertop
Message-ID <1402697910-29154-4-git-send-email-alexandra.yates@linux.intel.com>
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(-)

diff --git a/src/measurement/extech.cpp b/src/measurement/extech.cpp
index 4e8bf8a..e014a5d 100644
--- a/src/measurement/extech.cpp
+++ b/src/measurement/extech.cpp
@@ -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");
 
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.