Skip to content

Commit dcb4f20

Browse files
oanatitocrazvancrainea
authored andcommitted
dprint: Adapt log functions for g++ compiler
1 parent f9c671b commit dcb4f20

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

dprint.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/* used internally by the log interface */
4242
typedef void (*log_print_pre_fmt_f)(log_print_f gen_print_func, int log_level,
43-
int facility, char *module, const char *func,
43+
int facility, const char *module, const char *func,
4444
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap);
4545

4646
struct log_consumer_t {
@@ -72,16 +72,16 @@ int log_msg_buf_size = 4096;
7272

7373
str log_cee_hostname;
7474

75-
static void stderr_dprint(int log_level, int facility, char *module, const char *func,
75+
static void stderr_dprint(int log_level, int facility, const char *module, const char *func,
7676
char *format, va_list ap);
77-
static void syslog_dprint(int log_level, int facility, char *module, const char *func,
77+
static void syslog_dprint(int log_level, int facility, const char *module, const char *func,
7878
char *format, va_list ap);
7979

8080
static void stderr_pre_fmt_func(log_print_f gen_print_func, int log_level,
81-
int facility, char *module, const char *func,
81+
int facility, const char *module, const char *func,
8282
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap);
8383
static void syslog_pre_fmt_func(log_print_f gen_print_func, int log_level,
84-
int facility, char *module, const char *func,
84+
int facility, const char *module, const char *func,
8585
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap);
8686

8787
/* static consumer table to be used until a shm one is alloc'ed;
@@ -311,7 +311,7 @@ enum log_json_format {
311311
};
312312

313313
static int log_print_json(str *buf, enum log_json_format json_fmt, char *time,
314-
int pid, char *prefix, char *level, char *module, const char *func,
314+
int pid, char *prefix, const char *level, const char *module, const char *func,
315315
char *format, va_list ap)
316316
{
317317
char *p, *tmp;
@@ -454,7 +454,7 @@ static int log_print_json(str *buf, enum log_json_format json_fmt, char *time,
454454
return len;
455455
}
456456

457-
static void stderr_dprint(int log_level, int facility, char *module, const char *func,
457+
static void stderr_dprint(int log_level, int facility, const char *module, const char *func,
458458
char *format, va_list ap)
459459
{
460460
char *time;
@@ -486,7 +486,7 @@ static void stderr_dprint(int log_level, int facility, char *module, const char
486486
}
487487
}
488488

489-
static void syslog_dprint(int log_level, int facility, char *module, const char *func,
489+
static void syslog_dprint(int log_level, int facility, const char *module, const char *func,
490490
char *format, va_list ap)
491491
{
492492
int level;
@@ -553,7 +553,7 @@ static str evi_func_str = str_init("function");
553553
static str evi_prefix_str = str_init("prefix");
554554
static str evi_msg_str = str_init("message");
555555

556-
static void event_dprint(int level, int facility, char *module, const char *func,
556+
static void event_dprint(int level, int facility, const char *module, const char *func,
557557
char *format, va_list ap)
558558
{
559559
evi_params_p list = NULL;
@@ -652,7 +652,7 @@ static void event_dprint(int level, int facility, char *module, const char *func
652652

653653
/* generic consumer that registers to the log interface */
654654
static void gen_consumer_pre_fmt_func(log_print_f gen_print_func, int log_level,
655-
int facility, char *module, const char *func,
655+
int facility, const char *module, const char *func,
656656
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap)
657657
{
658658
/* skip the time, pid, prefix and function arguments from va_list */
@@ -666,7 +666,7 @@ static void gen_consumer_pre_fmt_func(log_print_f gen_print_func, int log_level,
666666
}
667667

668668
static void stderr_pre_fmt_func(log_print_f gen_print_func, int log_level,
669-
int facility, char *module, const char *func,
669+
int facility, const char *module, const char *func,
670670
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap)
671671
{
672672
char *fmt = stderr_log_format == LOG_FORMAT_PLAIN ? stderr_plain_fmt : format;
@@ -675,15 +675,15 @@ static void stderr_pre_fmt_func(log_print_f gen_print_func, int log_level,
675675
}
676676

677677
static void syslog_pre_fmt_func(log_print_f gen_print_func, int log_level,
678-
int facility, char *module, const char *func,
678+
int facility, const char *module, const char *func,
679679
char *stderr_plain_fmt, char *syslog_plain_fmt, char *format, va_list ap)
680680
{
681681
char *fmt = syslog_log_format == LOG_FORMAT_PLAIN ? syslog_plain_fmt : format;
682682

683683
gen_print_func(log_level, facility, module, func, fmt, ap);
684684
}
685685

686-
void dprint(int log_level, int facility, char *module, const char *func,
686+
void dprint(int log_level, int facility, const char *module, const char *func,
687687
char *stderr_fmt, char *syslog_fmt, char *format, ...)
688688
{
689689
va_list ap, ap_copy;

dprint.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#ifdef __SUNPRO_C
6969
#define DP_PREFIX
7070
#else
71-
#define DP_PREFIX "%s [%d] "
71+
#define DP_PREFIX (char *)"%s [%d] "
7272
#endif
7373

7474
#define DP_ALERT_STR "ALERT"
@@ -170,7 +170,7 @@ int dp_my_pid(void);
170170

171171
void stderr_dprint_tmp(char *format, ...);
172172

173-
void dprint(int log_level, int facility, char *module, const char *func,
173+
void dprint(int log_level, int facility, const char *module, const char *func,
174174
char *stderr_fmt, char *syslog_fmt, char *format, ...)
175175
__attribute__ ((__format__ (__printf__, 5, 8)));
176176

@@ -206,9 +206,9 @@ static inline char* dp_time(void)
206206
return ctime_buf+4; /* remove name of day*/
207207
}
208208

209-
static inline char *dp_log_level_str(int log_level)
209+
static inline const char *dp_log_level_str(int log_level)
210210
{
211-
char *level_str;
211+
const char *level_str;
212212

213213
switch (log_level) {
214214
case L_ALERT:
@@ -454,8 +454,8 @@ static inline char *dp_log_level_str(int log_level)
454454
dprint(_log_level, _log_facility, \
455455
LOG_PREFIX_UTIL(MOD_NAME), __DP_FUNC, \
456456
_stderr_prefix LOG_PREFIX _fmt, \
457-
"%s" _syslog_prefix LOG_PREFIX _fmt, \
458-
_fmt, \
457+
(char *)"%s" _syslog_prefix LOG_PREFIX _fmt, \
458+
(char *)_fmt, \
459459
dp_time(), dp_my_pid(), log_prefix, __DP_FUNC, ## args) \
460460

461461
#define LM_GEN(_lev, fmt, args...) \

log_interface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <stdarg.h>
2626

2727
/* printing function to be registered by a generic logging consumer */
28-
typedef void (*log_print_f)(int log_level, int facility, char *module, const char *func,
28+
typedef void (*log_print_f)(int log_level, int facility, const char *module, const char *func,
2929
char *format, va_list ap);
3030

3131
int register_log_consumer(char *name, log_print_f print_func,

0 commit comments

Comments
 (0)