From 97c11d7d85b7b9865f18258a6cf5334586bc12d3 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 1 Feb 2015 10:03:16 +0100 Subject: [PATCH] Fix compiler warnings. (return value ftrunc/write) --- source/rofi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/rofi.c b/source/rofi.c index f88c6215..c344f733 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -47,9 +47,9 @@ #include #include +#include #ifdef HAVE_I3_IPC_H -#include #include #include #include @@ -2742,12 +2742,12 @@ static void create_pid_file ( const char *pidfile ) fprintf ( stderr, "%d %s\n", retv, strerror ( errno ) ); exit ( 1 ); } - ftruncate ( fd, (off_t) 0 ); - - // Write pid. - char buffer[64]; - int length = snprintf ( buffer, 64, "%i", getpid () ); - write ( fd, buffer, length ); + if ( ftruncate ( fd, (off_t) 0 ) == 0 ) { + // Write pid, not needed, but for completeness sake. + char buffer[64]; + int length = snprintf ( buffer, 64, "%i", getpid () ); + ssize_t l = write ( fd, buffer, length ); + } } int main ( int argc, char *argv[] )