Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package dbus-broker for openSUSE:Factory checked in at 2021-06-28 15:33:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/dbus-broker (Old) and /work/SRC/openSUSE:Factory/.dbus-broker.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "dbus-broker" Mon Jun 28 15:33:49 2021 rev:12 rq:902808 version:29 Changes: -------- --- /work/SRC/openSUSE:Factory/dbus-broker/dbus-broker.changes 2021-03-25 14:52:17.784483701 +0100 +++ /work/SRC/openSUSE:Factory/.dbus-broker.new.2625/dbus-broker.changes 2021-06-28 15:34:23.179241682 +0200 @@ -1,0 +2,9 @@ +Wed Jun 2 13:23:40 UTC 2021 - Jan Engelhardt <jeng...@inai.de> + +- Update to release 29 + * Improve SELinux audit messages. + * Linux >=4.17 is now a hard requirement. + * Fix startup failures when at-console users have + consecutive UIDs. + +------------------------------------------------------------------- Old: ---- dbus-broker-28.tar.xz New: ---- dbus-broker-29.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ dbus-broker.spec ++++++ --- /var/tmp/diff_new_pack.AydOjk/_old 2021-06-28 15:34:23.643242252 +0200 +++ /var/tmp/diff_new_pack.AydOjk/_new 2021-06-28 15:34:23.647242256 +0200 @@ -17,7 +17,7 @@ Name: dbus-broker -Version: 28 +Version: 29 Release: 0 Summary: XDG-conforming message bus implementation License: Apache-2.0 @@ -25,16 +25,16 @@ URL: https://github.com/bus1/dbus-broker Source: https://github.com/bus1/dbus-broker/releases/download/v%version/dbus-broker-%version.tar.xz -BuildRequires: linux-glibc-devel >= 4.13 +BuildRequires: linux-glibc-devel >= 4.17 BuildRequires: meson BuildRequires: pkg-config BuildRequires: systemd-rpm-macros -BuildRequires: pkgconfig(audit) >= 2.7 +BuildRequires: pkgconfig(audit) >= 3.0 BuildRequires: pkgconfig(dbus-1) >= 1.10 BuildRequires: pkgconfig(expat) >= 2.2.3 BuildRequires: pkgconfig(glib-2.0) >= 2.50 BuildRequires: pkgconfig(libcap-ng) >= 0.6 -BuildRequires: pkgconfig(libselinux) >= 2.5 +BuildRequires: pkgconfig(libselinux) >= 3.2 BuildRequires: pkgconfig(libsystemd) >= 230 BuildRequires: pkgconfig(systemd) >= 230 Provides: bundled(c-dvar) = 1+ ++++++ dbus-broker-28.tar.xz -> dbus-broker-29.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/AUTHORS new/dbus-broker-29/AUTHORS --- old/dbus-broker-28/AUTHORS 2021-03-17 13:48:38.251243800 +0100 +++ new/dbus-broker-29/AUTHORS 2021-06-02 13:17:08.315670500 +0200 @@ -12,10 +12,10 @@ limitations under the License. COPYRIGHT: (ordered alphabetically) - Copyright (C) 2016-2019 Red Hat, Inc. + Copyright (C) 2016-2021 Red Hat, Inc. AUTHORS: (ordered alphabetically) - Chris Paulson-Ellis + Chris Paulson-Ellis <chris.paulson-el...@motorolasolutions.com> Chris PeBenito <chpeb...@linux.microsoft.com> Daniel Rusek <m...@asciiwolf.com> Daniele Nicolodi <dani...@grinta.net> @@ -28,6 +28,7 @@ Marc-Antoine Perennou <marc-anto...@perennou.com> Michal Schmidt <mschm...@redhat.com> Mike Gilbert <flop...@gentoo.org> + Thomas M??hlbacher <tmuehlbac...@posteo.net> Tim Gates <tim.ga...@iress.com> Tom Gundersen <t...@jklm.no> Yanko Kaneti <yan...@declera.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/NEWS.md new/dbus-broker-29/NEWS.md --- old/dbus-broker-28/NEWS.md 2021-03-17 15:50:54.115497000 +0100 +++ new/dbus-broker-29/NEWS.md 2021-06-02 13:16:57.462327000 +0200 @@ -1,8 +1,21 @@ # dbus-broker - Linux D-Bus Message Broker -## CHANGES WITH 28: +## CHANGES WITH 29: + + * Improve SELinux audit messages. This requires the new libselinux-3.2 + and libaudit-3.0 releases. If audit/selinux support is enabled, those + are now the minimum required versions. + + * Make linux-4.17 a hard-requirements. Older kernels are no longer + supported. + + * Fix startup failures when at-console users have consecutive uids. - Contributions from: David Rheinsberg + Contributions from: Chris PeBenito, David Rheinsberg, Thomas M??hlbacher + + - Du??lingen, 2021-06-02 + +## CHANGES WITH 28: * Further improvements to the service activation tracking. This better tracks units in systemd and closes some races where a repeated diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/README.md new/dbus-broker-29/README.md --- old/dbus-broker-28/README.md 2021-03-17 12:22:32.748786400 +0100 +++ new/dbus-broker-29/README.md 2021-06-02 13:08:16.022461700 +0200 @@ -31,11 +31,10 @@ The requirements for dbus-broker are: ``` - Linux kernel >= 4.14 (>=4.10 works, but lacks important - security-related AF_UNIX patches) + Linux kernel >= 4.17 glibc >= 2.16 - libaudit >= 2.7 (optional) - libselinux >= 2.5 (optional) + libaudit >= 3.0 (optional) + libselinux >= 3.2 (optional) ``` Additionally, the compatibility launcher requires: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/meson.build new/dbus-broker-29/meson.build --- old/dbus-broker-28/meson.build 2021-03-17 15:51:02.999106200 +0100 +++ new/dbus-broker-29/meson.build 2021-06-02 13:17:28.365688000 +0200 @@ -5,7 +5,7 @@ project( 'dbus-broker', 'c', - version: '28', + version: '29', license: 'Apache', default_options: [ 'c_std=c11', @@ -46,7 +46,7 @@ use_audit = get_option('audit') if use_audit - dep_libaudit = dependency('audit', version: '>=2.7') + dep_libaudit = dependency('audit', version: '>=3.0') dep_libcapng = dependency('libcap-ng', version: '>=0.6') endif @@ -76,14 +76,6 @@ endif # -# Config: linux-4-17 -# - -require_linux_4_17 = get_option('linux-4-17') - -add_project_arguments('-DREQUIRE_LINUX_4_17=' + require_linux_4_17.to_int().to_string(), language: 'c') - -# # Config: reference-test # @@ -98,7 +90,7 @@ use_selinux = get_option('selinux') if use_selinux - dep_libselinux = dependency('libselinux', version: '>=2.5') + dep_libselinux = dependency('libselinux', version: '>=3.2') endif # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/broker/broker.c new/dbus-broker-29/src/broker/broker.c --- old/dbus-broker-28/src/broker/broker.c 2021-03-17 12:22:32.748786400 +0100 +++ new/dbus-broker-29/src/broker/broker.c 2021-06-02 13:10:19.219018200 +0200 @@ -92,22 +92,16 @@ * return some value. Second, all unlabeled names get this label * assigned by default. Due to the latter, this seclabel is actually * referenced in selinux rules, to allow peers to own names. - * Preferably, we would call SO_PEERSEC on the controller socket. - * However, this used to return the 'unlabeled_t' entry for socketpairs - * until kernel v4.17. From v4.17 onwards it now returns the correct - * label. There is no way to detect this at runtime, though. Hence, we - * have to run the fallback as long as we do not have v4.17 as - * hard-requirement. + * We use SO_PEERSEC on the controller socket to get this label. + * However, note that this used to return the 'unlabeled_t' entry for + * socketpairs until kernel v4.17. From v4.17 onwards it now returns + * the correct label. There is no way to detect this at runtime, + * though. We hard-require 4.17. If you use older kernels, you will get + * selinux denials. */ - if (REQUIRE_LINUX_4_17) { - r = sockopt_get_peersec(controller_fd, &broker->bus.seclabel, &broker->bus.n_seclabel); - if (r) - return error_fold(r); - } else { - r = proc_get_seclabel(ucred.pid, &broker->bus.seclabel, &broker->bus.n_seclabel); - if (r) - return error_fold(r); - } + r = sockopt_get_peersec(controller_fd, &broker->bus.seclabel, &broker->bus.n_seclabel); + if (r) + return error_fold(r); r = sockopt_get_peergroups(controller_fd, &broker->log, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/catalog/dbus-broker.catalog new/dbus-broker-29/src/catalog/dbus-broker.catalog --- old/dbus-broker-28/src/catalog/dbus-broker.catalog 2021-03-17 12:22:32.762120000 +0100 +++ new/dbus-broker-29/src/catalog/dbus-broker.catalog 2021-04-13 14:02:46.364546300 +0200 @@ -36,7 +36,7 @@ Defined-By: dbus-broker Support: https://groups.google.com/forum/#!forum/bus1-devel -The peer @DBUS_BROKER_SENDER_UNIQUE_NAME@ attempted to vioalet the protocol +The peer @DBUS_BROKER_SENDER_UNIQUE_NAME@ attempted to violate the protocol and is therefore disconnected. -- 6fa70fa776044fa28be7a21daf42a108 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/launch/nss-cache.c new/dbus-broker-29/src/launch/nss-cache.c --- old/dbus-broker-28/src/launch/nss-cache.c 2021-03-17 13:48:38.281244000 +0100 +++ new/dbus-broker-29/src/launch/nss-cache.c 2021-03-18 11:22:48.466602800 +0100 @@ -493,22 +493,23 @@ int nss_cache_resolve_system_console_users(NSSCache *nss_cache, uint32_t **uidsp, size_t *n_uidsp) { static const char * const usernames[] = { SYSTEM_CONSOLE_USERS }; + static const size_t n_usernames = C_ARRAY_SIZE(usernames); _c_cleanup_(c_freep) uint32_t *uids = NULL; size_t i, n_uids = 0; uid_t uid; int r; - if (!C_ARRAY_SIZE(usernames)) { + if (!n_usernames) { *uidsp = NULL; *n_uidsp = 0; return 0; } - uids = calloc(C_ARRAY_SIZE(usernames), sizeof(*uids)); + uids = calloc(n_usernames, sizeof(*uids)); if (!uids) return error_origin(-ENOMEM); - for (i = 0; i < C_ARRAY_SIZE(usernames); ++i) { + for (i = 0; i < n_usernames; ++i) { r = nss_cache_get_uid(nss_cache, &uid, NULL, usernames[i]); if (r) { if (r == NSS_CACHE_E_INVALID_NAME) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/launch/policy.c new/dbus-broker-29/src/launch/policy.c --- old/dbus-broker-28/src/launch/policy.c 2021-03-17 12:22:32.768787000 +0100 +++ new/dbus-broker-29/src/launch/policy.c 2021-03-18 12:13:09.909788800 +0100 @@ -934,7 +934,8 @@ static int policy_export_console(Policy *policy, sd_bus_message *m, PolicyEntries *entries, uint32_t uid_start, uint32_t n_uid) { int r; - c_assert(((uint32_t)-1) - n_uid + 1 >= uid_start); + /* check for overflow */ + c_assert(n_uid == 0 || uid_start + n_uid - 1 >= uid_start); if (n_uid == 0) return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/util/audit.c new/dbus-broker-29/src/util/audit.c --- old/dbus-broker-28/src/util/audit.c 2021-03-17 13:58:11.058914400 +0100 +++ new/dbus-broker-29/src/util/audit.c 2021-04-13 14:02:46.364546300 +0200 @@ -108,6 +108,12 @@ case UTIL_AUDIT_TYPE_AVC: audit_type = AUDIT_USER_AVC; break; + case UTIL_AUDIT_TYPE_POLICYLOAD: + audit_type = AUDIT_USER_MAC_POLICY_LOAD; + break; + case UTIL_AUDIT_TYPE_MAC_STATUS: + audit_type = AUDIT_USER_MAC_STATUS; + break; case UTIL_AUDIT_TYPE_NOAUDIT: default: audit_type = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/util/audit.h new/dbus-broker-29/src/util/audit.h --- old/dbus-broker-28/src/util/audit.h 2021-03-17 13:58:11.058914400 +0100 +++ new/dbus-broker-29/src/util/audit.h 2021-04-13 14:02:46.364546300 +0200 @@ -10,6 +10,8 @@ enum { UTIL_AUDIT_TYPE_NOAUDIT, UTIL_AUDIT_TYPE_AVC, + UTIL_AUDIT_TYPE_POLICYLOAD, + UTIL_AUDIT_TYPE_MAC_STATUS, }; int util_audit_drop_permissions(uint32_t uid, uint32_t gid); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/src/util/selinux.c new/dbus-broker-29/src/util/selinux.c --- old/dbus-broker-28/src/util/selinux.c 2021-03-17 13:58:11.058914400 +0100 +++ new/dbus-broker-29/src/util/selinux.c 2021-04-13 14:02:46.364546300 +0200 @@ -300,6 +300,12 @@ case SELINUX_AVC: audit_type = UTIL_AUDIT_TYPE_AVC; break; + case SELINUX_POLICYLOAD: + audit_type = UTIL_AUDIT_TYPE_POLICYLOAD; + break; + case SELINUX_SETENFORCE: + audit_type = UTIL_AUDIT_TYPE_MAC_STATUS; + break; default: /* not an auditable message. */ audit_type = UTIL_AUDIT_TYPE_NOAUDIT; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-dvar/AUTHORS new/dbus-broker-29/subprojects/c-dvar/AUTHORS --- old/dbus-broker-28/subprojects/c-dvar/AUTHORS 2021-03-17 12:22:45.762383200 +0100 +++ new/dbus-broker-29/subprojects/c-dvar/AUTHORS 2021-04-13 14:01:42.414003100 +0200 @@ -30,8 +30,9 @@ along with this program; If not, see <http://www.gnu.org/licenses/>. COPYRIGHT: (ordered alphabetically) - Copyright (C) 2015-2019 Red Hat, Inc. + Copyright (C) 2015-2021 Red Hat, Inc. AUTHORS: (ordered alphabetically) + Adrian Szyndela <adria...@samsung.com> David Rheinsberg <david.rheinsb...@gmail.com> Tom Gundersen <t...@jklm.no> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-dvar/src/c-dvar-reader.c new/dbus-broker-29/subprojects/c-dvar/src/c-dvar-reader.c --- old/dbus-broker-28/subprojects/c-dvar/src/c-dvar-reader.c 2021-03-17 12:22:45.762383200 +0100 +++ new/dbus-broker-29/subprojects/c-dvar/src/c-dvar-reader.c 2021-04-13 14:01:42.414003100 +0200 @@ -426,17 +426,14 @@ } static int c_dvar_ff(CDVar *var) { - size_t depth = 0; + size_t t, depth = 0; char c; int r; - if (!var->current->n_type) - return -ENOTRECOVERABLE; - do { if (var->current->n_type && (var->current->container != 'a' || c_dvar_more(var))) { c = var->current->i_type->element; - } else { + } else if (depth > 0) { switch (var->current->container) { case 'a': c = ']'; @@ -453,6 +450,13 @@ default: return -ENOTRECOVERABLE; } + } else { + /* + * You cannot fast-forward if you are at the end of a + * compound type, or past the last element of an array. + * There is nothing to skip. + */ + return -ENOTRECOVERABLE; } switch (c) { @@ -480,6 +484,32 @@ assert(depth > 0); --depth; break; + case 'y': + case 'n': + case 'q': + case 'i': + case 'h': + case 'u': + case 'x': + case 't': + case 'd': + /* + * If we are skipping an entire array with a fixed size + * member, we can jump over all members in one go. Note + * that this only works if the member does not need any + * validation (this excludes 'b' and any non-basic + * type), because callers rely on this function to + * check for content validity. + */ + if (depth > 0 && var->current->container == 'a') { + t = var->current->n_buffer % var->current->i_type->size; + var->current->i_buffer += var->current->n_buffer - t; + var->current->n_buffer = t; + + c = ']'; + --depth; + } + break; } r = c_dvar_read(var, (char [2]){ c, 0 }, NULL); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-dvar/src/test-basic.c new/dbus-broker-29/subprojects/c-dvar/src/test-basic.c --- old/dbus-broker-28/subprojects/c-dvar/src/test-basic.c 2021-03-17 12:22:45.765716600 +0100 +++ new/dbus-broker-29/subprojects/c-dvar/src/test-basic.c 2021-04-13 14:01:42.414003100 +0200 @@ -196,10 +196,98 @@ free(data); } +static void test_skip(void) { + _c_cleanup_(c_dvar_type_freep) CDVarType *type = NULL; + _c_cleanup_(c_dvar_freep) CDVar *var = NULL; + size_t n_data; + void *data; + uint64_t t0, t1; + int r; + + /* + * A very basic serialization and deserialization test that serves as + * base-line for reader/writer operation testing. + * + * We simply allocate and build a variant of a fixed type, then read it + * back and verify the data matches. + */ + + r = c_dvar_type_new_from_string(&type, "at"); + c_assert(!r); + + r = c_dvar_new(&var); + c_assert(!r); + + /* write example data */ + + c_dvar_begin_write(var, (__BYTE_ORDER == __BIG_ENDIAN), type, 1); + + c_dvar_write(var, "[tt]", UINT64_C(7), UINT64_C(127)); + + r = c_dvar_end_write(var, &data, &n_data); + c_assert(!r); + + /* read back example data */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_read(var, "[tt]", &t0, &t1); + c_assert(t0 == 7); + c_assert(t1 == 127); + + r = c_dvar_end_read(var); + c_assert(!r); + + /* skip example data */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_skip(var, "*"); + + r = c_dvar_end_read(var); + c_assert(!r); + + /* skip single array member */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_skip(var, "[*t]"); + + r = c_dvar_end_read(var); + c_assert(!r); + + /* skip both array members */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_skip(var, "[**]"); + + r = c_dvar_end_read(var); + c_assert(!r); + + /* skip past last member */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_skip(var, "[tt*"); + c_assert(c_dvar_get_poison(var) == -ENOTRECOVERABLE); + + /* skip past array */ + + c_dvar_begin_read(var, c_dvar_is_big_endian(var), type, 1, data, n_data); + + c_dvar_skip(var, "[tt]*"); + c_assert(c_dvar_get_poison(var) == -ENOTRECOVERABLE); + + c_dvar_end_read(var); + free(data); +} + int main(int argc, char **argv) { test_basic_serialization(true); test_basic_serialization(false); test_dbus_message(); test_dbus_body(); + test_skip(); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/.github/workflows/ci.yml new/dbus-broker-29/subprojects/c-list/.github/workflows/ci.yml --- old/dbus-broker-28/subprojects/c-list/.github/workflows/ci.yml 2021-03-17 12:22:45.859051700 +0100 +++ new/dbus-broker-29/subprojects/c-list/.github/workflows/ci.yml 2021-04-13 14:01:43.727347600 +0200 @@ -19,3 +19,30 @@ with: m32: 1 valgrind: 1 + + ci-msvc: + name: CI with MSVC + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2016, windows-latest] + + steps: + - name: Fetch Sources + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install Python Dependencies + run: pip install meson ninja + - name: Prepare MSVC + uses: bus1/cabuild/action/msdevshell@v1 + with: + architecture: x64 + - name: Prepare Build + run: meson setup build + - name: Run Build + run: meson compile -v -C build + - name: Run Test Suite + run: meson test -v -C build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/AUTHORS new/dbus-broker-29/subprojects/c-list/AUTHORS --- old/dbus-broker-28/subprojects/c-list/AUTHORS 2021-03-17 12:22:45.859051700 +0100 +++ new/dbus-broker-29/subprojects/c-list/AUTHORS 2021-04-13 14:01:43.727347600 +0200 @@ -33,6 +33,8 @@ Copyright (C) 2015-2019 Red Hat, Inc. AUTHORS: (ordered alphabetically) + Danilo Horta <danilo.ho...@pm.me> David Rheinsberg <david.rheinsb...@gmail.com> + Lucas De Marchi <lucas.de.mar...@gmail.com> Thomas Haller <thal...@redhat.com> Tom Gundersen <t...@jklm.no> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/meson.build new/dbus-broker-29/subprojects/c-list/meson.build --- old/dbus-broker-28/subprojects/c-list/meson.build 2021-03-17 12:22:45.859051700 +0100 +++ new/dbus-broker-29/subprojects/c-list/meson.build 2021-04-13 14:01:43.727347600 +0200 @@ -4,7 +4,7 @@ version: '3', license: 'Apache', default_options: [ - 'c_std=c11', + 'c_std=c99', ], ) project_description = 'Circular Intrusive Double Linked List Collection' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/src/c-list.h new/dbus-broker-29/subprojects/c-list/src/c-list.h --- old/dbus-broker-28/subprojects/c-list/src/c-list.h 2021-03-17 12:22:45.859051700 +0100 +++ new/dbus-broker-29/subprojects/c-list/src/c-list.h 2021-04-13 14:01:43.727347600 +0200 @@ -22,6 +22,7 @@ #endif #include <stddef.h> +#include <stdint.h> typedef struct CList CList; @@ -50,9 +51,42 @@ /** * c_list_init() - initialize list entry * @what: list entry to initialize + * + * Return: @what is returned. */ -static inline void c_list_init(CList *what) { +static inline CList *c_list_init(CList *what) { *what = (CList)C_LIST_INIT(*what); + return what; +} + +/** + * c_list_entry_offset() - get parent container of list entry + * @what: list entry, or NULL + * @offset: offset of the list member in its surrounding type + * + * If the list entry @what is embedded into a surrounding structure, this will + * turn the list entry pointer @what into a pointer to the parent container + * (sometimes called container_of(3)). Use the `c_list_entry()` macro for an + * easier API. + * + * If @what is NULL, this will also return NULL. + * + * Return: Pointer to parent container, or NULL. + */ +static inline void *c_list_entry_offset(const CList *what, size_t offset) { + if (what) { + /* + * We allow calling "c_list_entry()" on the list head, which is + * commonly a plain CList struct. The returned entry pointer is + * thus invalid. For instance, this is used by the + * c_list_for_each_entry*() macros. Gcc correctly warns about that + * with "-Warray-bounds". However, as long as the value is never + * dereferenced, this is fine. We explicitly use integer arithmetic + * to circumvent the Gcc warning. + */ + return (void *)(((uintptr_t)(void *)what) - offset); + } + return NULL; } /** @@ -70,8 +104,7 @@ * Return: Pointer to parent container, or NULL. */ #define c_list_entry(_what, _t, _m) \ - ((_t *)(void *)(((unsigned long)(void *)(_what) ?: \ - offsetof(_t, _m)) - offsetof(_t, _m))) + ((_t *)c_list_entry_offset((_what), offsetof(_t, _m))) /** * c_list_is_linked() - check whether an entry is linked @@ -306,32 +339,47 @@ * state. */ +/* direct/raw iterators */ + #define c_list_for_each(_iter, _list) \ for (_iter = (_list)->next; \ (_iter) != (_list); \ _iter = (_iter)->next) -#define c_list_for_each_entry(_iter, _list, _m) \ - for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m); \ - &(_iter)->_m != (_list); \ - _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) - #define c_list_for_each_safe(_iter, _safe, _list) \ for (_iter = (_list)->next, _safe = (_iter)->next; \ (_iter) != (_list); \ _iter = (_safe), _safe = (_safe)->next) +#define c_list_for_each_continue(_iter, _list) \ + for (_iter = (_iter) ? (_iter)->next : (_list)->next; \ + (_iter) != (_list); \ + _iter = (_iter)->next) + +#define c_list_for_each_safe_continue(_iter, _safe, _list) \ + for (_iter = (_iter) ? (_iter)->next : (_list)->next, \ + _safe = (_iter)->next; \ + (_iter) != (_list); \ + _iter = (_safe), _safe = (_safe)->next) + +#define c_list_for_each_safe_unlink(_iter, _safe, _list) \ + for (_iter = (_list)->next, _safe = (_iter)->next; \ + c_list_init(_iter) != (_list); \ + _iter = (_safe), _safe = (_safe)->next) + +/* c_list_entry() based iterators */ + +#define c_list_for_each_entry(_iter, _list, _m) \ + for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m); \ + &(_iter)->_m != (_list); \ + _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) + #define c_list_for_each_entry_safe(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m), \ _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ &(_iter)->_m != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ - -#define c_list_for_each_continue(_iter, _list) \ - for (_iter = (_iter) ? (_iter)->next : (_list)->next; \ - (_iter) != (_list); \ - _iter = (_iter)->next) + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) #define c_list_for_each_entry_continue(_iter, _list, _m) \ for (_iter = c_list_entry((_iter) ? (_iter)->_m.next : (_list)->next, \ @@ -340,12 +388,6 @@ &(_iter)->_m != (_list); \ _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) -#define c_list_for_each_safe_continue(_iter, _safe, _list) \ - for (_iter = (_iter) ? (_iter)->next : (_list)->next, \ - _safe = (_iter)->next; \ - (_iter) != (_list); \ - _iter = (_safe), _safe = (_safe)->next) - #define c_list_for_each_entry_safe_continue(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_iter) ? (_iter)->_m.next : (_list)->next, \ __typeof__(*_iter), \ @@ -353,20 +395,14 @@ _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ &(_iter)->_m != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ - -#define c_list_for_each_safe_unlink(_iter, _safe, _list) \ - for (_iter = (_list)->next, _safe = (_iter)->next; \ - ((*_iter = (CList)C_LIST_INIT(*_iter)), (_iter) != (_list)); \ - _iter = (_safe), _safe = (_safe)->next) + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) #define c_list_for_each_entry_safe_unlink(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m), \ _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ - (((_iter)->_m = (CList)C_LIST_INIT((_iter)->_m)), \ - &(_iter)->_m != (_list)); \ + c_list_init(&(_iter)->_m) != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) /** * c_list_flush() - flush all entries from a list @@ -402,8 +438,8 @@ * * Return: Number of items in @list. */ -static inline unsigned long c_list_length(const CList *list) { - unsigned long n = 0; +static inline size_t c_list_length(const CList *list) { + size_t n = 0; const CList *iter; c_list_for_each(iter, list) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/src/test-api.c new/dbus-broker-29/subprojects/c-list/src/test-api.c --- old/dbus-broker-28/subprojects/c-list/src/test-api.c 2021-03-17 12:22:45.862385300 +0100 +++ new/dbus-broker-29/subprojects/c-list/src/test-api.c 2021-04-13 14:01:43.727347600 +0200 @@ -18,8 +18,11 @@ static void test_api(void) { CList *list_iter, *list_safe, list = C_LIST_INIT(list); - Node *node_iter, *node_safe, node = { .id = 0, .link = C_LIST_INIT(node.link) }; + Node node = { .id = 0, .link = C_LIST_INIT(node.link) }; + assert(c_list_init(&list) == &list); + assert(!c_list_entry_offset(NULL, 0)); + assert(!c_list_entry_offset(NULL, offsetof(Node, link))); assert(!c_list_entry(NULL, Node, link)); assert(c_list_entry(&node.link, Node, link) == &node); assert(!c_list_is_linked(&node.link)); @@ -73,28 +76,24 @@ c_list_splice(&list, &list); assert(c_list_is_empty(&list)); - /* loop macros */ + /* direct/raw iterators */ c_list_for_each(list_iter, &list) assert(list_iter != &list); - c_list_for_each_entry(node_iter, &list, link) - assert(&node_iter->link != &list); + c_list_for_each_safe(list_iter, list_safe, &list) assert(list_iter != &list); - c_list_for_each_entry_safe(node_iter, node_safe, &list, link) - assert(&node_iter->link != &list); + + list_iter = NULL; c_list_for_each_continue(list_iter, &list) assert(list_iter != &list); - c_list_for_each_entry_continue(node_iter, &list, link) - assert(&node_iter->link != &list); + + list_iter = NULL; c_list_for_each_safe_continue(list_iter, list_safe, &list) assert(list_iter != &list); - c_list_for_each_entry_safe_continue(node_iter, node_safe, &list, link) - assert(&node_iter->link != &list); + c_list_for_each_safe_unlink(list_iter, list_safe, &list) assert(list_iter != &list); - c_list_for_each_entry_safe_unlink(node_iter, node_safe, &list, link) - assert(&node_iter->link != &list); /* list accessors */ @@ -104,7 +103,37 @@ assert(!c_list_last_entry(&list, Node, link)); } -int main(int argc, char **argv) { +#if defined(__GNUC__) || defined(__clang__) +static void test_api_gnu(void) { + CList list = C_LIST_INIT(list); + Node *node_iter, *node_safe; + + /* c_list_entry() based iterators */ + + c_list_for_each_entry(node_iter, &list, link) + assert(&node_iter->link != &list); + + c_list_for_each_entry_safe(node_iter, node_safe, &list, link) + assert(&node_iter->link != &list); + + node_iter = NULL; + c_list_for_each_entry_continue(node_iter, &list, link) + assert(&node_iter->link != &list); + + node_iter = NULL; + c_list_for_each_entry_safe_continue(node_iter, node_safe, &list, link) + assert(&node_iter->link != &list); + + c_list_for_each_entry_safe_unlink(node_iter, node_safe, &list, link) + assert(&node_iter->link != &list); +} +#else +static void test_api_gnu(void) { +} +#endif + +int main(void) { test_api(); + test_api_gnu(); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/src/test-basic.c new/dbus-broker-29/subprojects/c-list/src/test-basic.c --- old/dbus-broker-28/subprojects/c-list/src/test-basic.c 2021-03-17 12:22:49.962468100 +0100 +++ new/dbus-broker-29/subprojects/c-list/src/test-basic.c 2021-04-13 14:01:43.727347600 +0200 @@ -160,17 +160,16 @@ static void test_flush(void) { CList e1 = C_LIST_INIT(e1), e2 = C_LIST_INIT(e2); + CList list1 = C_LIST_INIT(list1), list2 = C_LIST_INIT(list2); - { - __attribute__((__cleanup__(c_list_flush))) CList list1 = C_LIST_INIT(list1); - __attribute__((__cleanup__(c_list_flush))) CList list2 = C_LIST_INIT(list2); + c_list_link_tail(&list2, &e1); + c_list_link_tail(&list2, &e2); - c_list_link_tail(&list2, &e1); - c_list_link_tail(&list2, &e2); + assert(c_list_is_linked(&e1)); + assert(c_list_is_linked(&e2)); - assert(c_list_is_linked(&e1)); - assert(c_list_is_linked(&e2)); - } + c_list_flush(&list1); + c_list_flush(&list2); assert(!c_list_is_linked(&e1)); assert(!c_list_is_linked(&e2)); @@ -193,11 +192,36 @@ } } -int main(int argc, char **argv) { +#if defined(__GNUC__) || defined(__clang__) +static void test_gnu(void) { + CList e1 = C_LIST_INIT(e1), e2 = C_LIST_INIT(e2); + + /* Test `c_list_flush()` in combination with cleanup attributes. */ + { + __attribute((cleanup(c_list_flush))) CList list1 = C_LIST_INIT(list1); + __attribute((cleanup(c_list_flush))) CList list2 = C_LIST_INIT(list2); + + c_list_link_tail(&list2, &e1); + c_list_link_tail(&list2, &e2); + + assert(c_list_is_linked(&e1)); + assert(c_list_is_linked(&e2)); + } + + assert(!c_list_is_linked(&e1)); + assert(!c_list_is_linked(&e2)); +} +#else +static void test_gnu(void) { +} +#endif + +int main(void) { test_iterators(); test_swap(); test_splice(); test_flush(); test_macros(); + test_gnu(); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-list/src/test-embed.c new/dbus-broker-29/subprojects/c-list/src/test-embed.c --- old/dbus-broker-28/subprojects/c-list/src/test-embed.c 2021-03-17 12:22:45.862385300 +0100 +++ new/dbus-broker-29/subprojects/c-list/src/test-embed.c 2021-04-13 14:01:43.727347600 +0200 @@ -23,7 +23,8 @@ Entry e2 = { .foo = 2 * 7, .bar = 2 * 11 }; Entry e3 = { .foo = 3 * 7, .bar = 3 * 11 }; Entry e4 = { .foo = 4 * 7, .bar = 4 * 11 }; - Entry *e, *safe; + Entry *e; + CList *iter, *safe; size_t i; /* verify c_list_entry() works as expected (even with NULL) */ @@ -47,7 +48,8 @@ assert(c_list_last_entry(&list, Entry, link)->bar == 2 * 11); i = 0; - c_list_for_each_entry(e, &list, link) { + c_list_for_each(iter, &list) { + e = c_list_entry(iter, Entry, link); assert(i != 0 || e == &e1); assert(i != 1 || e == &e2); assert(i < 2); @@ -66,6 +68,63 @@ assert(c_list_last_entry(&list, Entry, link)->bar == 4 * 11); i = 0; + c_list_for_each(iter, &list) { + e = c_list_entry(iter, Entry, link); + assert(i != 0 || e == &e1); + assert(i != 1 || e == &e2); + assert(i != 2 || e == &e3); + assert(i != 3 || e == &e4); + assert(i < 4); + ++i; + } + assert(i == 4); + + assert(!c_list_is_empty(&list)); + assert(c_list_is_linked(&e1.link)); + assert(c_list_is_linked(&e2.link)); + assert(c_list_is_linked(&e3.link)); + assert(c_list_is_linked(&e4.link)); + + /* remove via safe iterator */ + + i = 0; + c_list_for_each_safe(iter, safe, &list) { + e = c_list_entry(iter, Entry, link); + assert(i != 0 || e == &e1); + assert(i != 1 || e == &e2); + assert(i != 2 || e == &e3); + assert(i != 3 || e == &e4); + assert(i < 4); + ++i; + c_list_unlink(&e->link); + } + assert(i == 4); + + assert(c_list_is_empty(&list)); + assert(!c_list_is_linked(&e1.link)); + assert(!c_list_is_linked(&e2.link)); + assert(!c_list_is_linked(&e3.link)); + assert(!c_list_is_linked(&e4.link)); +} + +#if defined(__GNUC__) || defined(__clang__) +static void test_entry_gnu(void) { + CList list = C_LIST_INIT(list); + Entry e1 = { .foo = 1 * 7, .bar = 1 * 11 }; + Entry e2 = { .foo = 2 * 7, .bar = 2 * 11 }; + Entry e3 = { .foo = 3 * 7, .bar = 3 * 11 }; + Entry e4 = { .foo = 4 * 7, .bar = 4 * 11 }; + Entry *e, *safe; + size_t i; + + /* link entries and verify list state */ + + c_list_link_tail(&list, &e1.link); + c_list_link_tail(&list, &e2.link); + c_list_link_tail(&list, &e3.link); + c_list_link_tail(&list, &e4.link); + + i = 0; c_list_for_each_entry(e, &list, link) { assert(i != 0 || e == &e1); assert(i != 1 || e == &e2); @@ -102,8 +161,13 @@ assert(!c_list_is_linked(&e3.link)); assert(!c_list_is_linked(&e4.link)); } +#else +static void test_entry_gnu(void) { +} +#endif -int main(int argc, char **argv) { +int main(void) { test_entry(); + test_entry_gnu(); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-stdaux/src/test-api.c new/dbus-broker-29/subprojects/c-stdaux/src/test-api.c --- old/dbus-broker-28/subprojects/c-stdaux/src/test-api.c 2021-03-17 12:22:51.732504000 +0100 +++ new/dbus-broker-29/subprojects/c-stdaux/src/test-api.c 2021-03-18 11:21:06.821794700 +0100 @@ -11,8 +11,10 @@ static _c_const_ int const_fn(void) { return 0; } static _c_deprecated_ _c_unused_ int deprecated_fn(void) { return 0; } +_c_hidden_ int c_internal_hidden_fn(void); _c_hidden_ int c_internal_hidden_fn(void) { return 0; } static _c_printf_(1, 2) int printf_fn(const _c_unused_ char *f, ...) { return 0; } +_c_public_ int c_internal_public_fn(void); _c_public_ int c_internal_public_fn(void) { return 0; } static _c_pure_ int pure_fn(void) { return 0; } static _c_sentinel_ int sentinel_fn(const _c_unused_ char *f, ...) { return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-utf8/src/bench-ascii.c new/dbus-broker-29/subprojects/c-utf8/src/bench-ascii.c --- old/dbus-broker-28/subprojects/c-utf8/src/bench-ascii.c 2021-03-17 12:22:46.045722200 +0100 +++ new/dbus-broker-29/subprojects/c-utf8/src/bench-ascii.c 2021-03-18 11:21:07.515138100 +0100 @@ -13,7 +13,7 @@ #include "c-utf8.h" #include "trivial-utf8.h" -uint64_t test_get_time(void) { +static uint64_t test_get_time(void) { struct timespec ts; int r; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dbus-broker-28/subprojects/c-utf8/src/bench-multibyte.c new/dbus-broker-29/subprojects/c-utf8/src/bench-multibyte.c --- old/dbus-broker-28/subprojects/c-utf8/src/bench-multibyte.c 2021-03-17 12:22:46.045722200 +0100 +++ new/dbus-broker-29/subprojects/c-utf8/src/bench-multibyte.c 2021-03-18 11:21:07.515138100 +0100 @@ -13,7 +13,7 @@ #include "c-utf8.h" #include "trivial-utf8.h" -uint64_t test_get_time(void) { +static uint64_t test_get_time(void) { struct timespec ts; int r;