diff options
author | Thomas Wood <thomas.wood@intel.com> | 2015-03-25 16:42:57 +0000 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2015-03-26 15:50:59 +0000 |
commit | 47f6b1305cc3752f318a555b932e194e1500c1d8 (patch) | |
tree | 18660c1faf9eadd6ef2bcbe9730eb1fa6c5ced7f /lib/igt_core.c | |
parent | 0c4dd28d2d3b39216f9d041119ebf34cc44b7df7 (diff) |
igt.cocci: check the return values of various functions
Add rules to fix unused-result warnings when compiling with
_FORTIFY_SOURCE defined and apply them to the library and tests.
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r-- | lib/igt_core.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index 4cc040f5..783a2191 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -417,13 +417,15 @@ 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_eq(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_eq(write(fd, prev_adj_scores, adj_scores_len), + adj_scores_len); close(fd); } @@ -864,7 +866,8 @@ 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_neq(asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err)), + -1); if (f) { static char *buf; @@ -874,7 +877,7 @@ void __igt_skip_check(const char *file, const int line, free(buf); va_start(args, f); - vasprintf(&buf, f, args); + igt_assert_neq(vasprintf(&buf, f, args), -1); va_end(args); igt_skip("Test requirement not met in function %s, file %s:%i:\n" @@ -1407,10 +1410,11 @@ static void fatal_sig_handler(int sig) continue; if (handled_signals[i].name_len) { - write(STDERR_FILENO, "Received signal ", 16); - write(STDERR_FILENO, handled_signals[i].name, - handled_signals[i].name_len); - write(STDERR_FILENO, ".\n", 2); + igt_assert_eq(write(STDERR_FILENO, "Received signal ", 16), + 16); + igt_assert_eq(write(STDERR_FILENO, handled_signals[i].name, handled_signals[i].name_len), + handled_signals[i].name_len); + igt_assert_eq(write(STDERR_FILENO, ".\n", 2), 2); } break; |