From 9751a9e2c969ad876d2af709d3b70df0bebb4b06 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Mar 2018 12:26:57 +0000 Subject: [PATCH] DBusSocket helpers: Declare as _DBUS_GNUC_WARN_UNUSED_RESULT There is no point in calling these functions for their side-effects, because they don't have any. Signed-off-by: Simon McVittie --- dbus/dbus-sysdeps.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index c9d630a7..171af7b5 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -132,15 +132,18 @@ typedef struct { SOCKET sock; } DBusSocket; # define DBUS_SOCKET_FORMAT "Iu" # define DBUS_SOCKET_INIT { INVALID_SOCKET } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline SOCKET _dbus_socket_printable (DBusSocket s) { return s.sock; } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline dbus_bool_t _dbus_socket_is_valid (DBusSocket s) { return s.sock != INVALID_SOCKET; } static inline void _dbus_socket_invalidate (DBusSocket *s) { s->sock = INVALID_SOCKET; } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline int _dbus_socket_get_int (DBusSocket s) { return (int)s.sock; } @@ -150,20 +153,24 @@ typedef struct { int fd; } DBusSocket; # define DBUS_SOCKET_FORMAT "d" # define DBUS_SOCKET_INIT { -1 } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline int _dbus_socket_printable (DBusSocket s) { return s.fd; } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline dbus_bool_t _dbus_socket_is_valid (DBusSocket s) { return s.fd >= 0; } static inline void _dbus_socket_invalidate (DBusSocket *s) { s->fd = -1; } +_DBUS_GNUC_WARN_UNUSED_RESULT static inline int _dbus_socket_get_int (DBusSocket s) { return s.fd; } #endif /* not DBUS_WIN */ +_DBUS_GNUC_WARN_UNUSED_RESULT static inline DBusSocket _dbus_socket_get_invalid (void) { -- 2.16.2