summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2019-04-17 15:19:01 +0000
committerSimon McVittie <smcv@collabora.com>2019-04-17 15:19:01 +0000
commit77c650f48b1035e0515840123309756b95797517 (patch)
tree0c4672aadb2f51aa9bc5923b668831ba3f14d22e
parent177ef29188c430e7e137e1d27e0b462a63190b4f (diff)
parentc6c6b423cfd190f25f055ad78998b3055fff62e1 (diff)
downloaddbus-77c650f48b1035e0515840123309756b95797517.tar.gz
Merge branch '1-12-logical-op' into 'dbus-1.12'
Backport -Wlogical-op fixes to 1.12.x See merge request dbus/dbus!109
-rw-r--r--bus/desktop-file.c10
-rw-r--r--dbus/dbus-sysdeps-unix.c8
-rw-r--r--tools/dbus-send.c11
3 files changed, 22 insertions, 7 deletions
diff --git a/bus/desktop-file.c b/bus/desktop-file.c
index 44598584..fd4f0d31 100644
--- a/bus/desktop-file.c
+++ b/bus/desktop-file.c
@@ -378,12 +378,16 @@ parse_comment_or_blank (BusDesktopFileParser *parser)
static dbus_bool_t
is_valid_section_name (const char *name)
{
- /* 5. Group names may contain all ASCII characters except for control characters and '[' and ']'. */
+ /* 5. Group names may contain all ASCII characters except for control characters and '[' and ']'.
+ *
+ * We don't use isprint() here because it's locale-dependent. ASCII
+ * characters <= 0x1f and 0x7f are control characters, and bytes with
+ * values >= 0x80 aren't ASCII. 0x20 is a space, which we must allow,
+ * not least because DBUS_SERVICE_SECTION contains one. */
while (*name)
{
- if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' || *name <= 'z') ||
- *name == '\n' || *name == '\t'))
+ if (*name <= 0x1f || *name >= 0x7f || *name == '[' || *name == ']')
return FALSE;
name++;
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 565e089c..e8cd5b33 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -4364,7 +4364,15 @@ _dbus_daemon_unpublish_session_bus_address (void)
dbus_bool_t
_dbus_get_is_errno_eagain_or_ewouldblock (int e)
{
+ /* Avoid the -Wlogical-op GCC warning, which can be triggered when EAGAIN and
+ * EWOULDBLOCK are numerically equal, which is permitted as described by
+ * errno(3).
+ */
+#if EAGAIN == EWOULDBLOCK
+ return e == EAGAIN;
+#else
return e == EAGAIN || e == EWOULDBLOCK;
+#endif
}
/**
diff --git a/tools/dbus-send.c b/tools/dbus-send.c
index 6fb65fe0..efeb76e0 100644
--- a/tools/dbus-send.c
+++ b/tools/dbus-send.c
@@ -289,13 +289,16 @@ main (int argc, char *argv[])
}
else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg))
{
- if (arg[2] == 'b') /* bus */
+ /* Check for peer first, to avoid the GCC -Wduplicated-branches
+ * warning.
+ */
+ if (arg[2] == 'p') /* peer */
{
- is_bus = TRUE;
+ is_bus = FALSE;
}
- else if (arg[2] == 'p') /* peer */
+ else if (arg[2] == 'b') /* bus */
{
- is_bus = FALSE;
+ is_bus = TRUE;
}
else /* address; keeping backwards compatibility */
{