Make the debug subsystem unsigned.
It was already unsigned in sudoers but not in the front-end or the python plugin. Making this consistent resolves a lot of -Wconversion warnings. Also clean up some other -Wconversion warnings in sudo_debug.c.
This commit is contained in:
@@ -409,7 +409,7 @@ sudo_debug_deregister_v1(int idx)
|
||||
return -1; /* already deregistered */
|
||||
|
||||
if (--instance->refcnt != 0)
|
||||
return instance->refcnt; /* ref held by other caller */
|
||||
return (int)instance->refcnt; /* ref held by other caller */
|
||||
|
||||
/* Free up instance data, note that subsystems[] is owned by caller. */
|
||||
sudo_debug_instances[idx] = NULL;
|
||||
@@ -497,7 +497,7 @@ sudo_debug_fork_v1(void)
|
||||
|
||||
void
|
||||
sudo_debug_enter_v1(const char *func, const char *file, int line,
|
||||
int subsys)
|
||||
unsigned int subsys)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"-> %s @ %s:%d", func, file, line);
|
||||
@@ -505,7 +505,7 @@ sudo_debug_enter_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_v1(const char *func, const char *file, int line,
|
||||
int subsys)
|
||||
unsigned int subsys)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d", func, file, line);
|
||||
@@ -513,7 +513,7 @@ sudo_debug_exit_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_int_v1(const char *func, const char *file, int line,
|
||||
int subsys, int ret)
|
||||
unsigned int subsys, int ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %d", func, file, line, ret);
|
||||
@@ -521,7 +521,7 @@ sudo_debug_exit_int_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_long_v1(const char *func, const char *file, int line,
|
||||
int subsys, long ret)
|
||||
unsigned int subsys, long ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %ld", func, file, line, ret);
|
||||
@@ -529,7 +529,7 @@ sudo_debug_exit_long_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_id_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, id_t ret)
|
||||
unsigned int subsys, id_t ret)
|
||||
{
|
||||
#if SIZEOF_ID_T == 8
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
@@ -542,7 +542,7 @@ sudo_debug_exit_id_t_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, size_t ret)
|
||||
unsigned int subsys, size_t ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %zu", func, file, line, ret);
|
||||
@@ -550,7 +550,7 @@ sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, ssize_t ret)
|
||||
unsigned int subsys, ssize_t ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %zd", func, file, line, ret);
|
||||
@@ -558,7 +558,7 @@ sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_time_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, time_t ret)
|
||||
unsigned int subsys, time_t ret)
|
||||
{
|
||||
#if SIZEOF_TIME_T == 8
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
@@ -571,7 +571,7 @@ sudo_debug_exit_time_t_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
|
||||
int subsys, bool ret)
|
||||
unsigned int subsys, bool ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %s", func, file, line, ret ? "true" : "false");
|
||||
@@ -579,7 +579,7 @@ sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_str_v1(const char *func, const char *file, int line,
|
||||
int subsys, const char *ret)
|
||||
unsigned int subsys, const char *ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %s", func, file, line, ret ? ret : "(null)");
|
||||
@@ -587,18 +587,19 @@ sudo_debug_exit_str_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line,
|
||||
int subsys, const char *ret)
|
||||
unsigned int subsys, const char *ret)
|
||||
{
|
||||
static const char stars[] = "********************************************************************************";
|
||||
int len = ret ? strlen(ret) : sizeof("(null)") - 1;
|
||||
const size_t len = ret ? strlen(ret) : sizeof("(null)") - 1;
|
||||
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %.*s", func, file, line, len, ret ? stars : "(null)");
|
||||
"<- %s @ %s:%d := %.*s", func, file, line, (int)len,
|
||||
ret ? stars : "(null)");
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
|
||||
int subsys, const void *ret)
|
||||
unsigned int subsys, const void *ret)
|
||||
{
|
||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
||||
"<- %s @ %s:%d := %p", func, file, line, ret);
|
||||
@@ -606,7 +607,7 @@ sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
|
||||
|
||||
void
|
||||
sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno,
|
||||
const char *str, int len, int errnum)
|
||||
const char *str, unsigned int len, int errnum)
|
||||
{
|
||||
char numbuf[(((sizeof(int) * 8) + 2) / 3) + 2];
|
||||
char timebuf[64];
|
||||
@@ -644,7 +645,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno,
|
||||
/* Add string, trimming any trailing newlines. */
|
||||
while (len > 0 && str[len - 1] == '\n')
|
||||
len--;
|
||||
if (len > 0) {
|
||||
if (len != 0) {
|
||||
iov[iovcnt].iov_base = (char *)str;
|
||||
iov[iovcnt].iov_len = len;
|
||||
iovcnt++;
|
||||
@@ -652,7 +653,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno,
|
||||
|
||||
/* Append error string if errno is specified. */
|
||||
if (errnum) {
|
||||
if (len > 0) {
|
||||
if (len != 0) {
|
||||
iov[iovcnt].iov_base = (char *)": ";
|
||||
iov[iovcnt].iov_len = 2;
|
||||
iovcnt++;
|
||||
@@ -696,7 +697,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno,
|
||||
}
|
||||
|
||||
bool
|
||||
sudo_debug_needed_v1(int level)
|
||||
sudo_debug_needed_v1(unsigned int level)
|
||||
{
|
||||
unsigned int subsys;
|
||||
int pri;
|
||||
@@ -708,8 +709,8 @@ sudo_debug_needed_v1(int level)
|
||||
goto out;
|
||||
|
||||
/* Extract priority and subsystem from level. */
|
||||
pri = SUDO_DEBUG_PRI(level);
|
||||
subsys = (unsigned int)SUDO_DEBUG_SUBSYS(level);
|
||||
pri = (int)SUDO_DEBUG_PRI(level);
|
||||
subsys = SUDO_DEBUG_SUBSYS(level);
|
||||
|
||||
if (sudo_debug_active_instance > sudo_debug_last_instance)
|
||||
goto out;
|
||||
@@ -731,10 +732,10 @@ out:
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level,
|
||||
const char *fmt, va_list ap)
|
||||
sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno,
|
||||
unsigned int level, const char *fmt, va_list ap)
|
||||
{
|
||||
int buflen, pri, saved_errno = errno;
|
||||
int pri, saved_errno = errno;
|
||||
unsigned int subsys;
|
||||
char static_buf[1024], *buf = static_buf;
|
||||
struct sudo_debug_instance *instance;
|
||||
@@ -745,9 +746,16 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level
|
||||
goto out;
|
||||
|
||||
/* Extract priority and subsystem from level. */
|
||||
pri = SUDO_DEBUG_PRI(level);
|
||||
pri = (int)SUDO_DEBUG_PRI(level);
|
||||
subsys = SUDO_DEBUG_SUBSYS(level);
|
||||
|
||||
/* Disable extra info if SUDO_DEBUG_LINENO is not enabled. */
|
||||
if (!ISSET(level, SUDO_DEBUG_LINENO)) {
|
||||
func = NULL;
|
||||
file = NULL;
|
||||
lineno = 0;
|
||||
}
|
||||
|
||||
/* Find matching instance. */
|
||||
if (sudo_debug_active_instance > sudo_debug_last_instance) {
|
||||
sudo_warnx_nodebug("%s: invalid instance ID %d, max %d",
|
||||
@@ -764,31 +772,36 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level
|
||||
SLIST_FOREACH(output, &instance->outputs, entries) {
|
||||
/* Make sure we want debug info at this level. */
|
||||
if (subsys <= instance->max_subsystem && output->settings[subsys] >= pri) {
|
||||
int errcode, buflen = 0;
|
||||
va_list ap2;
|
||||
|
||||
/* Operate on a copy of ap to support multiple outputs. */
|
||||
va_copy(ap2, ap);
|
||||
buflen = fmt ? vsnprintf(static_buf, sizeof(static_buf), fmt, ap2) : 0;
|
||||
va_end(ap2);
|
||||
if (buflen >= ssizeof(static_buf)) {
|
||||
va_list ap3;
|
||||
|
||||
/* Not enough room in static buf, allocate dynamically. */
|
||||
va_copy(ap3, ap);
|
||||
buflen = vasprintf(&buf, fmt, ap3);
|
||||
va_end(ap3);
|
||||
}
|
||||
if (buflen != -1) {
|
||||
int errcode = ISSET(level, SUDO_DEBUG_ERRNO) ? saved_errno : 0;
|
||||
if (ISSET(level, SUDO_DEBUG_LINENO))
|
||||
sudo_debug_write2(output->fd, func, file, lineno, buf, buflen, errcode);
|
||||
else
|
||||
sudo_debug_write2(output->fd, NULL, NULL, 0, buf, buflen, errcode);
|
||||
if (buf != static_buf) {
|
||||
free(buf);
|
||||
buf = static_buf;
|
||||
if (fmt != NULL) {
|
||||
/* Operate on a copy of ap to support multiple outputs. */
|
||||
va_copy(ap2, ap);
|
||||
buflen = vsnprintf(static_buf, sizeof(static_buf), fmt, ap2);
|
||||
va_end(ap2);
|
||||
if (buflen < 0) {
|
||||
sudo_warnx_nodebug("%s: invalid format string \"%s\"",
|
||||
__func__, fmt);
|
||||
buflen = 0;
|
||||
} else if (buflen >= ssizeof(static_buf)) {
|
||||
/* Not enough room in static buf, allocate dynamically. */
|
||||
va_copy(ap2, ap);
|
||||
buflen = vasprintf(&buf, fmt, ap2);
|
||||
if (buflen == -1) {
|
||||
buf = static_buf;
|
||||
buflen = (int)strlen(buf);
|
||||
}
|
||||
va_end(ap2);
|
||||
}
|
||||
}
|
||||
errcode = ISSET(level, SUDO_DEBUG_ERRNO) ? saved_errno : 0;
|
||||
sudo_debug_write2(output->fd, func, file, lineno, buf,
|
||||
(unsigned int)buflen, errcode);
|
||||
if (buf != static_buf) {
|
||||
free(buf);
|
||||
buf = static_buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
@@ -808,8 +821,8 @@ sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...)
|
||||
#endif /* NO_VARIADIC_MACROS */
|
||||
|
||||
void
|
||||
sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level,
|
||||
const char *fmt, ...)
|
||||
sudo_debug_printf2_v1(const char *func, const char *file, int lineno,
|
||||
unsigned int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -821,22 +834,23 @@ sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level,
|
||||
#define EXEC_PREFIX "exec "
|
||||
|
||||
void
|
||||
sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[])
|
||||
sudo_debug_execve2_v1(unsigned int level, const char *path, char *const argv[],
|
||||
char *const envp[])
|
||||
{
|
||||
int buflen, pri, saved_errno = errno;
|
||||
int pri, saved_errno = errno;
|
||||
unsigned int subsys;
|
||||
struct sudo_debug_instance *instance;
|
||||
struct sudo_debug_output *output;
|
||||
char * const *av;
|
||||
char *cp, static_buf[4096], *buf = static_buf;
|
||||
size_t plen;
|
||||
size_t buflen, plen;
|
||||
debug_decl_func(sudo_debug_execve2);
|
||||
|
||||
if (sudo_debug_active_instance == -1 || path == NULL)
|
||||
goto out;
|
||||
|
||||
/* Extract priority and subsystem from level. */
|
||||
pri = SUDO_DEBUG_PRI(level);
|
||||
pri = (int)SUDO_DEBUG_PRI(level);
|
||||
subsys = SUDO_DEBUG_SUBSYS(level);
|
||||
|
||||
/* Find matching instance. */
|
||||
@@ -880,7 +894,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con
|
||||
buflen += strlen(*av) + 1;
|
||||
buflen--;
|
||||
}
|
||||
if (buflen >= ssizeof(static_buf)) {
|
||||
if (buflen >= sizeof(static_buf)) {
|
||||
buf = malloc(buflen + 1);
|
||||
if (buf == NULL)
|
||||
goto out;
|
||||
@@ -919,7 +933,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con
|
||||
|
||||
*cp = '\0';
|
||||
|
||||
sudo_debug_write(output->fd, buf, buflen, 0);
|
||||
sudo_debug_write(output->fd, buf, (unsigned int)buflen, 0);
|
||||
if (buf != static_buf) {
|
||||
free(buf);
|
||||
buf = static_buf;
|
||||
@@ -1037,91 +1051,91 @@ sudo_debug_fork_v1(void)
|
||||
|
||||
void
|
||||
sudo_debug_enter_v1(const char *func, const char *file, int line,
|
||||
int subsys)
|
||||
unsigned int subsys)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_v1(const char *func, const char *file, int line,
|
||||
int subsys)
|
||||
unsigned int subsys)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_int_v1(const char *func, const char *file, int line,
|
||||
int subsys, int ret)
|
||||
unsigned int subsys, int ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_long_v1(const char *func, const char *file, int line,
|
||||
int subsys, long ret)
|
||||
unsigned int subsys, long ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_id_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, id_t ret)
|
||||
unsigned int subsys, id_t ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, size_t ret)
|
||||
unsigned int subsys, size_t ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, ssize_t ret)
|
||||
unsigned int subsys, ssize_t ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_time_t_v1(const char *func, const char *file, int line,
|
||||
int subsys, time_t ret)
|
||||
unsigned int subsys, time_t ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
|
||||
int subsys, bool ret)
|
||||
unsigned int subsys, bool ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_str_v1(const char *func, const char *file, int line,
|
||||
int subsys, const char *ret)
|
||||
unsigned int subsys, const char *ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line,
|
||||
int subsys, const char *ret)
|
||||
unsigned int subsys, const char *ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
|
||||
int subsys, const void *ret)
|
||||
unsigned int subsys, const void *ret)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno,
|
||||
const char *str, int len, int errnum)
|
||||
const char *str, unsigned int len, int errnum)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
sudo_debug_needed_v1(int level)
|
||||
sudo_debug_needed_v1(unsigned int level)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level,
|
||||
const char *fmt, va_list ap)
|
||||
sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno,
|
||||
unsigned int level, const char *fmt, va_list ap)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1133,13 +1147,14 @@ sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...)
|
||||
#endif /* NO_VARIADIC_MACROS */
|
||||
|
||||
void
|
||||
sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level,
|
||||
const char *fmt, ...)
|
||||
sudo_debug_printf2_v1(const char *func, const char *file, int lineno,
|
||||
unsigned int level, const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[])
|
||||
sudo_debug_execve2_v1(unsigned int level, const char *path, char *const argv[],
|
||||
char *const envp[])
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user