From ece7ef7684ac7fa78d08a546b2619b62b2100cf2 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 3 Mar 2015 21:26:31 +0100 Subject: [PATCH] -Wsign-compare fixes. --- bus/signals.c | 3 ++- dbus/dbus-message.c | 2 +- dbus/dbus-sysdeps-unix.c | 13 ++++++++----- tools/dbus-print-message.c | 2 +- tools/dbus-spam.c | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bus/signals.c b/bus/signals.c index 260dd24..e8def9f 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -848,7 +848,8 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, if (end != length) { - if ((end + strlen ("path")) == length && + int len1 = strlen ("path"); + if ((end + len1) == length && _dbus_string_ends_with_c_str (&key_str, "path")) { is_path = TRUE; diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 01c2367..22da695 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -602,7 +602,7 @@ static void close_unix_fds(int *fds, unsigned *n_fds) { DBusError e; - int i; + unsigned int i; if (*n_fds <= 0) return; diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 0bcd5ab..d94a4fc 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1674,16 +1674,18 @@ add_linux_security_label_to_credentials (int client_fd, { #if defined(__linux__) && defined(SO_PEERSEC) DBusString buf; - socklen_t len = 1024; + socklen_t socklen = 1024; + int len = 0; dbus_bool_t oom = FALSE; - if (!_dbus_string_init_preallocated (&buf, len) || - !_dbus_string_set_length (&buf, len)) + if (!_dbus_string_init_preallocated (&buf, socklen) || + !_dbus_string_set_length (&buf, socklen)) return FALSE; while (getsockopt (client_fd, SOL_SOCKET, SO_PEERSEC, - _dbus_string_get_data (&buf), &len) < 0) + _dbus_string_get_data (&buf), &socklen) < 0) { + len = socklen; int e = errno; _dbus_verbose ("getsockopt failed with %s, len now %lu\n", @@ -1736,7 +1738,8 @@ add_linux_security_label_to_credentials (int client_fd, goto out; } - if (strlen (_dbus_string_get_const_data (&buf)) != len) + int len1 = strlen (_dbus_string_get_const_data (&buf)); + if (len1 != len) { /* LSM people on the linux-security-module@ mailing list say this * should never happen: the label should be a bytestring with diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index 4a2a9c8..bd0817c 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -68,7 +68,7 @@ indent (int depth) static void print_hex (const unsigned char *bytes, - int len, + unsigned int len, int depth) { unsigned int i, columns; diff --git a/tools/dbus-spam.c b/tools/dbus-spam.c index ce91875..e708ea2 100644 --- a/tools/dbus-spam.c +++ b/tools/dbus-spam.c @@ -155,9 +155,9 @@ dbus_test_tool_spam (int argc, char **argv) int i; int count = 1; int sent = 0; - int sent_in_this_conn = 0; + unsigned int sent_in_this_conn = 0; int received = 0; - int received_before_this_conn = 0; + unsigned int received_before_this_conn = 0; int queue_len = 1; const char *payload = NULL; char *payload_buf = NULL; -- 1.8.4.5