Added type casting from debug_t to int

This commit is contained in:
thorkill 2015-06-29 14:17:40 +02:00
parent 0ef605d864
commit 3bfb343b85

View file

@ -48,10 +48,10 @@ static void real_logger(int level, int priority, const char *message) {
if(suppress) if(suppress)
return; return;
if(!logcontrol && (level > debug_level || logmode == LOGMODE_NULL)) if(!logcontrol && (level > (int)debug_level || logmode == LOGMODE_NULL))
return; return;
if(level <= debug_level) { if(level <= (int)debug_level) {
switch(logmode) { switch(logmode) {
case LOGMODE_STDERR: case LOGMODE_STDERR:
fprintf(stderr, "%s\n", message); fprintf(stderr, "%s\n", message);
@ -94,7 +94,7 @@ static void real_logger(int level, int priority, const char *message) {
if(!c->status.log) if(!c->status.log)
continue; continue;
logcontrol = true; logcontrol = true;
if(level > (c->outcompression >= 0 ? c->outcompression : debug_level)) if(level > (c->outcompression >= 0 ? (int)c->outcompression : (int)debug_level))
continue; continue;
int len = strlen(message); int len = strlen(message);
if(send_request(c, "%d %d %d", CONTROL, REQ_LOG, len)) if(send_request(c, "%d %d %d", CONTROL, REQ_LOG, len))
@ -109,10 +109,10 @@ void logger(int level, int priority, const char *format, ...) {
char message[1024] = ""; char message[1024] = "";
va_start(ap, format); va_start(ap, format);
int len = vsnprintf(message, sizeof message, format, ap); int len = vsnprintf(message, sizeof(message), format, ap);
va_end(ap); va_end(ap);
if(len > 0 && len < sizeof message && message[len - 1] == '\n') if(len > 0 && len < (int)sizeof(message) && message[len - 1] == '\n')
message[len - 1] = 0; message[len - 1] = 0;
real_logger(level, priority, message); real_logger(level, priority, message);
@ -123,7 +123,7 @@ static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap
size_t msglen = sizeof message; size_t msglen = sizeof message;
int len = vsnprintf(message, msglen, format, ap); int len = vsnprintf(message, msglen, format, ap);
if(len > 0 && len < sizeof message) { if(len > 0 && len < (int)sizeof(message)) {
if(message[len - 1] == '\n') if(message[len - 1] == '\n')
message[--len] = 0; message[--len] = 0;
@ -131,7 +131,7 @@ static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap
// but both types have the name and hostname fields at the same offsets. // but both types have the name and hostname fields at the same offsets.
connection_t *c = s->handle; connection_t *c = s->handle;
if(c) if(c)
snprintf(message + len, sizeof message - len, " from %s (%s) [errno: %d]", c->name, c->hostname, s_errno); snprintf(message + len, sizeof(message) - (unsigned long)len, " from %s (%s) [errno: %d]", c->name, c->hostname, s_errno);
} }
real_logger(DEBUG_ALWAYS, LOG_ERR, message); real_logger(DEBUG_ALWAYS, LOG_ERR, message);