libevent: silence -Wconversion warnings.
This commit is contained in:
@@ -73,11 +73,11 @@ enum eventlog_format {
|
|||||||
struct eventlog_config {
|
struct eventlog_config {
|
||||||
int type;
|
int type;
|
||||||
enum eventlog_format format;
|
enum eventlog_format format;
|
||||||
|
size_t file_maxlen;
|
||||||
|
size_t syslog_maxlen;
|
||||||
int syslog_acceptpri;
|
int syslog_acceptpri;
|
||||||
int syslog_rejectpri;
|
int syslog_rejectpri;
|
||||||
int syslog_alertpri;
|
int syslog_alertpri;
|
||||||
int syslog_maxlen;
|
|
||||||
int file_maxlen;
|
|
||||||
uid_t mailuid;
|
uid_t mailuid;
|
||||||
bool omit_hostname;
|
bool omit_hostname;
|
||||||
const char *logpath;
|
const char *logpath;
|
||||||
@@ -146,8 +146,8 @@ void eventlog_set_format(enum eventlog_format format);
|
|||||||
void eventlog_set_syslog_acceptpri(int pri);
|
void eventlog_set_syslog_acceptpri(int pri);
|
||||||
void eventlog_set_syslog_rejectpri(int pri);
|
void eventlog_set_syslog_rejectpri(int pri);
|
||||||
void eventlog_set_syslog_alertpri(int pri);
|
void eventlog_set_syslog_alertpri(int pri);
|
||||||
void eventlog_set_syslog_maxlen(int len);
|
void eventlog_set_syslog_maxlen(size_t len);
|
||||||
void eventlog_set_file_maxlen(int len);
|
void eventlog_set_file_maxlen(size_t len);
|
||||||
void eventlog_set_mailuid(uid_t uid);
|
void eventlog_set_mailuid(uid_t uid);
|
||||||
void eventlog_set_omit_hostname(bool omit_hostname);
|
void eventlog_set_omit_hostname(bool omit_hostname);
|
||||||
void eventlog_set_logpath(const char *path);
|
void eventlog_set_logpath(const char *path);
|
||||||
|
@@ -1136,7 +1136,7 @@ do_logfile_sudo(const char *logline, const struct eventlog *evlog,
|
|||||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
eventlog_writeln(fp, full_line, len, evl_conf->file_maxlen);
|
eventlog_writeln(fp, full_line, (size_t)len, evl_conf->file_maxlen);
|
||||||
free(full_line);
|
free(full_line);
|
||||||
(void)fflush(fp);
|
(void)fflush(fp);
|
||||||
if (ferror(fp)) {
|
if (ferror(fp)) {
|
||||||
|
@@ -139,13 +139,13 @@ eventlog_set_syslog_alertpri(int pri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eventlog_set_syslog_maxlen(int len)
|
eventlog_set_syslog_maxlen(size_t len)
|
||||||
{
|
{
|
||||||
evl_conf.syslog_maxlen = len;
|
evl_conf.syslog_maxlen = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eventlog_set_file_maxlen(int len)
|
eventlog_set_file_maxlen(size_t len)
|
||||||
{
|
{
|
||||||
evl_conf.file_maxlen = len;
|
evl_conf.file_maxlen = len;
|
||||||
}
|
}
|
||||||
|
@@ -46,10 +46,10 @@ eventlog_writeln(FILE *fp, char *line, size_t linelen, size_t maxlen)
|
|||||||
/* Maximum length too small, disable wrapping. */
|
/* Maximum length too small, disable wrapping. */
|
||||||
outlen = fwrite(line, 1, linelen, fp);
|
outlen = fwrite(line, 1, linelen, fp);
|
||||||
if (outlen != linelen)
|
if (outlen != linelen)
|
||||||
debug_return_ssize_t(-1);
|
debug_return_size_t((size_t)-1);
|
||||||
if (fputc('\n', fp) == EOF)
|
if (fputc('\n', fp) == EOF)
|
||||||
debug_return_ssize_t(-1);
|
debug_return_size_t((size_t)-1);
|
||||||
debug_return_int(outlen + 1);
|
debug_return_size_t(outlen + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -67,11 +67,11 @@ eventlog_writeln(FILE *fp, char *line, size_t linelen, size_t maxlen)
|
|||||||
}
|
}
|
||||||
len = fprintf(fp, "%s%.*s\n", indent, (int)(end - beg), beg);
|
len = fprintf(fp, "%s%.*s\n", indent, (int)(end - beg), beg);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
debug_return_ssize_t(-1);
|
debug_return_size_t((size_t)-1);
|
||||||
outlen += len;
|
outlen += (size_t)len;
|
||||||
while (*end == ' ')
|
while (*end == ' ')
|
||||||
end++;
|
end++;
|
||||||
linelen -= (end - beg);
|
linelen -= (size_t)(end - beg);
|
||||||
beg = end;
|
beg = end;
|
||||||
if (indent[0] == '\0') {
|
if (indent[0] == '\0') {
|
||||||
indent = EVENTLOG_INDENT;
|
indent = EVENTLOG_INDENT;
|
||||||
@@ -82,8 +82,8 @@ eventlog_writeln(FILE *fp, char *line, size_t linelen, size_t maxlen)
|
|||||||
if (linelen) {
|
if (linelen) {
|
||||||
len = fprintf(fp, "%s%s\n", indent, beg);
|
len = fprintf(fp, "%s%s\n", indent, beg);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
debug_return_ssize_t(-1);
|
debug_return_size_t((size_t)-1);
|
||||||
outlen += len;
|
outlen += (size_t)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_return_size_t(outlen);
|
debug_return_size_t(outlen);
|
||||||
|
@@ -67,7 +67,7 @@ json_store_columns(struct json_item *item, struct eventlog *evlog)
|
|||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
evlog->columns = item->u.number;
|
evlog->columns = (int)item->u.number;
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ json_store_exit_value(struct json_item *item, struct eventlog *evlog)
|
|||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
evlog->exit_value = item->u.number;
|
evlog->exit_value = (int)item->u.number;
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ json_store_lines(struct json_item *item, struct eventlog *evlog)
|
|||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
evlog->lines = item->u.number;
|
evlog->lines = (int)item->u.number;
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,7 +503,7 @@ json_parse_string(char **strp)
|
|||||||
debug_return_str(NULL);
|
debug_return_str(NULL);
|
||||||
}
|
}
|
||||||
while (src < end) {
|
while (src < end) {
|
||||||
char ch = *src++;
|
int ch = *src++;
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
switch (*src) {
|
switch (*src) {
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -541,7 +541,7 @@ json_parse_string(char **strp)
|
|||||||
}
|
}
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
*dst++ = ch;
|
*dst++ = (char)ch;
|
||||||
}
|
}
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
|
|
||||||
@@ -775,9 +775,9 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
struct json_stack stack = JSON_STACK_INTIALIZER(stack);
|
struct json_stack stack = JSON_STACK_INTIALIZER(stack);
|
||||||
unsigned int lineno = 0;
|
unsigned int lineno = 0;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *cp, *buf = NULL;
|
char *cp, *line = NULL;
|
||||||
size_t bufsize = 0;
|
size_t len, linesize = 0;
|
||||||
ssize_t len;
|
ssize_t linelen;
|
||||||
bool saw_comma = false;
|
bool saw_comma = false;
|
||||||
long long num;
|
long long num;
|
||||||
char ch;
|
char ch;
|
||||||
@@ -791,9 +791,9 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
TAILQ_INIT(&root->items);
|
TAILQ_INIT(&root->items);
|
||||||
|
|
||||||
frame = root;
|
frame = root;
|
||||||
while ((len = getdelim(&buf, &bufsize, '\n', fp)) != -1) {
|
while ((linelen = getdelim(&line, &linesize, '\n', fp)) != -1) {
|
||||||
char *ep = buf + len - 1;
|
char *ep = line + linelen - 1;
|
||||||
cp = buf;
|
cp = line;
|
||||||
|
|
||||||
lineno++;
|
lineno++;
|
||||||
|
|
||||||
@@ -824,12 +824,12 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
switch (*cp) {
|
switch (*cp) {
|
||||||
case '{':
|
case '{':
|
||||||
if (name == NULL && frame->parent != NULL) {
|
if (name == NULL && frame->parent != NULL) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("objects must consist of name:value pairs"));
|
U_("objects must consist of name:value pairs"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -844,7 +844,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
case '}':
|
case '}':
|
||||||
if (stack.depth == 0 || frame->parent == NULL ||
|
if (stack.depth == 0 || frame->parent == NULL ||
|
||||||
frame->parent->type != JSON_OBJECT) {
|
frame->parent->type != JSON_OBJECT) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unmatched close brace"));
|
U_("unmatched close brace"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -855,12 +855,12 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
case '[':
|
case '[':
|
||||||
if (frame->parent == NULL) {
|
if (frame->parent == NULL) {
|
||||||
/* Must have an enclosing object. */
|
/* Must have an enclosing object. */
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected array"));
|
U_("unexpected array"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -875,7 +875,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
case ']':
|
case ']':
|
||||||
if (stack.depth == 0 || frame->parent == NULL ||
|
if (stack.depth == 0 || frame->parent == NULL ||
|
||||||
frame->parent->type != JSON_ARRAY) {
|
frame->parent->type != JSON_ARRAY) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unmatched close bracket"));
|
U_("unmatched close bracket"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -886,7 +886,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
case '"':
|
case '"':
|
||||||
if (frame->parent == NULL) {
|
if (frame->parent == NULL) {
|
||||||
/* Must have an enclosing object. */
|
/* Must have an enclosing object. */
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected string"));
|
U_("unexpected string"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -897,14 +897,14 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
goto bad;
|
goto bad;
|
||||||
/* TODO: allow colon on next line? */
|
/* TODO: allow colon on next line? */
|
||||||
if (*cp != ':') {
|
if (*cp != ':') {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing colon after name"));
|
U_("missing colon after name"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
cp++;
|
cp++;
|
||||||
} else {
|
} else {
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -918,7 +918,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (strncmp(cp, "true", sizeof("true") - 1) != 0)
|
if (strncmp(cp, "true", sizeof("true") - 1) != 0)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected boolean"));
|
U_("unexpected boolean"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -926,7 +926,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -940,7 +940,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (strncmp(cp, "false", sizeof("false") - 1) != 0)
|
if (strncmp(cp, "false", sizeof("false") - 1) != 0)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected boolean"));
|
U_("unexpected boolean"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -948,7 +948,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -962,7 +962,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (strncmp(cp, "null", sizeof("null") - 1) != 0)
|
if (strncmp(cp, "null", sizeof("null") - 1) != 0)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected null"));
|
U_("unexpected null"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -970,7 +970,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -983,7 +983,7 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
case '+': case '-': case '0': case '1': case '2': case '3':
|
case '+': case '-': case '0': case '1': case '2': case '3':
|
||||||
case '4': case '5': case '6': case '7': case '8': case '9':
|
case '4': case '5': case '6': case '7': case '8': case '9':
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unexpected number"));
|
U_("unexpected number"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -992,14 +992,14 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
ch = cp[len];
|
ch = cp[len];
|
||||||
cp[len] = '\0';
|
cp[len] = '\0';
|
||||||
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
if (!saw_comma && !TAILQ_EMPTY(&frame->items)) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("missing separator between values"));
|
U_("missing separator between values"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
saw_comma = false;
|
saw_comma = false;
|
||||||
num = sudo_strtonum(cp, LLONG_MIN, LLONG_MAX, &errstr);
|
num = sudo_strtonum(cp, LLONG_MIN, LLONG_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx("%s:%u:%td: %s: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s: %s", filename, lineno, cp - line,
|
||||||
cp, U_(errstr));
|
cp, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -1018,10 +1018,10 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
if (stack.depth != 0) {
|
if (stack.depth != 0) {
|
||||||
frame = stack.frames[stack.depth - 1];
|
frame = stack.frames[stack.depth - 1];
|
||||||
if (frame->parent == NULL || frame->parent->type == JSON_OBJECT) {
|
if (frame->parent == NULL || frame->parent->type == JSON_OBJECT) {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unmatched close brace"));
|
U_("unmatched close brace"));
|
||||||
} else {
|
} else {
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf,
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line,
|
||||||
U_("unmatched close bracket"));
|
U_("unmatched close bracket"));
|
||||||
}
|
}
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -1030,12 +1030,12 @@ eventlog_json_read(FILE *fp, const char *filename)
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - buf, U_("parse error"));
|
sudo_warnx("%s:%u:%td: %s", filename, lineno, cp - line, U_("parse error"));
|
||||||
bad:
|
bad:
|
||||||
eventlog_json_free(root);
|
eventlog_json_free(root);
|
||||||
root = NULL;
|
root = NULL;
|
||||||
done:
|
done:
|
||||||
free(buf);
|
free(line);
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
debug_return_ptr(root);
|
debug_return_ptr(root);
|
||||||
|
@@ -69,7 +69,7 @@ compare(FILE *fp, const char *infile, struct json_container *jsonc)
|
|||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
|
|
||||||
if (strncmp(line, cp, len) != 0) {
|
if (strncmp(line, cp, (size_t)len) != 0) {
|
||||||
fprintf(stderr, "%s: mismatch on line %u\n", infile, lineno);
|
fprintf(stderr, "%s: mismatch on line %u\n", infile, lineno);
|
||||||
fprintf(stderr, "expected: %s", line);
|
fprintf(stderr, "expected: %s", line);
|
||||||
fprintf(stderr, "got : %.*s\n", (int)len, cp);
|
fprintf(stderr, "got : %.*s\n", (int)len, cp);
|
||||||
|
@@ -51,7 +51,7 @@ compare(FILE *fp, const char *infile, const char *output)
|
|||||||
|
|
||||||
/* Expect two log lines, one for accept, one for exit. */
|
/* Expect two log lines, one for accept, one for exit. */
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
ssize_t output_len = strcspn(output, "\n");
|
ssize_t output_len = (ssize_t)strcspn(output, "\n");
|
||||||
ssize_t len = getdelim(&line, &linesize, '\n', fp);
|
ssize_t len = getdelim(&line, &linesize, '\n', fp);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
sudo_warn("getdelim");
|
sudo_warn("getdelim");
|
||||||
@@ -60,7 +60,7 @@ compare(FILE *fp, const char *infile, const char *output)
|
|||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
|
|
||||||
if (len != output_len || strncmp(line, output, len) != 0) {
|
if (len != output_len || strncmp(line, output, (size_t)len) != 0) {
|
||||||
fprintf(stderr, "%s: %s mismatch\n", infile, i ? "exit" : "accept");
|
fprintf(stderr, "%s: %s mismatch\n", infile, i ? "exit" : "accept");
|
||||||
fprintf(stderr, "expected: %.*s\n", (int)len, line);
|
fprintf(stderr, "expected: %.*s\n", (int)len, line);
|
||||||
fprintf(stderr, "got : %.*s\n", (int)output_len, output);
|
fprintf(stderr, "got : %.*s\n", (int)output_len, output);
|
||||||
|
@@ -98,11 +98,11 @@ main(int argc, char *argv[])
|
|||||||
dash = strchr(cp, '-');
|
dash = strchr(cp, '-');
|
||||||
if (dash != NULL) {
|
if (dash != NULL) {
|
||||||
*dash = '\0';
|
*dash = '\0';
|
||||||
len = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
len = (size_t)sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
maxlen = sudo_strtonum(dash + 1, 0, INT_MAX, &errstr);
|
maxlen = (size_t)sudo_strtonum(dash + 1, 0, INT_MAX, &errstr);
|
||||||
} else {
|
} else {
|
||||||
len = maxlen = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
len = maxlen = (size_t)sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
}
|
}
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_fatalx("%s: invalid length on line %d", infile, lineno);
|
sudo_fatalx("%s: invalid length on line %d", infile, lineno);
|
||||||
|
@@ -155,7 +155,7 @@ compare(FILE *fp, const char *infile, struct json_container *jsonc)
|
|||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
|
|
||||||
if (strncmp(line, cp, len) != 0) {
|
if (strncmp(line, cp, (size_t)len) != 0) {
|
||||||
fprintf(stderr, "%s: mismatch on line %u\n", infile, lineno);
|
fprintf(stderr, "%s: mismatch on line %u\n", infile, lineno);
|
||||||
fprintf(stderr, "expected: %s", line);
|
fprintf(stderr, "expected: %s", line);
|
||||||
fprintf(stderr, "got : %.*s\n", (int)len, cp);
|
fprintf(stderr, "got : %.*s\n", (int)len, cp);
|
||||||
|
Reference in New Issue
Block a user