[glib: 1/2] tests: Check the return value of fwrite() in a test




commit d6c29b538ad848185711372d7a0165a433266b8f
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Oct 13 15:48:47 2022 +0100

    tests: Check the return value of fwrite() in a test
    
    Not that we ever expect it to fail. This is basically just to silence a
    compiler warning with `-Werror=unused-result`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #2758

 glib/tests/fileutils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index 247bcef1cf..5218aedec0 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -1422,9 +1422,11 @@ test_get_contents (void)
   GError *error = NULL;
   const gchar *text = "abcdefghijklmnopqrstuvwxyz";
   const gchar *filename = "file-test-get-contents";
+  gsize bytes_written;
 
   f = g_fopen (filename, "w");
-  fwrite (text, 1, strlen (text), f);
+  bytes_written = fwrite (text, 1, strlen (text), f);
+  g_assert_cmpint (bytes_written, ==, strlen (text));
   fclose (f);
 
   if (g_test_undefined ())


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