Simon McVittie [Wed, 18 May 2022 13:01:25 +0000 (14:01 +0100)]
COPYING: Move full license text into LICENSES/
Having the full text of the AFL-2.1 and GPL in this file makes it harder
to find the unique information, which is the summary. Move their full
text into LICENSES/ (consistent with how REUSE handles this), leaving
a short summary of the licensing situation in COPYING.
Loosely based on work from Ralf Habacker in dbus!304.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Alex Richardson [Wed, 25 May 2022 22:05:03 +0000 (22:05 +0000)]
configure: Avoid exit() when checking for __sync_sub_and_fetch()
Use of exit() requires a stdlib.h include. This check was failing for me
since the compiler defaulted to -Werror=implicit-function-declaration, so
__sync_sub_and_fetch() support was not dectected.
Alex Richardson [Sun, 22 May 2022 22:08:32 +0000 (22:08 +0000)]
dbus-mempool.c: Ensure element_size is at least sizeof(void *)
I am trying to use DBus on an Arm Morello system where sizeof(void *) is
16 and not 8, so the assertion in the line below can fail unless we ensure
that element_size is at least sizeof(void *).
Simon McVittie [Wed, 18 May 2022 11:46:09 +0000 (12:46 +0100)]
.editorconfig: Automatically configure multiple text editors
See editorconfig.org for details of the format. This is a first attempt
at describing our coding style in editorconfig syntax; please add new
file types here as they become relevant.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Some pages are missing AUTHOR section, xmlto complains about it, ex:
Warn: meta author : no refentry/info/author dbus-update-activation-environment
Note: meta author : see http://www.docbook.org/tdg5/en/html/autho dbus-update-activation-environment
Warn: meta author : no author data, so inserted a fixme dbus-update-activation-environment
Alex Richardson [Tue, 17 May 2022 09:26:58 +0000 (09:26 +0000)]
Add a clang-format configuration file
This ensures that IDEs such as CLion automatically use the correct
indentation, and running `git-clang-format` results in patches that are
actually quite close to the current style. It doesn't handle alignment
of parameters in function declarations, but otherwise it seems accurate.
Ralf Habacker [Thu, 3 Mar 2022 16:15:44 +0000 (17:15 +0100)]
On Windows in autolaunch related function use rmutex related functions to support thread locking
The previously used additional and incomplete functions have been merged
into the current rmutex functions to fix the reported bug and reduce the
maintenance effort.
Alex Richardson [Sun, 15 May 2022 10:12:41 +0000 (11:12 +0100)]
dbus-string.c: use memcpy() in _dbus_string_insert_{2,4,8}_aligned
This fixes a -Wcast-align warning from Clang, and I believe this could
be a genuine issue on some architectures since the octets argument is
an unsigned char pointer that only has alignment 1. Using memcpy() instead
will generate the same code on architectures that support unaligned loads
and stores (i.e. almost all current ones) and individual stores on those
that don't (e.g. old MIPS).
Clang performs the -Wcast-align analysis before code generation and
optimizations, so the compiler cannot see that the alignment is actually
guaranteed to be sufficient for these casts. Silence the warning by adding
casts to void* and/or changing the types of some variables.
Alex Richardson [Sun, 20 Mar 2022 00:40:22 +0000 (00:40 +0000)]
tools/ci-build.sh: Add a ci_cmake_junit_output argument
CMake 3.21 can emit JUnit XML test results which can be visualized by
GitLab. This also updates the gitlab CI config file to make use of this
feature whenever possible.
Alex Richardson [Sun, 15 May 2022 10:28:51 +0000 (11:28 +0100)]
cmake: Fix definition of DBUS_USE_SYNC
dbus-sysdeps-unix.c checks for DBUS_USE_SYNC using 0/1 checks not defined
checks, so we should be using #cmakedefine01. This fixes lots of -Wundef
warnings when compiling for FreeBSD and ensures that we actually use
atomics instead of the pthread fallback there.
Alex Richardson [Mon, 18 Apr 2022 22:18:41 +0000 (22:18 +0000)]
Use freedesktop/ci-templates for the GitLab CI
The CI templates include infrastructure to create docker images with all
packages specified in tools/ci-install.sh. Using those docker images
speeds up the CI since we don't have to install all the dependencies in
every pipeline. We could extend this to also create containers that have
mingw pre-installed but for now we only create an image with the
dependencies that are required for every job.
Ralf Habacker [Wed, 2 Mar 2022 12:17:10 +0000 (13:17 +0100)]
Add unit tests for platform-specific mutex implementation.
The tests are enabled with the embedded tests; the required
low-level functions from the dbus library are decorated with
DBUS_EMBEDDED_TESTS_EXPORT to indicate the appropriate usage.
On Windows, all tests are run; on unix-like operating systems,
individual tests are disabled:
- the tests on #NULL pointers of type DBus[C|R]Mutex, since they
point to a data structure and would cause a segment violation
when accessed.
- the multiple lock test for type DBusCMutex, since it would block
the current thread.
Since the whole point of "rmutex" is to be able to lock multiple
times, the "rmutex double lock" test is enabled on unix-like
operating systems too.
To avoid that build break in test-marshall-recursive-util.c the newly
added function _dbus_string_append_buffer_as_hex() is used to print
the hex bytes.
This function provides a portable way to print data as hex values.
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: Only compile this when needed, improve assertions, coding style] Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Thu, 21 Apr 2022 13:35:44 +0000 (14:35 +0100)]
dbus: Move DBUS_ENABLE_EMBEDDED_TESTS to a new dbus-macros-internal.h
This avoids a circular dependency: I want to use
DBUS_ENABLE_EMBEDDED_TESTS in dbus-string.h, but
DBUS_ENABLE_EMBEDDED_TESTS was previously defined in dbus-internals.h,
which depends on dbus-string.h.
Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake: Fix not detecting unsupported g++ related warning checks
Unsupported warnings are detected by cmake through errors during
compilation, which causes g++ not to detect them, since they are
only output as warnings. Setting -Werror ensures this.
Ignore gcc 10.3 'inline' warnings: 'call is unlikely and code size would grow'
As long as gcc does something with compatible semantics, it is up to gcc
how to optimize our code.
The alternative would be to export the functions in question from the
shared library, which has the disadvantage of greatly increasing the
number of calls across a shared library boundary.
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Mon, 7 Mar 2022 15:38:25 +0000 (16:38 +0100)]
bus_service_remove_owner(): Assert that service has an owner
gcc 10.3 warns that link->data is a possible NULL dereference.
However, that can't actually happen without an earlier programming
error, because bus_service_remove_owner() is only valid to call for
a connection that is currently in the queue to own the service,
in which case we know _bus_service_find_owner_link() will succeed.
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Tue, 1 Mar 2022 09:54:05 +0000 (10:54 +0100)]
_dbus_string_test(): Fix fatal build error caused by "-Wstrict-aliasing"
To fix this problem, the problematic code was replaced by a new function
_dbus_string_get_allocated_size(), which uses the existing macro
DBUS_CONST_STRING_PREAMBLE for these purposes.
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Tue, 8 Mar 2022 07:48:31 +0000 (08:48 +0100)]
bus: Add assertions to silence compiler warnings
gcc 10.3 warns that link->data might be NULL, which would make
new_owner->conn a null pointer dereference. However, we know that
we only add valid, non-null BusOwner objects to the list, so that
can't happen in reality.
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 2 Mar 2022 12:25:54 +0000 (12:25 +0000)]
sysdeps: On Linux, wrap close_range syscall directly if necessary
This was added to the Linux kernel in version 5.9, but the wrapper
wasn't added to glibc until 2.34. Adding our own wrapper for the
system call means we can use close_range() on Debian 11 and
contemporary distributions.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 1 Mar 2022 19:12:38 +0000 (19:12 +0000)]
sysdeps: Only use closefrom() if known to be async-signal-safe
closefrom() is known to be async-signal-safe on FreeBSD, NetBSD and
OpenBSD, and safe to call after fork() on Solaris, but not necessarily
on DragonflyBSD.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 1 Apr 2022 14:57:07 +0000 (15:57 +0100)]
build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIER
Using PRId64, etc. to print dbus_int64_t or dbus_uint64_t is not 100%
portable. On platforms where both long and long long are 64-bit (such as
Linux and macOS), we will prefer to define dbus_int64_t as long.
If the operating system has chosen to define int64_t as long long,
which is apparently the case on macOS, then the compiler can warn that
we are passing a long argument to PRId64, which is "lld" and therefore
expects a long long argument (even though that ends up with the same
bit-pattern being used).
We can't necessarily just use int64_t and uint64_t directly, even if all
our supported platforms have them available now, because swapping
dbus_int64_t between long and long long might change C++ name mangling,
causing ABI breaks in third-party libraries if they define C++ functions
that take a dbus_int64_t argument.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Alex Richardson [Fri, 1 Apr 2022 11:09:45 +0000 (11:09 +0000)]
cmake: Correct DBUS_{SYSTEM,SESSION}_CONFIG_FILE on UNIX systems
We always install to a dbus-1 subdir, but the path encoded in the binary
was missing the dbus-1/ subdirectory, so we end up getting errors when
trying to load it.
The detection is based on the variable VERSION_CODENAME from
/etc/os-release, which is supported by systemd. For further details see
https://www.freedesktop.org/software/systemd/man/os-release.html.