Skip to content

Commit c44baeb

Browse files
committed
Removed "thread"-s from error.c
1 parent a8eb1a6 commit c44baeb

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

error.c

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <string.h>
3030
#include <stdarg.h>
3131
#include <syslog.h>
32-
#include <pthread.h> /* pthread_self() */
3332
#include "error.h"
3433
#include "common.h"
3534
#include "configuration.h"
@@ -42,8 +41,6 @@ static int *debug = &zero;
4241
static int *quiet = &zero;
4342
static int *verbose = &three;
4443

45-
pthread_mutex_t error_mutex = PTHREAD_MUTEX_INITIALIZER;
46-
4744
static int printf_stderr(const char *fmt, ...) {
4845
va_list args;
4946
int rc;
@@ -170,15 +167,12 @@ void _critical(const char *const function_name, const char *fmt, ...) {
170167
if (*quiet)
171168
return;
172169

173-
pthread_mutex_lock(&error_mutex);
174-
175170
outputmethod_t method = *outputmethod;
176171

177172
{
178173
va_list args;
179-
pthread_t thread = pthread_self();
180174

181-
outfunct[method]("Critical (thread %p): %s(): ", thread, function_name);
175+
outfunct[method]("Critical: %s(): ", function_name);
182176
va_start(args, fmt);
183177
voutfunct[method](fmt, args);
184178
va_end(args);
@@ -197,7 +191,6 @@ void _critical(const char *const function_name, const char *fmt, ...) {
197191
outfunct[method]("_critical(): Got error, but cannot print the backtrace. Current errno: %u: %s\n",
198192
errno, strerror(errno));
199193
flushfunct[method](LOG_CRIT);
200-
pthread_mutex_unlock(&error_mutex);
201194
exit(EXIT_FAILURE);
202195
}
203196

@@ -208,7 +201,6 @@ void _critical(const char *const function_name, const char *fmt, ...) {
208201
}
209202
#endif
210203

211-
pthread_mutex_unlock(&error_mutex);
212204
exit(errno);
213205

214206
return;
@@ -223,20 +215,16 @@ void _error(const char *const function_name, const char *fmt, ...) {
223215
if (*verbose < 1)
224216
return;
225217

226-
pthread_mutex_lock(&error_mutex);
227-
228-
pthread_t thread = pthread_self();
229218
outputmethod_t method = *outputmethod;
230219

231-
outfunct[method](*debug ? "Error (thread %p): %s(): " : "Error: ", thread, function_name);
220+
outfunct[method](*debug ? "Error: %s(): " : "Error: ", function_name);
232221
va_start(args, fmt);
233222
voutfunct[method](fmt, args);
234223
va_end(args);
235224
if (errno)
236225
outfunct[method](" (%i: %s)", errno, strerror(errno));
237226
flushfunct[method](LOG_ERR);
238227

239-
pthread_mutex_unlock(&error_mutex);
240228
return;
241229
}
242230

@@ -249,18 +237,14 @@ void _info_short(const char *const function_name, const char *fmt, ...) {
249237
if (*verbose < 3)
250238
return;
251239

252-
pthread_mutex_lock(&error_mutex);
253-
254-
pthread_t thread = pthread_self();
255240
outputmethod_t method = *outputmethod;
256241

257-
outfunct[method](*debug ? "Info (thread %p): %s(): " : "", thread, function_name);
242+
outfunct[method](*debug ? "Info: %s(): " : "", function_name);
258243
va_start(args, fmt);
259244
voutfunct[method](fmt, args);
260245
va_end(args);
261246
flushfunct[method](LOG_INFO);
262247

263-
pthread_mutex_unlock(&error_mutex);
264248
return;
265249
}
266250

@@ -273,18 +257,14 @@ void _info(const char *const function_name, const char *fmt, ...) {
273257
if (*verbose < 3)
274258
return;
275259

276-
pthread_mutex_lock(&error_mutex);
277-
278-
pthread_t thread = pthread_self();
279260
outputmethod_t method = *outputmethod;
280261

281-
outfunct[method](*debug ? "Info (thread %p): %s(): " : "Info: ", thread, function_name);
262+
outfunct[method](*debug ? "Info: %s(): " : "Info: ", function_name);
282263
va_start(args, fmt);
283264
voutfunct[method](fmt, args);
284265
va_end(args);
285266
flushfunct[method](LOG_INFO);
286267

287-
pthread_mutex_unlock(&error_mutex);
288268
return;
289269
}
290270

@@ -297,18 +277,14 @@ void _warning(const char *const function_name, const char *fmt, ...) {
297277
if (*verbose < 2)
298278
return;
299279

300-
pthread_mutex_lock(&error_mutex);
301-
302-
pthread_t thread = pthread_self();
303280
outputmethod_t method = *outputmethod;
304281

305-
outfunct[method](*debug ? "Warning (thread %p): %s(): " : "Warning: ", thread, function_name);
282+
outfunct[method](*debug ? "Warning: %s(): " : "Warning: ", function_name);
306283
va_start(args, fmt);
307284
voutfunct[method](fmt, args);
308285
va_end(args);
309286
flushfunct[method](LOG_WARNING);
310287

311-
pthread_mutex_unlock(&error_mutex);
312288
return;
313289
}
314290

@@ -321,18 +297,14 @@ void _debug(int debug_level, const char *const function_name, const char *fmt, .
321297
if (debug_level > *debug)
322298
return;
323299

324-
pthread_mutex_lock(&error_mutex);
325-
326-
pthread_t thread = pthread_self();
327300
outputmethod_t method = *outputmethod;
328301

329-
outfunct[method]("Debug%u (thread %p): %s(): ", debug_level, thread, function_name);
302+
outfunct[method]("Debug%u: %s(): ", debug_level, function_name);
330303
va_start(args, fmt);
331304
voutfunct[method](fmt, args);
332305
va_end(args);
333306
flushfunct[method](LOG_DEBUG);
334307

335-
pthread_mutex_unlock(&error_mutex);
336308
return;
337309
}
338310

@@ -341,9 +313,6 @@ void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug) {
341313
quiet = _quiet;
342314
verbose = _verbose;
343315
debug = _debug;
344-
345-
pthread_mutex_init(&error_mutex, NULL);
346-
347316
return;
348317
}
349318

0 commit comments

Comments
 (0)