diff --git a/src/ctl/ctl-cli.c b/src/ctl/ctl-cli.c index 72d1eba..dd61ff0 100644 --- a/src/ctl/ctl-cli.c +++ b/src/ctl/ctl-cli.c @@ -47,7 +47,7 @@ static sd_event_source *cli_sigs[_NSIG]; static sd_event_source *cli_stdin; static bool cli_rl; static const struct cli_cmd *cli_cmds; -int cli_max_sev = LOG_NOTICE; +unsigned int cli_max_sev = LOG_NOTICE; static bool is_cli(void) { diff --git a/src/ctl/ctl-sink.c b/src/ctl/ctl-sink.c index e771f52..2d72e18 100644 --- a/src/ctl/ctl-sink.c +++ b/src/ctl/ctl-sink.c @@ -213,7 +213,7 @@ static void sink_handle_set_parameter(struct ctl_sink *s, _rtsp_message_unref_ struct rtsp_message *rep = NULL; const char *trigger; const char *url; - const char *uibc_config; + char *uibc_config; const char *uibc_setting; char *nu; unsigned int cea_res, vesa_res, hh_res; diff --git a/src/ctl/ctl.h b/src/ctl/ctl.h index 077cc49..75cc0a3 100644 --- a/src/ctl/ctl.h +++ b/src/ctl/ctl.h @@ -120,7 +120,7 @@ bool ctl_sink_is_closed(struct ctl_sink *s); /* CLI handling */ -extern int cli_max_sev; +extern unsigned int cli_max_sev; void cli_printv(const char *fmt, va_list args); void cli_printf(const char *fmt, ...); diff --git a/src/shared/shl_log.c b/src/shared/shl_log.c index dc7ef55..2e983cf 100644 --- a/src/shared/shl_log.c +++ b/src/shared/shl_log.c @@ -12,6 +12,7 @@ #include #include #include +#include #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; } diff --git a/src/shared/shl_log.h b/src/shared/shl_log.h index e645948..ed9afa1 100644 --- a/src/shared/shl_log.h +++ b/src/shared/shl_log.h @@ -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, ...) diff --git a/src/uibc/miracle-uibcctl.c b/src/uibc/miracle-uibcctl.c index 79b92e0..2c8835b 100644 --- a/src/uibc/miracle-uibcctl.c +++ b/src/uibc/miracle-uibcctl.c @@ -106,7 +106,7 @@ const char *int2binary(int x, int padding) int sendUibcMessage(UibcMessage* uibcmessage, int sockfd) { ssize_t n; - printf("sending %d bytes\n", uibcmessage->m_PacketDataLen); + printf("sending %zu bytes\n", uibcmessage->m_PacketDataLen); n = write(sockfd, uibcmessage->m_PacketData , uibcmessage->m_PacketDataLen); @@ -249,7 +249,7 @@ void getUIBCGenericTouchPacket(const char *inEventDesc, void hexdump(void *_data, size_t len) { unsigned char *data = _data; - int count; + size_t count; int line = 15; for (count = 0; count < len; count++) { @@ -270,7 +270,7 @@ void hexdump(void *_data, size_t len) void binarydump(void *_data, size_t len) { unsigned char *data = _data; - int count; + size_t count; int line = 7; for (count = 0; count < len; count++) {