diff options
author | Federico Mena Quintero <federico.mena@gmail.com> | 2021-12-14 22:30:54 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico.mena@gmail.com> | 2021-12-14 22:30:54 +0000 |
commit | a607ce0cb87e8ad66680920dac241ec655d42b11 (patch) | |
tree | 9d1f2eb06feab526b468859914648b7f1d1acea3 | |
parent | 412bdee0a1daa3fe9bc7d1fa289a31495dff3387 (diff) | |
parent | ae90cda15b5edc23c72f994b4da9b39c965afdd1 (diff) | |
download | at-spi2-core-a607ce0cb87e8ad66680920dac241ec655d42b11.tar.gz |
Merge branch 'ci' into 'master'
Initial CI scripts
See merge request GNOME/at-spi2-core!63
-rw-r--r-- | .gitlab-ci.yml | 215 | ||||
-rw-r--r-- | .gitlab-ci/gen-coverage.sh | 30 | ||||
-rw-r--r-- | .gitlab-ci/lcovrc | 13 | ||||
-rwxr-xr-x | .gitlab-ci/run-style-check.sh | 33 | ||||
-rwxr-xr-x | .gitlab-ci/run-tests.sh | 16 | ||||
-rwxr-xr-x | .gitlab-ci/search-common-ancestor.sh | 36 | ||||
-rw-r--r-- | atspi/atspi-device-legacy.c | 2 | ||||
-rw-r--r-- | atspi/atspi-device-x11.c | 2 | ||||
-rw-r--r-- | atspi/atspi-event-listener.c | 9 | ||||
-rw-r--r-- | atspi/atspi-misc.c | 74 | ||||
-rw-r--r-- | bus/at-spi-bus-launcher.c | 143 | ||||
-rw-r--r-- | dbind/dbtest.c | 3 | ||||
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | registryd/deviceeventcontroller-x11.c | 14 | ||||
-rw-r--r-- | registryd/deviceeventcontroller.c | 20 | ||||
-rw-r--r-- | registryd/registry.c | 2 | ||||
-rw-r--r-- | test/memory.c | 15 |
17 files changed, 526 insertions, 104 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..a5f371ab --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,215 @@ +variables: + +stages: +# - style-check + - build + - analysis + - docs + - deploy + +.only-default: + variables: + PROJECT_DEPS: + gcc + dbus-1 + dbus-1-devel + gettext + git + glib2-devel + gobject-introspection-devel + gsettings-desktop-schemas + itstool + libxml2-devel + libxkbcommon-devel + libXi-devel + libXtst-devel + meson + ninja + python38 + python38-gobject + only: + - merge_requests + - branches + except: + - tags + +# style-check-diff: +# extends: .only-default +# image: fedora:latest +# stage: style-check +# script: +# - dnf install -y clang-tools-extra curl diffutils git +# - sh -x ./.gitlab-ci/run-style-check.sh + +# Recipe for setting up the build +# @PROJECT_DEPS: the dependencies of the project (on openSUSE) +# @MESON_VERSION: the version of Meson required by the project +.build-setup: + image: opensuse/tumbleweed + extends: .only-default + before_script: + - zypper refresh + - zypper install -y ${PROJECT_DEPS} ${EXTRA_DEPS} + +# Default build recipe +# @PROJECT_DEPS: the dependencies of the project (on openSUSE) +# @MESON_VERSION: the version of Meson required by the project +# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation +.build-default: + image: opensuse/tumbleweed + extends: .only-default + before_script: + - zypper refresh + - zypper install -y ${PROJECT_DEPS} ${EXTRA_DEPS} + script: + - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build . + - meson compile -C _build + - meson install -C _build + - dbus-run-session -- .gitlab-ci/run-tests.sh + artifacts: + reports: + junit: "_build/meson-logs/testlog.junit.xml" + when: always + name: "at-spi2-core-${CI_COMMIT_REF_NAME}" + paths: + - "${CI_PROJECT_DIR}/_build/meson-logs" + - "${CI_PROJECT_DIR}/_build/atspi/Atspi-2.0.gir" + +# Inherit to build the API reference via gi-docgen +# @PROJECT_DEPS: the dependencies of the project (on Fedora) +# @MESON_VERSION: the version of Meson required by the project +# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation +# @DOCS_FLAGS: doc-related arguments for the meson setup invocation +# @DOCS_PATH: the docs output directory under the build directory +# .gidocgen-build: +# image: fedora:latest +# before_script: +# - export PATH="$HOME/.local/bin:$PATH" +# - dnf install -y python3 python3-pip python3-wheel gobject-introspection-devel graphviz ninja-build redhat-rpm-config +# - dnf install -y ${PROJECT_DEPS} +# - pip3 install --user meson==${MESON_VERSION} gi-docgen jinja2 Markdown markupsafe pygments toml typogrify +# script: +# - meson setup ${MESON_EXTRA_FLAGS} ${DOCS_FLAGS} _docs . +# - meson compile -C _docs +# - | +# pushd "_docs/${DOCS_PATH}" > /dev/null +# tar cf ${CI_PROJECT_NAME}-docs.tar . +# popd > /dev/null +# - mv _docs/${DOCS_PATH}/${CI_PROJECT_NAME}-docs.tar . +# artifacts: +# when: always +# name: 'Documentation' +# expose_as: 'Download the API reference' +# paths: +# - ${CI_PROJECT_NAME}-docs.tar + +opensuse-x86_64: + extends: .build-default + stage: build + needs: [] + variables: + MESON_EXTRA_FLAGS: "--buildtype=debug" # -Dwerror=true + +static-scan: + extends: .build-setup + stage: analysis + needs: [] + variables: + EXTRA_DEPS: + clang + clang-tools + MESON_EXTRA_FLAGS: "--buildtype=debug -Dintrospection=no -Ddocs=false" + script: + - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _scan_build . + - ninja -C _scan_build scan-build + artifacts: + name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" + when: always + paths: + - "_scan_build/meson-logs/scanbuild" + +asan-build: + extends: .build-setup + stage: analysis + needs: [] + variables: + EXTRA_DEPS: + clang-tools + libasan6 + MESON_EXTRA_FLAGS: "--buildtype=debug -Db_sanitize=address -Db_lundef=false -Dintrospection=no -Ddocs=false" + script: + - CC=clang meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build . + - meson compile -C _build + - dbus-run-session -- .gitlab-ci/run-tests.sh + artifacts: + name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" + when: always + paths: + - "_asan_build/meson-logs" + allow_failure: true + +coverage: + extends: .build-setup + stage: analysis + needs: [] + variables: + EXTRA_DEPS: + lcov + MESON_EXTRA_FLAGS: "--buildtype=debug -Ddocs=false -Dintrospection=no" + CFLAGS: "-coverage -ftest-coverage -fprofile-arcs" + script: + - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build . + - meson compile -C _build + - meson install -C _build + - mkdir -p _coverage + - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov" + - dbus-run-session -- .gitlab-ci/run-tests.sh + - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov" + - bash -x .gitlab-ci/gen-coverage.sh + coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/' + artifacts: + name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" + when: always + paths: + - "_build/meson-logs" + - "_coverage" + allow_failure: true + +# reference: +# stage: docs +# needs: [] +# extends: .gidocgen-build +# variables: +# PROJECT_DEPS: +# gdk-pixbuf2-devel +# geocode-glib-devel +# gettext +# git +# gobject-introspection-devel +# itstool +# libsoup-devel +# libxml2-devel +# ninja-build +# pylint +# python3 +# python3-gobject +# python3-pip +# python3-wheel +# redhat-rpm-config +# vala +# MESON_VERSION: "0.55.3" +# DOCS_FLAGS: -Dgtk_doc=true +# DOCS_PATH: doc/libgweather-4.0 +# +# pages: +# stage: deploy +# needs: ['reference'] +# script: +# - mkdir public && cd public +# - tar xf ../${CI_PROJECT_NAME}-docs.tar +# artifacts: +# paths: +# - public +# only: +# - master +# - main diff --git a/.gitlab-ci/gen-coverage.sh b/.gitlab-ci/gen-coverage.sh new file mode 100644 index 00000000..39492565 --- /dev/null +++ b/.gitlab-ci/gen-coverage.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +for path in _coverage/*.lcov; do + lcov --config-file .gitlab-ci/lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}" + lcov --config-file .gitlab-ci/lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}" +done + +genhtml \ + --ignore-errors=source \ + --config-file .gitlab-ci/lcovrc \ + _coverage/*.lcov \ + -o _coverage/coverage + +cd _coverage +rm -f ./*.lcov + +cat >index.html <<EOL +<html> +<head><title>at-spi2-core Coverage</title></head> +<body> +<div> +<ul> +<li><a href="coverage/index.html">Coverage report</a></li> +</ul> +</div> +</body> +</html> +EOL diff --git a/.gitlab-ci/lcovrc b/.gitlab-ci/lcovrc new file mode 100644 index 00000000..ac5997b7 --- /dev/null +++ b/.gitlab-ci/lcovrc @@ -0,0 +1,13 @@ +# lcov and genhtml configuration +# See http://ltp.sourceforge.net/coverage/lcov/lcovrc.5.php + +# Always enable branch coverage +lcov_branch_coverage = 1 + +# Exclude precondition assertions, as we can never reasonably get full branch +# coverage of them, as they should never normally fail. +# See https://github.com/linux-test-project/lcov/issues/44 +lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_ + +# Similarly for unreachable assertions. +lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached diff --git a/.gitlab-ci/run-style-check.sh b/.gitlab-ci/run-style-check.sh new file mode 100755 index 00000000..9d741bcc --- /dev/null +++ b/.gitlab-ci/run-style-check.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +ancestor_horizon=28 # days (4 weeks) + +# Wrap everything in a subshell so we can propagate the exit status. +( + +source .gitlab-ci/search-common-ancestor.sh + +git diff -U0 --no-color "${newest_common_ancestor_sha}" atspi/*.c bus/*.c dbind/*.c registryd/*.c test/*.c | clang-format-diff -p1 > format-diff.log + +) +exit_status=$? + +[ ${exit_status} == 0 ] || exit ${exit_status} + +format_diff="$(<format-diff.log)" + +if [ -n "${format_diff}" ]; then + echo 'body=```diff' > format.log + cat format-diff.log >> format.log + echo '```' >> format.log + [ -n "$CI_MERGE_REQUEST_IID" ] && curl \ + --request POST \ + --header "Private-Token: $STYLE_CHECK_TOKEN" \ + --data-urlencode "$(<format.log)" \ + https://gitlab.gnome.org/api/v4/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes \ + --insecure + unlink format.log + exit 1 +fi diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh new file mode 100755 index 00000000..366bdc3a --- /dev/null +++ b/.gitlab-ci/run-tests.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "About to run the tests. First we'll launch the accessibility bus by calling GetAddress:" + +dbus-send --print-reply --session --dest=org.a11y.Bus /org/a11y/bus org.a11y.Bus.GetAddress + +ps auxwww + +echo "Now running the tests:" + +meson test -C _build + +echo "After the tests - calling GetAddress again:" + +dbus-send --print-reply --session --dest=org.a11y.Bus /org/a11y/bus org.a11y.Bus.GetAddress + diff --git a/.gitlab-ci/search-common-ancestor.sh b/.gitlab-ci/search-common-ancestor.sh new file mode 100755 index 00000000..bac99d2c --- /dev/null +++ b/.gitlab-ci/search-common-ancestor.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +ancestor_horizon=28 # days (4 weeks) + +# We need to add a new remote for the upstream target branch, since this script +# could be running in a personal fork of the repository which has out of date +# branches. +# +# Limit the fetch to a certain date horizon to limit the amount of data we get. +# If the branch was forked from origin/main before this horizon, it should +# probably be rebased. +if ! git ls-remote --exit-code upstream >/dev/null 2>&1 ; then + git remote add upstream https://gitlab.gnome.org/GNOME/${CI_PROJECT_NAME}.git +fi +git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" upstream + +# Work out the newest common ancestor between the detached HEAD that this CI job +# has checked out, and the upstream target branch (which will typically be +# `upstream/main` or `upstream/gnome-40`). +# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` or `${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}` +# are only defined if we’re running in a merge request pipeline, +# fall back to `${CI_DEFAULT_BRANCH}` or `${CI_COMMIT_BRANCH}` respectively +# otherwise. + +source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}" +git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" origin "${source_branch}" + +newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "origin/${source_branch}") | head -1) +if [ -z "${newest_common_ancestor_sha}" ]; then + echo "Couldn’t find common ancestor with upstream main branch. This typically" + echo "happens if you branched from main a long time ago. Please update" + echo "your clone, rebase, and re-push your branch." + exit 1 +fi diff --git a/atspi/atspi-device-legacy.c b/atspi/atspi-device-legacy.c index eb677685..bfb63d4b 100644 --- a/atspi/atspi-device-legacy.c +++ b/atspi/atspi-device-legacy.c @@ -212,8 +212,8 @@ atspi_device_legacy_unmap_modifier (AtspiDevice *device, gint keycode) AtspiLegacyKeyModifier *entry = l->data; if (entry->keycode == keycode) { - g_free (entry); priv->modifiers = g_slist_remove (priv->modifiers, entry); + g_free (entry); return; } } diff --git a/atspi/atspi-device-x11.c b/atspi/atspi-device-x11.c index 4f88e609..eafdba62 100644 --- a/atspi/atspi-device-x11.c +++ b/atspi/atspi-device-x11.c @@ -516,8 +516,8 @@ atspi_device_x11_unmap_modifier (AtspiDevice *device, gint keycode) AtspiX11KeyModifier *entry = l->data; if (entry->keycode == keycode) { - g_free (entry); priv->modifiers = g_slist_remove (priv->modifiers, entry); + g_free (entry); return; } } diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c index 5455b589..5cdc8064 100644 --- a/atspi/atspi-event-listener.c +++ b/atspi/atspi-event-listener.c @@ -1000,6 +1000,13 @@ _atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data) } category++; } + else + { + // TODO: Error + // Note that the single caller of this function, process_deferred_message(), ignores the return value. + // We should probably free the message if we aren't going to process it after all. + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } dbus_message_iter_get_basic (&iter, &detail); dbus_message_iter_next (&iter); dbus_message_iter_get_basic (&iter, &detail1); @@ -1087,6 +1094,8 @@ _atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data) break; } + g_assert (e.source != NULL); + dbus_message_iter_next (&iter); if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY) { diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c index 7af46e9f..d896afbd 100644 --- a/atspi/atspi-misc.c +++ b/atspi/atspi-misc.c @@ -877,43 +877,6 @@ atspi_dbus_filter (DBusConnection *bus, DBusMessage *message, void *data) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -/* - * Returns a 'canonicalized' value for DISPLAY, - * with the screen number stripped off if present. - * - * TODO: Avoid having duplicate functions for this here and in at-spi2-atk - */ -static gchar * -spi_display_name (void) -{ - char *canonical_display_name = NULL; - const gchar *display_env = g_getenv ("AT_SPI_DISPLAY"); - - if (!display_env) - { - display_env = g_getenv ("DISPLAY"); - if (!display_env || !display_env[0]) - return NULL; - else - { - gchar *display_p, *screen_p; - canonical_display_name = g_strdup (display_env); - display_p = g_utf8_strrchr (canonical_display_name, -1, ':'); - screen_p = g_utf8_strrchr (canonical_display_name, -1, '.'); - if (screen_p && display_p && (screen_p > display_p)) - { - *screen_p = '\0'; - } - } - } - else - { - canonical_display_name = g_strdup (display_env); - } - - return canonical_display_name; -} - /** * atspi_init: * @@ -1499,6 +1462,43 @@ _atspi_error_quark (void) * Gets the IOR from the XDisplay. */ #ifdef HAVE_X11 +/* + * Returns a 'canonicalized' value for DISPLAY, + * with the screen number stripped off if present. + * + * TODO: Avoid having duplicate functions for this here and in at-spi2-atk + */ +static gchar * +spi_display_name (void) +{ + char *canonical_display_name = NULL; + const gchar *display_env = g_getenv ("AT_SPI_DISPLAY"); + + if (!display_env) + { + display_env = g_getenv ("DISPLAY"); + if (!display_env || !display_env[0]) + return NULL; + else + { + gchar *display_p, *screen_p; + canonical_display_name = g_strdup (display_env); + display_p = g_utf8_strrchr (canonical_display_name, -1, ':'); + screen_p = g_utf8_strrchr (canonical_display_name, -1, '.'); + if (screen_p && display_p && (screen_p > display_p)) + { + *screen_p = '\0'; + } + } + } + else + { + canonical_display_name = g_strdup (display_env); + } + + return canonical_display_name; +} + static char * get_accessibility_bus_address_x11 (void) { diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index b0ccab67..b695fb68 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -65,7 +65,7 @@ typedef struct { A11yBusState state; /* -1 == error, 0 == pending, > 0 == running */ - int a11y_bus_pid; + GPid a11y_bus_pid; char *socket_name; char *a11y_bus_address; #ifdef HAVE_X11 @@ -250,19 +250,44 @@ name_appeared_handler (GDBusConnection *connection, * Read all data from a file descriptor to a C string buffer. */ static gboolean -unix_read_all_fd_to_string (int fd, - char *buf, - ssize_t max_bytes) +unix_read_all_fd_to_string (int fd, + char *buf, + ssize_t max_bytes, + char **error_msg) { - ssize_t bytes_read; + g_assert (max_bytes > 1); + *error_msg = NULL; - while (max_bytes > 1 && (bytes_read = read (fd, buf, MIN (4096, max_bytes - 1)))) + max_bytes -= 1; /* allow space for nul terminator */ + + while (max_bytes > 1) { - if (bytes_read < 0) - return FALSE; - buf += bytes_read; - max_bytes -= bytes_read; + ssize_t bytes_read; + + again: + bytes_read = read (fd, buf, max_bytes); + + if (bytes_read == 0) + { + break; + } + else if (bytes_read > 0) + { + buf += bytes_read; + max_bytes -= bytes_read; + } + else if (errno == EINTR) + { + goto again; + } + else + { + int err_save = errno; + *error_msg = g_strdup_printf ("Failed to read data from accessibility bus: %s", g_strerror (err_save)); + return FALSE; + } } + *buf = '\0'; return TRUE; } @@ -286,58 +311,67 @@ on_bus_exited (GPid pid, app->a11y_launch_error_message = g_strdup_printf ("Bus stopped by signal %d", WSTOPSIG (status)); } g_main_loop_quit (app->loop); -} +} #ifdef DBUS_DAEMON -static void -setup_bus_child_daemon (gpointer data) +static gboolean +ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) { - A11yBusLauncher *app = data; - (void) app; + char *address_param; - close (app->pipefd[0]); - dup2 (app->pipefd[1], 3); - close (app->pipefd[1]); + if (app->socket_name) + { + address_param = g_strconcat ("--address=unix:path=", app->socket_name, NULL); + } + else + { + address_param = NULL; + } - /* On Linux, tell the bus process to exit if this process goes away */ -#ifdef __linux__ - prctl (PR_SET_PDEATHSIG, 15); -#endif -} + if (pipe (app->pipefd) < 0) + g_error ("Failed to create pipe: %s", strerror (errno)); -static gboolean -ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) -{ - char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", "3", NULL, NULL }; + char *print_address_fd_param = g_strdup_printf ("%d", app->pipefd[1]); + + char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", print_address_fd_param, address_param, NULL }; + gint source_fds[1] = { app->pipefd[1] }; + gint target_fds[1] = { app->pipefd[1] }; + G_STATIC_ASSERT (G_N_ELEMENTS (source_fds) == G_N_ELEMENTS (target_fds)); GPid pid; char addr_buf[2048]; GError *error = NULL; - - if (pipe (app->pipefd) < 0) - g_error ("Failed to create pipe: %s", strerror (errno)); + char *error_from_read; g_clear_pointer (&app->a11y_launch_error_message, g_free); - if (app->socket_name) - argv[5] = g_strconcat ("--address=unix:path=", app->socket_name, NULL); - - if (!g_spawn_async (NULL, - argv, - NULL, - G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, - setup_bus_child_daemon, - app, - &pid, - &error)) + if (!g_spawn_async_with_pipes_and_fds (NULL, + (const gchar * const *) argv, + NULL, + G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, + NULL, /* child_setup */ + app, + -1, /* stdin_fd */ + -1, /* stdout_fd */ + -1, /* stdout_fd */ + source_fds, + target_fds, + G_N_ELEMENTS (source_fds), /* n_fds in source_fds and target_fds */ + &pid, + NULL, /* stdin_pipe_out */ + NULL, /* stdout_pipe_out */ + NULL, /* stderr_pipe_out */ + &error)) { app->a11y_bus_pid = -1; app->a11y_launch_error_message = g_strdup (error->message); g_clear_error (&error); - g_free (argv[5]); + g_free (address_param); + g_free (print_address_fd_param); goto error; } - g_free (argv[5]); + g_free (address_param); + g_free (print_address_fd_param); close (app->pipefd[1]); app->pipefd[1] = -1; @@ -346,10 +380,12 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) app->state = A11Y_BUS_STATE_READING_ADDRESS; app->a11y_bus_pid = pid; g_debug ("Launched a11y bus, child is %ld", (long) pid); - if (!unix_read_all_fd_to_string (app->pipefd[0], addr_buf, sizeof (addr_buf))) + error_from_read = NULL; + if (!unix_read_all_fd_to_string (app->pipefd[0], addr_buf, sizeof (addr_buf), &error_from_read)) { - app->a11y_launch_error_message = g_strdup_printf ("Failed to read address: %s", strerror (errno)); + app->a11y_launch_error_message = error_from_read; kill (app->a11y_bus_pid, SIGTERM); + g_spawn_close_pid (app->a11y_bus_pid); app->a11y_bus_pid = -1; goto error; } @@ -393,9 +429,6 @@ setup_bus_child_broker (gpointer data) pid_str = g_strdup_printf("%u", getpid()); g_setenv("LISTEN_PID", pid_str, TRUE); g_free(pid_str); - - /* Tell the bus process to exit if this process goes away */ - prctl (PR_SET_PDEATHSIG, SIGTERM); } static gboolean @@ -515,7 +548,6 @@ ensure_a11y_bus (A11yBusLauncher *app) if (strlen (app->socket_name) >= 100) { g_free (app->socket_name); - g_free (at_spi_dir); app->socket_name = NULL; } } @@ -851,6 +883,11 @@ get_schema (const gchar *name) { #if GLIB_CHECK_VERSION (2, 32, 0) GSettingsSchemaSource *source = g_settings_schema_source_get_default (); + if (!source) + { + g_error ("Cannot get the default GSettingsSchemaSource - is the gsettings-desktop-schemas package installed?"); + } + GSettingsSchema *schema = g_settings_schema_source_lookup (source, name, FALSE); if (schema == NULL) @@ -891,7 +928,7 @@ main (int argc, gboolean screen_reader_set = FALSE; gint i; - _global_app = g_slice_new0 (A11yBusLauncher); + _global_app = g_new0 (A11yBusLauncher, 1); _global_app->loop = g_main_loop_new (NULL, FALSE); for (i = 1; i < argc; i++) @@ -952,7 +989,11 @@ main (int argc, g_main_loop_run (_global_app->loop); if (_global_app->a11y_bus_pid > 0) - kill (_global_app->a11y_bus_pid, SIGTERM); + { + kill (_global_app->a11y_bus_pid, SIGTERM); + g_spawn_close_pid (_global_app->a11y_bus_pid); + _global_app->a11y_bus_pid = -1; + } /* Clear the X property if our bus is gone; in the case where e.g. * GDM is launching a login on an X server it was using before, diff --git a/dbind/dbtest.c b/dbind/dbtest.c index 085d7ffb..511839c3 100644 --- a/dbind/dbtest.c +++ b/dbind/dbtest.c @@ -40,7 +40,10 @@ void demarshal (DBusMessage *msg, const char *type, void *ptr) DBusMessageIter iter; if (!dbus_message_iter_init (msg, &iter)) + { fprintf (stderr, "no data in msg\n"); + g_assert_not_reached (); + } else dbind_any_demarshal (&iter, &type, &ptr); } diff --git a/meson.build b/meson.build index cfd2e091..fa6ca53e 100644 --- a/meson.build +++ b/meson.build @@ -47,6 +47,7 @@ libdbus_req_version = '>= 1.5' glib_req_version = '>= 2.62.0' gobject_req_version = '>= 2.0.0' gio_req_version = '>= 2.28.0' +gir_req_version = '>= 0.6.7' libdbus_dep = dependency('dbus-1', version: libdbus_req_version) glib_dep = dependency('glib-2.0', version: glib_req_version) @@ -106,7 +107,7 @@ have_gir = false introspection_option = get_option('introspection') if introspection_option != 'no' - gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false) + gir_dep = dependency('gobject-introspection-1.0', version: gir_req_version, required: false) if gir_dep.found() have_gir = true diff --git a/registryd/deviceeventcontroller-x11.c b/registryd/deviceeventcontroller-x11.c index 6060118b..65560480 100644 --- a/registryd/deviceeventcontroller-x11.c +++ b/registryd/deviceeventcontroller-x11.c @@ -383,11 +383,15 @@ spi_dec_x11_mouse_check (SpiDEController *controller, Window root_return, child_return; Display *display = spi_get_display (); - if (display != NULL) - XQueryPointer(display, DefaultRootWindow (display), - &root_return, &child_return, - x, y, - &win_x_return, &win_y_return, &mask_return); + if (display == NULL) + { + return 0; + } + + XQueryPointer(display, DefaultRootWindow (display), + &root_return, &child_return, + x, y, + &win_x_return, &win_y_return, &mask_return); /* * Since many clients grab the pointer, and X goes an automatic * pointer grab on mouse-down, we often must detect mouse button events diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index daf18b29..99fb159a 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -122,7 +122,13 @@ spi_dec_plat_get_keycode (SpiDEController *controller, if (klass->plat.get_keycode) return klass->plat.get_keycode (controller, keysym, key_str, fix, modmask); else - return keysym; + { + if (modmask) + { + *modmask = 0; + } + return keysym; + } } static guint @@ -134,7 +140,13 @@ spi_dec_plat_mouse_check (SpiDEController *controller, if (klass->plat.mouse_check) return klass->plat.mouse_check (controller, x, y, moved); else - return 0; + { + if (moved) + { + *moved = FALSE; + } + return 0; + } } static gboolean @@ -884,8 +896,8 @@ reset_hung_process (DBusPendingCall *pending, void *data) { if (!strcmp (l->data, dest)) { - g_free (l->data); hung_processes = g_slist_remove (hung_processes, l->data); + g_free (l->data); break; } } @@ -909,8 +921,8 @@ reset_hung_process_from_ping (DBusPendingCall *pending, void *data) { if (!strcmp (l->data, data)) { - g_free (l->data); hung_processes = g_slist_remove (hung_processes, l->data); + g_free (l->data); break; } } diff --git a/registryd/registry.c b/registryd/registry.c index bfa3a317..e22fbcbc 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -248,8 +248,8 @@ remove_events (SpiRegistry *registry, const char *bus_name, const char *event) g_strfreev (evdata->data); g_free (evdata->bus_name); g_slist_free_full (evdata->properties, g_free); - g_free (evdata); registry->events = g_list_remove (registry->events, evdata); + g_free (evdata); } else { diff --git a/test/memory.c b/test/memory.c index 2f53dd7f..54f06524 100644 --- a/test/memory.c +++ b/test/memory.c @@ -47,7 +47,7 @@ end (void *data) static gboolean kill_child (void *data) { - kill (child_pid, SIGTERM); + g_assert_no_errno (kill (child_pid, SIGTERM)); return FALSE; } @@ -56,6 +56,7 @@ on_event (AtspiEvent *event, void *data) { if (atspi_accessible_get_role (event->source, NULL) == ATSPI_ROLE_DESKTOP_FRAME) { + printf ("memory: event: %s\n", event->type); if (strstr (event->type, "add")) { AtspiAccessible *desktop = atspi_get_desktop (0); @@ -83,8 +84,16 @@ main() listener = atspi_event_listener_new (on_event, NULL, NULL); atspi_event_listener_register (listener, "object:children-changed", NULL); child_pid = fork (); - if (!child_pid) - execlp ("test/test-application", "test/test-application", NULL); + if (child_pid == 0) + { + g_assert_no_errno (execlp ("test/test-application", "test/test-application", NULL)); + } + else if (child_pid == -1) + { + const char *error = g_strerror (errno); + g_error ("could not fork test-application child: %s", error); + } + printf ("memory: child pid: %d\n", (int) child_pid); atspi_event_main (); return 0; } |