Skip to content

Commit

Permalink
core: ignore -Wunused-result for some read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
nil0x42 committed Sep 29, 2020
1 parent 7c892c1 commit b6ecc8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
#include <stdio.h>
#include <stdarg.h>

/** Ignore warning:
* ignoring return value of ‘write’, declared with attribute warn_unused_result
* Because we write to STDERR_FILENO & don't need to check write() return.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"

/** Print a formatted warning message without leaving the program.
* The use of printf() inside this function causes it
Expand Down Expand Up @@ -50,3 +56,5 @@ void die(const char *msg)
perror(msg);
exit(1);
}

#pragma GCC diagnostic pop
5 changes: 2 additions & 3 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "debug.h"
#include "bytesize.h"

# define FILE_ISSET(_f) ((_f)->fd >= 0)

# define BUF_SIZE (0x20000) /* 128kb */
#define FILE_ISSET(_f) ((_f)->fd >= 0)
#define BUF_SIZE (0x20000) /* 128kb */


static struct file g_infile;
Expand Down
3 changes: 3 additions & 0 deletions src/user_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ static void *watch_user_input_worker(void *arg)
{
#if DEBUG_PROGRAM_STATUS == 0
memset(input, 0, BUF_SIZE);
# pragma GCC diagnostic push // no need to check read()'s return here
# pragma GCC diagnostic ignored "-Wunused-result"
read(STDIN_FILENO, input, BUF_SIZE - 1);
# pragma GCC diagnostic pop
#else
usleep(100000);
#endif
Expand Down

0 comments on commit b6ecc8b

Please sign in to comment.