1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

Fix compilation warnings

This commit is contained in:
albfan 2016-10-23 03:58:47 +02:00
parent cd23da3c74
commit 5e93ad0638
6 changed files with 27 additions and 10 deletions

View file

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <limits.h>
#include "shl_log.h"
/*
@ -239,9 +240,9 @@ void log_llog(void *data,
log_submit(file, line, func, subs, sev, format, args);
}
int log_parse_arg(char *optarg)
unsigned int log_parse_arg(char *optarg)
{
int log_max_sev;
unsigned int log_max_sev;
if(!strcasecmp(optarg, "fatal")) {
log_max_sev = LOG_FATAL;
} else if(!strcasecmp(optarg, "alert")) {
@ -261,7 +262,23 @@ int log_parse_arg(char *optarg)
} else if(!strcasecmp(optarg, "trace")) {
log_max_sev = LOG_TRACE;
} else {
log_max_sev = atoi(optarg);
errno = 0;
char *temp;
long val = strtoul(optarg, &temp, 0);
if (temp == optarg || *temp != '\0'
|| ((val == LONG_MIN || val == LONG_MAX) && errno == ERANGE)) {
log_error("Could not convert '%s' to long and leftover string is: '%s'\n", optarg, temp);
}
if (val > INT_MAX) {
errno = ERANGE;
return INT_MAX;
}
if (val < INT_MIN) {
errno = ERANGE;
return INT_MIN;
}
log_max_sev = (unsigned int) val;
}
return log_max_sev;
}

View file

@ -116,7 +116,7 @@ void log_llog(void *data,
const char *format,
va_list args);
int log_parse_arg(char *optarg);
unsigned int log_parse_arg(char *optarg);
static inline __attribute__((format(printf, 2, 3)))
void log_dummyf(unsigned int sev, const char *format, ...)