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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
From 50439c9ca9a52f39681fb81bd6768f306125516a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
<congdanhqx@gmail.com>
Date: Tue, 15 Sep 2020 08:21:50 +0700
Subject: [PATCH 1/3] compat: add fallback implementation for reallocarray(3)
ZV: This is from https://gitlab.gnome.org/GNOME/sysprof/-/merge_requests/37.patch
modified to remove the meson-related bits, and add 'subprojects/sysprof'
---
src/libsysprof-capture/sysprof-capture-cursor.c | 4 +++-
src/libsysprof-capture/sysprof-capture-reader.c | 2 +-
.../sysprof-capture-util-private.h | 8 ++++++++
src/libsysprof-capture/sysprof-capture-util.c | 13 +++++++++++++
src/libsysprof-capture/sysprof-capture-writer-cat.c | 7 ++++---
6 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-cursor.c b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-cursor.c
index 24563f0a..cf11bcd5 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-cursor.c
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-cursor.c
@@ -293,7 +293,9 @@ sysprof_capture_cursor_add_condition (SysprofCaptureCursor *self,
*
* FIXME: There’s currently no error reporting from this function, so ENOMEM
* results in an abort. */
- self->conditions = reallocarray (self->conditions, ++self->n_conditions, sizeof (*self->conditions));
+ self->conditions = _sysprof_reallocarray (self->conditions,
+ ++self->n_conditions,
+ sizeof (*self->conditions));
assert (self->conditions != NULL);
self->conditions[self->n_conditions - 1] = sysprof_steal_pointer (&condition);
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-reader.c b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-reader.c
index 67c6b28b..9a5aa912 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-reader.c
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-reader.c
@@ -1270,7 +1270,7 @@ array_append (const char ***files,
const char **new_files;
*n_files_allocated = (*n_files_allocated > 0) ? 2 * *n_files_allocated : 4;
- new_files = reallocarray (*files, *n_files_allocated, sizeof (**files));
+ new_files = _sysprof_reallocarray (*files, *n_files_allocated, sizeof (**files));
if (new_files == NULL)
return false;
*files = new_files;
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
index 1b1d93e9..13ec1eed 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
@@ -108,3 +108,11 @@ size_t _sysprof_strlcpy (char *dest,
const char *src,
size_t dest_size);
#endif
+
+#ifdef HAVE_REALLOCARRAY
+# define _sysprof_reallocarray(p,m,n) reallocarray(p,m,n)
+#else
+void *_sysprof_reallocarray (void *ptr,
+ size_t m,
+ size_t n);
+#endif
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util.c b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util.c
index 0bbea06a..acb71acf 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util.c
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util.c
@@ -58,6 +58,7 @@
#include <assert.h>
#include <errno.h>
+#include <stdint.h>
#include <unistd.h>
#ifdef _WIN32
@@ -253,3 +254,15 @@ size_t
return i;
}
+
+void *
+(_sysprof_reallocarray) (void *ptr,
+ size_t m,
+ size_t n)
+{
+ if (n && m > (size_t)(-1) / n) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(ptr, m * n);
+}
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-writer-cat.c b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-writer-cat.c
index 66171b92..a157ed73 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-writer-cat.c
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-writer-cat.c
@@ -64,6 +64,7 @@
#include <unistd.h>
#include "sysprof-capture.h"
+#include "sysprof-capture-util-private.h"
#include "sysprof-macros-internal.h"
typedef struct
@@ -133,7 +134,7 @@ translate_table_add (TranslateTable *tables,
if (table_ptr->n_items == table_ptr->n_items_allocated)
{
table_ptr->n_items_allocated = (table_ptr->n_items_allocated > 0) ? table_ptr->n_items_allocated * 2 : 4;
- table_ptr->items = reallocarray (table_ptr->items, table_ptr->n_items_allocated, sizeof (*table_ptr->items));
+ table_ptr->items = _sysprof_reallocarray (table_ptr->items, table_ptr->n_items_allocated, sizeof (*table_ptr->items));
assert (table_ptr->items != NULL);
}
@@ -481,8 +482,8 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self,
if (n_elements == n_elements_allocated)
{
n_elements_allocated = (n_elements_allocated > 0) ? n_elements_allocated * 2 : 4;
- ids = reallocarray (ids, n_elements_allocated, sizeof (*ids));
- values = reallocarray (values, n_elements_allocated, sizeof (*values));
+ ids = _sysprof_reallocarray (ids, n_elements_allocated, sizeof (*ids));
+ values = _sysprof_reallocarray (values, n_elements_allocated, sizeof (*values));
if (ids == NULL || values == NULL)
goto panic;
}
--
GitLab
From 429223635e5a9a1de7903465ae1e8a5eb6d61be9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
<congdanhqx@gmail.com>
Date: Tue, 15 Sep 2020 08:47:12 +0700
Subject: [PATCH 2/3] compat: add TEMP_FAILURE_RETRY compatiable implementation
---
src/libsysprof-capture/sysprof-capture-util-private.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
index 13ec1eed..6181212c 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-util-private.h
@@ -60,10 +60,19 @@
# include <sys/sendfile.h>
#endif
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+ ({ long int __result; \
+ do { __result = (long int) (expression); } \
+ while (__result == -1L && errno == EINTR); \
+ __result; })
+#endif
+
static inline void *
sysprof_malloc0 (size_t size)
{
--
GitLab
From 088408c085e5d668c872769391787481875293a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
<congdanhqx@gmail.com>
Date: Tue, 15 Sep 2020 20:51:28 +0700
Subject: [PATCH 3/3] sysprof-capture-condition: always return even if
unreachable
Fix the problem with -Werror=return-type
---
src/libsysprof-capture/sysprof-capture-condition.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-condition.c b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-condition.c
index 8f891577..4b829a98 100644
--- a/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-condition.c
+++ b/subprojects/sysprof/src/libsysprof-capture/sysprof-capture-condition.c
@@ -269,6 +269,7 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
}
sysprof_assert_not_reached ();
+ return NULL;
}
static void
--
GitLab
|