tests: Use g_clear_fd()

This commit is contained in:
Benjamin Otte 2023-04-17 14:20:52 +02:00 committed by Philip Withnall
parent e8254f14fd
commit 77c35415a3

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <gio/gio.h>
#include <gio/gfiledescriptorbased.h>
#include <glib/gstdio.h>
#ifdef G_OS_UNIX
#include <sys/stat.h>
#endif
@ -2855,7 +2856,8 @@ test_load_bytes (void)
len = strlen ("test_load_bytes");
ret = write (fd, "test_load_bytes", len);
g_assert_cmpint (ret, ==, len);
close (fd);
g_clear_fd (&fd, &error);
g_assert_no_error (error);
file = g_file_new_for_path (filename);
bytes = g_file_load_bytes (file, NULL, NULL, &error);
@ -2898,6 +2900,7 @@ test_load_bytes_async (void)
{
LoadBytesAsyncData data = { 0 };
gchar filename[] = "g_file_load_bytes_XXXXXX";
GError *error = NULL;
int len;
int fd;
int ret;
@ -2907,7 +2910,8 @@ test_load_bytes_async (void)
len = strlen ("test_load_bytes_async");
ret = write (fd, "test_load_bytes_async", len);
g_assert_cmpint (ret, ==, len);
close (fd);
g_clear_fd (&fd, &error);
g_assert_no_error (error);
data.main_loop = g_main_loop_new (NULL, FALSE);
data.file = g_file_new_for_path (filename);