1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
From 2744d7921dd1a1851113eaa12297404f5f523439 Mon Sep 17 00:00:00 2001
From: Seungha Yang <seungha@centricular.com>
Date: Sun, 8 Mar 2020 15:39:23 +0900
Subject: [PATCH] meson: Don't use assert in test code
The test code can be built on Windows using Cygwin or MSYS2.
Even though it's test code, it might bring assertion dialog box
for native Windows while meson configure.
---
meson.build | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/meson.build b/meson.build
index f837465b4..36be4ab05 100644
--- a/meson.build
+++ b/meson.build
@@ -2013,8 +2013,6 @@ cmdline_test_code = '''
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
-#undef NDEBUG
-#include <assert.h>
static int
__getcmdline (void)
@@ -2028,16 +2026,24 @@ __getcmdline (void)
struct stat stat_buf;
int fd = open ("/proc/self/cmdline", O_RDONLY|O_BINARY);
- assert (fd >= 0);
- assert (fstat (fd, &stat_buf) == 0);
+ if (fd < 0)
+ exit (1);
+ if (fstat (fd, &stat_buf))
+ exit (1);
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
{
FILE *f = fdopen (fd, "r");
- assert (f != NULL);
- assert (fread (result, 1, BUFSIZE, f) > 0);
+ if (f == NULL)
+ exit (1);
+
+ if (fread (result, 1, BUFSIZE, f) <= 0)
+ exit (1);
}
return 0;
--
2.17.1
|