util: fix a leaking fd in a test

This commit is contained in:
Peter Hutterer 2024-09-11 11:31:49 +10:00
parent e3091a1802
commit bbc1f8de1c

View file

@ -28,6 +28,7 @@
#include <string.h>
#include "util-strings.h"
#include "util-io.h"
/**
* Return the next word in a string pointed to by state before the first
@ -516,7 +517,7 @@ MUNIT_TEST(test_cmdline_as_str)
xsnprintf(cmdline, sizeof(cmdline), "/proc/%i/cmdline", getpid());
int fd = open(cmdline, O_RDONLY);
_cleanup_close_ int fd = open(cmdline, O_RDONLY);
munit_assert_int(fd, >=, 0);
int len = read(fd, cmdline, sizeof(cmdline) - 1);
munit_assert_int(len, >=, 0);