Skip to content

Commit fd5c9db

Browse files
authored
Merge pull request #1974 from jan-cerny/data_races
Prevent data race
2 parents 90ce15f + 7372188 commit fd5c9db

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/common/debug.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,15 @@ static const char *__oscap_path_rstrip(const char *path)
187187
}
188188

189189

190-
static void debug_message_start(int level, int indent)
190+
static void debug_message_start(int level, int delta_indent)
191191
{
192192
char l;
193+
static int indent = 0;
193194

194195
__LOCK_FP;
195196

197+
indent += delta_indent;
198+
196199
switch (level) {
197200
case DBG_E:
198201
l = 'E';
@@ -250,21 +253,19 @@ static void debug_message_end()
250253

251254
void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, int delta_indent, const char *fmt, ...)
252255
{
253-
static int indent = 0;
254256
va_list ap;
255257

256258
if (__debuglog_fp == NULL) {
257259
return;
258260
}
259-
indent += delta_indent;
260261
if (fmt == NULL) {
261262
return;
262263
}
263264
if (__debuglog_level < level) {
264265
return;
265266
}
266267
va_start(ap, fmt);
267-
debug_message_start(level, indent);
268+
debug_message_start(level, delta_indent);
268269
vfprintf(__debuglog_fp, fmt, ap);
269270
if (__debuglog_level == DBG_D) {
270271
debug_message_devel_metadata(file, fn, line);

0 commit comments

Comments
 (0)