[glib: 1/2] gcancellable: Assert that make_pollfd() call succeeds




commit a110ca920abf10008abbd7f603bb2bbe054159c2
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Aug 18 10:27:36 2020 +0100

    gcancellable: Assert that make_pollfd() call succeeds
    
    The `make_pollfd()` call can’t fail because it only does so if
    `cancellable == NULL`, and we’ve already checked that. Assert that’s the
    case, to shut Coverity up and to catch behavioural changes in future.
    
    Coverity CID: #1159433
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gio/gcancellable.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index e687cca23..3008ecf6f 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -348,6 +348,9 @@ int
 g_cancellable_get_fd (GCancellable *cancellable)
 {
   GPollFD pollfd;
+#ifndef G_OS_WIN32
+  gboolean retval;
+#endif
 
   if (cancellable == NULL)
          return -1;
@@ -355,7 +358,8 @@ g_cancellable_get_fd (GCancellable *cancellable)
 #ifdef G_OS_WIN32
   pollfd.fd = -1;
 #else
-  g_cancellable_make_pollfd (cancellable, &pollfd);
+  retval = g_cancellable_make_pollfd (cancellable, &pollfd);
+  g_assert (retval);
 #endif
 
   return pollfd.fd;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]