aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2014-10-14 00:03:31 +0100
committerChristopher Li <sparse@chrisli.org>2014-11-10 11:57:43 +0800
commit78f9e8faafed4a5ec7e3141360a0dc01910656e4 (patch)
tree3e58a0d5813ecd88f2d93ca6db258dcd9d467824
parent7f9fbccc06bc1b2b4e8f2ebfd8cf8148e54478a4 (diff)
downloadsparse-dev-78f9e8faafed4a5ec7e3141360a0dc01910656e4.tar.gz
compile-i386.c: don't ignore return value of write(2)
Some versions of gcc (e.g. v4.8.2) complain about ignoring the return value of a call to the write(2) system call, since the system header files have marked its declaration with the warn_unused_result attribute. In order to suppress the compiler warning, check the return value from 'write' and, if it indicates an error (a negative return value), exit the process using 'die' to display an error message. Replace a second call to 'write', which does not provoke a compiler warning, with similar code for consistency. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--compile-i386.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/compile-i386.c b/compile-i386.c
index 88169ecb..44b72ec3 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -732,7 +732,8 @@ static void emit_insn_atom(struct function *f, struct atom *atom)
atom->insn,
comment[0] ? "\t\t" : "", comment);
- write(STDOUT_FILENO, s, strlen(s));
+ if (write(STDOUT_FILENO, s, strlen(s)) < 0)
+ die("can't write to stdout");
}
static void emit_atom_list(struct function *f)
@@ -742,9 +743,8 @@ static void emit_atom_list(struct function *f)
FOR_EACH_PTR(f->atom_list, atom) {
switch (atom->type) {
case ATOM_TEXT: {
- ssize_t rc = write(STDOUT_FILENO, atom->text,
- atom->text_len);
- (void) rc; /* FIXME */
+ if (write(STDOUT_FILENO, atom->text, atom->text_len) < 0)
+ die("can't write to stdout");
break;
}
case ATOM_INSN: