[PATCH] lib: fix warnings on ignoring return values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxx>
---
 lib/igt_core.c    | 21 ++++++++++++++++-----
 lib/igt_debugfs.c |  6 +++---
 lib/igt_kms.c     | 22 +++++++++++++---------
 lib/intel_os.c    |  2 +-
 4 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index e3d5fb0..287e345 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -336,13 +336,18 @@ static void low_mem_killer_disable(bool disable)
 		/* writing 9999 to this module parameter effectively diables the
 		 * low memory killer. This is not a real file, so we dont need to
 		 * seek to the start or truncate it */
-		write(fd, no_lowmem_killer, sizeof(no_lowmem_killer));
+		igt_assert(
+			write(fd, no_lowmem_killer, sizeof(no_lowmem_killer))
+			== sizeof(no_lowmem_killer));
 		close(fd);
 	} else {
 		/* just re-enstate the original settings */
 		fd = open(adj_fname, O_WRONLY);
 		igt_assert(fd != -1);
-		write(fd, prev_adj_scores, adj_scores_len);
+		igt_assert(
+			write(fd, prev_adj_scores, adj_scores_len)
+			== adj_scores_len);
+
 		close(fd);
 	}
 
@@ -775,7 +780,10 @@ void __igt_skip_check(const char *file, const int line,
 	char *err_str = NULL;
 
 	if (err)
-		asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err));
+		igt_assert(
+			asprintf(&err_str, "Last errno: %i, %s\n",
+				 err, strerror(err))
+			> 0);
 
 	if (f) {
 		static char *buf;
@@ -785,7 +793,7 @@ void __igt_skip_check(const char *file, const int line,
 			free(buf);
 
 		va_start(args, f);
-		vasprintf(&buf, f, args);
+		igt_assert(vasprintf(&buf, f, args) >= 0);
 		va_end(args);
 
 		igt_skip("Test requirement not met in function %s, file %s:%i:\n"
@@ -878,7 +886,10 @@ void __igt_fail_assert(int exitcode, const char *file,
 	char *err_str = NULL;
 
 	if (err)
-		asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err));
+		igt_assert(
+			asprintf(&err_str, "Last errno: %i, %s\n",
+				 err, strerror(err))
+			> 0);
 
 	printf("Test assertion failure function %s, file %s:%i:\n"
 	       "Failed assertion: %s\n"
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index b30f5e4..f4ff61a 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -297,7 +297,7 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 	sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
 		pipe_crc_source_name(pipe_crc->source));
 	errno = 0;
-	write(pipe_crc->ctl_fd, buf, strlen(buf));
+	igt_assert(write(pipe_crc->ctl_fd, buf, strlen(buf)) == strlen(buf));
 	if (errno != 0)
 		return false;
 
@@ -309,7 +309,7 @@ static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
 	char buf[32];
 
 	sprintf(buf, "pipe %s none", kmstest_pipe_name(pipe));
-	write(fd, buf, strlen(buf));
+	igt_assert(write(fd, buf, strlen(buf) == strlen(buf)));
 }
 
 static void igt_pipe_crc_reset(void)
@@ -446,7 +446,7 @@ void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc)
 	char buf[32];
 
 	sprintf(buf, "pipe %s none", kmstest_pipe_name(pipe_crc->pipe));
-	write(pipe_crc->ctl_fd, buf, strlen(buf));
+	igt_assert(write(pipe_crc->ctl_fd, buf, strlen(buf)) == strlen(buf));
 }
 
 static bool pipe_crc_init_from_string(igt_crc_t *crc, const char *line)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0547147..49bc6a9 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -323,11 +323,13 @@ static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
 {
 	char *path;
 
-	asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/%s",
-		 get_card_number(drm_fd),
-		 kmstest_connector_type_str(connector->connector_type),
-		 connector->connector_type_id,
-		 file);
+	igt_assert(
+		asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/%s",
+			 get_card_number(drm_fd),
+			 kmstest_connector_type_str(connector->connector_type),
+			 connector->connector_type_id,
+			 file)
+		> 0);
 
 	return path;
 }
@@ -851,9 +853,11 @@ static void igt_output_refresh(igt_output_t *output)
 	if (!output->name) {
 		drmModeConnector *c = output->config.connector;
 
-		asprintf(&output->name, "%s-%d",
-			 kmstest_connector_type_str(c->connector_type),
-			 c->connector_type_id);
+		igt_assert(
+			asprintf(&output->name, "%s-%d",
+				 kmstest_connector_type_str(c->connector_type),
+				 c->connector_type_id)
+			> 0);
 	}
 
 	LOG(display, "%s: Selecting pipe %s\n", output->name,
@@ -1795,7 +1799,7 @@ void igt_reset_connectors(void)
 
 	for (tmp = forced_connectors; *tmp; tmp++) {
 		int fd = open(*tmp, O_WRONLY | O_TRUNC);
-		write(fd, "unspecified", 11);
+		igt_assert(write(fd, "unspecified", 11) == 11);
 		close(fd);
 	}
 }
diff --git a/lib/intel_os.c b/lib/intel_os.c
index c8793b9..c05e4b8 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -257,7 +257,7 @@ intel_purge_vm_caches(void)
 	if (fd < 0)
 		return;
 
-	write(fd, "3\n", 2);
+	igt_assert(write(fd, "3\n", 2) == 2);
 	close(fd);
 }
 
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux