Fix a bunch of compiler warnings

Most are signed vs unsigned, the remaining ones are an unused
variables/functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2022-03-01 14:15:08 +10:00
parent 2c4506fdb8
commit 5f2afdf806
18 changed files with 29 additions and 54 deletions

View file

@ -113,7 +113,7 @@ ei_device_new(struct ei_seat *seat, uint32_t deviceid)
device->capabilities = 0;
device->id = deviceid;
device->state = EI_DEVICE_STATE_NEW;
device->name = xaprintf("unnamed device %d", device->id);
device->name = xaprintf("unnamed device %#x", device->id);
list_init(&device->regions);
/* We have a ref to the seat to make sure our seat doesn't get

View file

@ -130,7 +130,7 @@ check_event_type(struct ei_event *event,
if (!rc)
log_bug_client(ei_event_get_context(event),
"Invalid event type %d passed to %s()\n",
"Invalid event type %u passed to %s()\n",
type, function_name);
return rc;

View file

@ -46,12 +46,6 @@ struct ei_fd {
struct object object;
};
static inline struct ei_fd *
ei_fd(struct ei *ei)
{
return ei->backend;
}
static inline void
ei_fd_destroy(struct ei_fd *backend)
{

View file

@ -190,7 +190,7 @@ portal_response_received(sd_bus_message *m, void *userdata, sd_bus_error *error)
return 0;
}
log_debug(ei, "Portal CreateSession reponse is %d\n", response);
log_debug(ei, "Portal CreateSession reponse is %u\n", response);
const char *session_handle = NULL;
if (response == 0) {
@ -256,7 +256,6 @@ static int
portal_init(struct ei *ei, const char *busname)
{
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_unref_(sd_bus_message) *m = NULL;
_unref_(sd_bus_message) *response = NULL;
_unref_(sd_bus) *bus = NULL;
_unref_(sd_bus_slot) *slot = NULL;

View file

@ -43,12 +43,6 @@ struct ei_socket {
struct object object;
};
static inline struct ei_socket *
ei_socket(struct ei *ei)
{
return ei->backend;
}
static inline void
ei_socket_destroy(struct ei_socket *socket)
{

View file

@ -114,7 +114,7 @@ set_prop_cmdline(struct ei *ei)
{
char path[PATH_MAX];
xsnprintf(path, sizeof(path), "/proc/%u/cmdline", getpid());
xsnprintf(path, sizeof(path), "/proc/%d/cmdline", getpid());
_cleanup_close_ int fd = open(path, O_RDONLY);
if (fd < 0)
return;
@ -132,7 +132,7 @@ set_prop_pid(struct ei *ei)
{
char pid[64];
xsnprintf(pid, sizeof(pid), "%u", getpid());
xsnprintf(pid, sizeof(pid), "%d", getpid());
ei_property_update(ei, "ei.application.pid", pid, EI_PROPERTY_PERM_NONE);
}
@ -184,7 +184,7 @@ ei_dispatch(struct ei *ei)
static void
queue_event(struct ei *ei, struct ei_event *event)
{
log_debug(ei, "queuing event type %s (%d)\n",
log_debug(ei, "queuing event type %s (%u)\n",
ei_event_type_to_string(event->type), event->type);
list_append(&ei->event_queue, &event->link);
@ -193,7 +193,7 @@ queue_event(struct ei *ei, struct ei_event *event)
static void
insert_event(struct ei *ei, struct ei_event *event)
{
log_debug(ei, "inserting event type %s (%d)\n",
log_debug(ei, "inserting event type %s (%u)\n",
ei_event_type_to_string(event->type), event->type);
list_insert(&ei->event_queue, &event->link);
@ -394,7 +394,7 @@ handle_msg_device_added(struct ei *ei, uint32_t deviceid, uint32_t seatid,
struct ei_seat *seat = ei_find_seat(ei, seatid);
if (!seat) {
log_bug(ei, "Invalid seat id %d for device %s (%d)\n",
log_bug(ei, "Invalid seat id %#x for device %s (%#x)\n",
seatid, name, deviceid);
return 0;
}
@ -559,7 +559,7 @@ handle_msg_device_resumed(struct ei *ei, uint32_t deviceid)
static int
handle_msg_device_paused(struct ei *ei, uint32_t deviceid)
{
log_debug(ei, "Paused device %d\n", deviceid);
log_debug(ei, "Paused device %#x\n", deviceid);
struct ei_device *device = ei_find_device(ei, deviceid);
if (device) {

View file

@ -162,7 +162,7 @@ check_event_type(struct eis_event *event,
if (!rc)
log_bug_client(eis_event_get_context(event),
"Invalid event type %d passed to %s()\n",
"Invalid event type %u passed to %s()\n",
type, function_name);
return rc;

View file

@ -39,12 +39,6 @@ struct eis_fd {
struct object object;
};
static inline struct eis_fd *
eis_fd(struct eis *eis)
{
return eis->backend;
}
static inline void
eis_fd_destroy(struct eis_fd *eis_fd)
{
@ -58,8 +52,7 @@ OBJECT_IMPLEMENT_UNREF(eis_fd);
static void
interface_fd_destroy(struct eis *eis, void *backend)
{
struct eis_fd *fd = backend;
eis_fd_unref(fd);
_unref_(eis_fd) *fd = backend;
}
static const struct eis_backend_interface interface = {

View file

@ -48,12 +48,6 @@ struct eis_socket {
int lockfd;
};
static inline struct eis_socket *
eis_socket(struct eis *eis)
{
return eis->backend;
}
static inline void
eis_socket_destroy(struct eis_socket *socket)
{

View file

@ -139,7 +139,7 @@ eis_queue_event(struct eis_event *event)
{
struct eis *eis = eis_event_get_context(event);
log_debug(eis, "queuing event type %s (%d)\n",
log_debug(eis, "queuing event type %s (%u)\n",
eis_event_type_to_string(event->type), event->type);
list_append(&eis->event_queue, &event->link);

View file

@ -345,6 +345,9 @@ MUNIT_TEST(test_iobuf_cleanup)
_cleanup_iobuf_ struct iobuf *buf = iobuf_new(10);
_cleanup_iobuf_ struct iobuf *nullbuf = NULL;
assert(buf);
assert(nullbuf == NULL);
return MUNIT_OK;
}
@ -515,7 +518,7 @@ MUNIT_TEST(test_pass_fd)
/* Write some data to the file on it's real fd */
for (size_t idx = 0; idx < ARRAY_LENGTH(fps); idx++) {
_cleanup_free_ char *buf = xaprintf("foo %zd\n", idx);
_cleanup_free_ char *buf = xaprintf("foo %zu\n", idx);
FILE *fp = fps[idx];
fwrite(buf, strlen(buf) + 1, 1, fp);
fflush(fp);
@ -542,7 +545,7 @@ MUNIT_TEST(test_pass_fd)
char readbuf[64];
int readrc = xread(passed_fd, readbuf, sizeof(readbuf));
_cleanup_free_ char *expected = xaprintf("foo %zd\n", idx);
_cleanup_free_ char *expected = xaprintf("foo %zu\n", idx);
munit_assert_int(readrc, ==, strlen(expected) + 1);
munit_assert_string_equal(readbuf, expected);

View file

@ -38,7 +38,7 @@ struct logger {
char *prefix;
};
_printf_(4, 0)
_printf_(7, 0)
static void
logger_default_log_func(struct logger *logger,
const char *prefix,

View file

@ -238,7 +238,7 @@ peck_ei_log_handler(struct ei *ei,
struct peck *peck = ei_get_user_data(ei);
fprintf(stderr, "| | ei | | %s |%*s🥚 %s%s%s",
prefix, peck_get_indent(peck), " ",
prefix, (int)peck_get_indent(peck), " ",
use_color ? ANSI_FG_RGB(150, 125, 100) : "",
message,
use_color ? ansi_colorcode[RESET] : "");
@ -271,7 +271,7 @@ peck_eis_log_handler(struct eis *eis,
struct peck *peck = eis_get_user_data(eis);
fprintf(stderr, "| | | EIS | %s |%*s🍨 %s%s%s",
prefix, peck_get_indent(peck), " ",
prefix, (int)peck_get_indent(peck), " ",
use_color ? ANSI_FG_RGB(150, 200, 125) : "",
message,
use_color ? ansi_colorcode[RESET] : "");
@ -305,7 +305,7 @@ peck_log_handler(struct logger *logger,
fprintf(stderr, "| peck | | | %s |%*s%s",
msgtype,
peck_get_indent(peck), " ",
(int)peck_get_indent(peck), " ",
use_color ? ANSI_FG_RGB(125, 150, 255) : "");
vfprintf(stderr, format, args);
if (use_color)

View file

@ -55,8 +55,8 @@ MUNIT_TEST(test_ei_initial_properties)
char pid[64];
char cmdline[PATH_MAX];
xsnprintf(pid, sizeof(pid), "%u", getpid());
xsnprintf(cmdline, sizeof(cmdline), "/proc/%u/cmdline", getpid());
xsnprintf(pid, sizeof(pid), "%i", getpid());
xsnprintf(cmdline, sizeof(cmdline), "/proc/%i/cmdline", getpid());
int fd = open(cmdline, O_RDONLY);
munit_assert_int(fd, >=, 0);

View file

@ -60,7 +60,6 @@
DEFINE_UNREF_CLEANUP_FUNC(ei);
DEFINE_UNREF_CLEANUP_FUNC(ei_device);
DEFINE_UNREF_CLEANUP_FUNC(ei_keymap);
DEFINE_UNREF_CLEANUP_FUNC(ei_event);
static inline void
@ -83,7 +82,6 @@ colorprint(const char *format, ...)
DEFINE_UNREF_CLEANUP_FUNC(xkb_context);
DEFINE_UNREF_CLEANUP_FUNC(xkb_keymap);
DEFINE_UNREF_CLEANUP_FUNC(xkb_state);
DEFINE_UNREF_CLEANUP_FUNC(memfile);
#endif
static void

View file

@ -190,7 +190,7 @@ handle_key(struct eis_demo_server *server, uint32_t keycode, bool is_press)
xkb_state_key_get_utf8(server->state, xkbkc, keysym_name, sizeof(keysym_name));
}
#endif
colorprint("key %d (%s) [%s]\n",
colorprint("key %u (%s) [%s]\n",
keycode, is_press ? "press" : "release",
keysym_name);
}
@ -341,7 +341,7 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server,
break;
case EIS_EVENT_POINTER_BUTTON:
{
colorprint("button %d (%s)\n",
colorprint("button %u (%s)\n",
eis_event_pointer_get_button(e),
eis_event_pointer_get_button_is_press(e) ? "press" : "release");
}

View file

@ -190,7 +190,7 @@ set_prop_cmdline(struct reis *reis)
{
char path[PATH_MAX];
xsnprintf(path, sizeof(path), "/proc/%u/cmdline", getpid());
xsnprintf(path, sizeof(path), "/proc/%i/cmdline", getpid());
_cleanup_close_ int fd = open(path, O_RDONLY);
if (fd < 0)
return;
@ -208,7 +208,7 @@ set_prop_pid(struct reis *reis)
{
char pid[64];
xsnprintf(pid, sizeof(pid), "%u", getpid());
xsnprintf(pid, sizeof(pid), "%i", getpid());
reis_set_property_with_permissions(reis, "ei.application.pid", pid, REIS_PROPERTY_PERM_NONE);
}

View file

@ -231,7 +231,7 @@ set_prop_cmdline(struct reis *reis)
{
char path[PATH_MAX];
xsnprintf(path, sizeof(path), "/proc/%u/cmdline", getpid());
xsnprintf(path, sizeof(path), "/proc/%i/cmdline", getpid());
_cleanup_close_ int fd = open(path, O_RDONLY);
if (fd < 0)
return;
@ -249,7 +249,7 @@ set_prop_pid(struct reis *reis)
{
char pid[64];
xsnprintf(pid, sizeof(pid), "%u", getpid());
xsnprintf(pid, sizeof(pid), "%i", getpid());
reis_set_property_with_permissions(reis, "ei.application.pid", pid, REIS_PROPERTY_PERM_NONE);
}