From 2e1a735c1bb76094744a6112b092331e34c7db09 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 13 Nov 2013 19:26:15 +0100 Subject: Respect warn_unused_result warnings --- src/rccexternal.c | 7 ++++++- src/rccxml.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/rccexternal.c b/src/rccexternal.c index 74e1ef3..1667ba8 100644 --- a/src/rccexternal.c +++ b/src/rccexternal.c @@ -271,9 +271,14 @@ again: void rccExternalClose(int s) { #ifdef HAVE_SYS_SOCKET_H + ssize_t ret; unsigned char cmd = 0; if (s != -1) { - write(s, &cmd, 1); +retry: + ret = write(s, &cmd, 1); + // retry once on signal + if ((ret < 0)&&(errno == EINTR)) + ret = write(s, &cmd, 1); close(s); } #endif /* HAVE_SYS_SOCKET_H */ diff --git a/src/rccxml.c b/src/rccxml.c index 6fb7e28..39992f2 100644 --- a/src/rccxml.c +++ b/src/rccxml.c @@ -19,6 +19,7 @@ #include #include +#include #include #ifdef HAVE_STRINGS_H @@ -455,10 +456,18 @@ int rccSave(rcc_context ctx, const char *name) { } xmlDocDumpFormatMemory(doc,&mem,&memsize,1); - ftruncate(fd, 0); - lseek(fd, SEEK_SET, 0); + + if (ftruncate(fd, 0) < 0) + goto clear; + + if (lseek(fd, SEEK_SET, 0)) + goto clear; + if (mem) { - write(fd, mem, memsize); + ssize_t ret = write(fd, mem, memsize); + // Retry once on signals + if ((ret < 0)&&(errno = EINTR)) + ret = write(fd, mem, memsize); free(mem); } -- cgit v1.2.3