mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
Merge branch 'fix-win-assert' into 'master'
meson: Don't use assert in test code See merge request GNOME/glib!1415
This commit is contained in:
commit
5d6e3d52b3
20
meson.build
20
meson.build
@ -2013,8 +2013,6 @@ cmdline_test_code = '''
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#undef NDEBUG
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__getcmdline (void)
|
__getcmdline (void)
|
||||||
@ -2028,16 +2026,24 @@ __getcmdline (void)
|
|||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
|
||||||
int fd = open ("/proc/self/cmdline", O_RDONLY|O_BINARY);
|
int fd = open ("/proc/self/cmdline", O_RDONLY|O_BINARY);
|
||||||
assert (fd >= 0);
|
if (fd < 0)
|
||||||
assert (fstat (fd, &stat_buf) == 0);
|
exit (1);
|
||||||
|
if (fstat (fd, &stat_buf))
|
||||||
|
exit (1);
|
||||||
|
|
||||||
if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode))
|
if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode))
|
||||||
assert (read (fd, result, BUFSIZE) > 0);
|
{
|
||||||
|
if (read (fd, result, BUFSIZE) <= 0)
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *f = fdopen (fd, "r");
|
FILE *f = fdopen (fd, "r");
|
||||||
assert (f != NULL);
|
if (f == NULL)
|
||||||
assert (fread (result, 1, BUFSIZE, f) > 0);
|
exit (1);
|
||||||
|
|
||||||
|
if (fread (result, 1, BUFSIZE, f) <= 0)
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user