From ee22267ae381eb3274aff3a6c6d1b0ab6efe53d2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 10 Dec 2021 21:28:49 +0100 Subject: Fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- internal.h | 1 + liberror-libc.h | 1 + lseek.c | 6 ++++-- recv.c | 8 +++++++- send.c | 8 +++++++- shutdown.c | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/internal.h b/internal.h index 2605d21..190de0e 100644 --- a/internal.h +++ b/internal.h @@ -17,6 +17,7 @@ #if defined(__GNUC__) +# pragma GCC diagnostic ignored "-Wsuggest-attribute=const" # define GCC_ATTRIBUTES(...) __attribute__((__VA_ARGS__)) #else # define GCC_ATTRIBUTES(...) diff --git a/liberror-libc.h b/liberror-libc.h index 14ca4a0..7b99d93 100644 --- a/liberror-libc.h +++ b/liberror-libc.h @@ -15,6 +15,7 @@ #define _LIBERROR_WUR _LIBERROR_GCC_ONLY(__attribute__((__warn_unused_result__))) #define _LIBERROR_MALLOC _LIBERROR_GCC_ONLY(__attribute__((__malloc__))) +#define _LIBERROR_CONST _LIBERROR_GCC_ONLY(__attribute__((__const__))) #define LIBERROR_LIBC_ERRROR_SHORT_READ -1 diff --git a/lseek.c b/lseek.c index 7b1dc90..53f46e1 100644 --- a/lseek.c +++ b/lseek.c @@ -77,9 +77,9 @@ liberror_lseek_short(int fd, _liberror_off_t offset, int whence, _liberror_uoff_ struct liberror_error *error; int saved_errno = errno; liberror_save_backtrace(NULL); - if (returned < 0 || (size_t)returned < min) { + if (returned < 0 || (_liberror_uoff_t)returned < min) { desc = "Seek resulted in a new offset in an earlier position than expected"; - } else if (returned > max) { + } else if ((_liberror_uoff_t)returned > max) { desc = "Seek resulted in a new offset in an beyond the expectation"; } else { desc = "Seek resulted in an unexpected new offset"; @@ -91,6 +91,8 @@ liberror_lseek_short(int fd, _liberror_off_t offset, int whence, _liberror_uoff_ error->details.one_file.name = fname ? strdup(fname) : NULL; error->details.one_file.role = "Seekable file"; errno = saved_errno; + (void) offset; + (void) whence; } diff --git a/recv.c b/recv.c index 7d1af35..831850a 100644 --- a/recv.c +++ b/recv.c @@ -109,6 +109,9 @@ liberror_recv_failed(int fd, void *buf, size_t n, int flags, const char *fname) break; } liberror_libc_set_error_one_file(desc, "recv", "Socket file", fd, fname); + (void) buf; + (void) n; + (void) flags; } @@ -121,7 +124,7 @@ liberror_recv_short(int fd, void *buf, size_t n, int flags, size_t min, size_t m liberror_save_backtrace(NULL); if (returned < 0 || (size_t)returned < min) { desc = "Received message was shorter than expected"; - } else if (returned > max) { + } else if ((size_t) returned > max) { desc = "Received message was larger than expected"; } else { desc = "Received message was of an unexpected size"; @@ -133,6 +136,9 @@ liberror_recv_short(int fd, void *buf, size_t n, int flags, size_t min, size_t m error->details.one_file.name = fname ? strdup(fname) : NULL; error->details.one_file.role = "Socket file"; errno = saved_errno; + (void) buf; + (void) n; + (void) flags; } diff --git a/send.c b/send.c index e79f562..62c12a7 100644 --- a/send.c +++ b/send.c @@ -142,6 +142,9 @@ liberror_send_failed(int fd, const void *buf, size_t n, int flags, const char *f break; } liberror_libc_set_error_one_file(desc, "send", "Socket file", fd, fname); + (void) buf; + (void) n; + (void) flags; } @@ -154,7 +157,7 @@ liberror_send_short(int fd, const void *buf, size_t n, int flags, size_t min, si liberror_save_backtrace(NULL); if (returned < 0 || (size_t)returned < min) { desc = "Sent message was shorter than expected"; - } else if (returned > max) { + } else if ((size_t)returned > max) { desc = "Sent message was larger than expected"; } else { desc = "Sent message was of an unexpected size"; @@ -166,6 +169,9 @@ liberror_send_short(int fd, const void *buf, size_t n, int flags, size_t min, si error->details.one_file.name = fname ? strdup(fname) : NULL; error->details.one_file.role = "Socket file"; errno = saved_errno; + (void) buf; + (void) n; + (void) flags; } diff --git a/shutdown.c b/shutdown.c index 7ea4103..8265e3f 100644 --- a/shutdown.c +++ b/shutdown.c @@ -30,6 +30,7 @@ liberror_shutdown_failed(int fd, int how, const char *fname) break; } liberror_libc_set_error_one_file(desc, "shutdown", "Socket file", fd, fname); + (void) how; } -- cgit v1.2.3-70-g09d2