From bd39d6b8abf236b38392096e9637054d87d78093 Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis <ludovico.denittis@collabora.com> Date: Thu, 10 Jun 2021 12:52:33 +0200 Subject: [PATCH] pressure-vessel: Address several clang warnings This commit addresses most of the warnings printed at compilation time while using clang and `ninja scan-build`. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com> --- pressure-vessel/launch.c | 6 +++--- pressure-vessel/runtime.c | 17 +++++++++-------- pressure-vessel/wrap-flatpak.c | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pressure-vessel/launch.c b/pressure-vessel/launch.c index 7a4f72b72..4e038cf46 100644 --- a/pressure-vessel/launch.c +++ b/pressure-vessel/launch.c @@ -200,7 +200,7 @@ process_exited_cb (G_GNUC_UNUSED GDBusConnection *connection, static void forward_signal (int sig) { - g_autoptr(GVariant) reply = NULL; + G_GNUC_UNUSED g_autoptr(GVariant) reply = NULL; gboolean to_process_group = FALSE; g_autoptr(GError) error = NULL; @@ -537,7 +537,6 @@ path_to_handle (GUnixFDList *fd_list, { close (path_fd); path_fd = var_fd; - var_fd = -1; } else { @@ -743,7 +742,7 @@ main (int argc, g_auto(GVariantBuilder) env_builder = {}; g_auto(GVariantBuilder) options_builder = {}; g_autoptr(AutoUnixFDList) fd_list = NULL; - g_autoptr(GVariant) reply = NULL; + G_GNUC_UNUSED g_autoptr(GVariant) reply = NULL; gint stdin_handle = -1; gint stdout_handle = -1; gint stderr_handle = -1; @@ -883,6 +882,7 @@ main (int argc, launch_exit_status = LAUNCH_EX_FAILED; loop = g_main_loop_new (NULL, FALSE); + g_assert (api != NULL); if (api->service_bus_name != NULL) { if (opt_dbus_address != NULL || opt_socket != NULL) diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index c29491847..9e140bba0 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -639,7 +639,7 @@ pv_runtime_garbage_collect_legacy (const char *variable_dir, g_autoptr(GError) local_error = NULL; g_autoptr(PvBwrapLock) variable_lock = NULL; g_autoptr(PvBwrapLock) base_lock = NULL; - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; g_auto(GLnxDirFdIterator) variable_dir_iter = { FALSE }; g_auto(GLnxDirFdIterator) runtime_base_iter = { FALSE }; glnx_autofd int variable_dir_fd = -1; @@ -763,7 +763,7 @@ pv_runtime_garbage_collect (PvRuntime *self, GError **error) { g_auto(GLnxDirFdIterator) iter = { FALSE }; - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; g_return_val_if_fail (PV_IS_RUNTIME (self), FALSE); g_return_val_if_fail (self->variable_dir != NULL, FALSE); @@ -866,8 +866,8 @@ pv_runtime_create_copy (PvRuntime *self, g_autofree gchar *temp_dir = NULL; g_autoptr(GDir) dir = NULL; g_autoptr(PvBwrapLock) copy_lock = NULL; - g_autoptr(PvBwrapLock) source_lock = NULL; - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(PvBwrapLock) source_lock = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; const char *member; glnx_autofd int temp_dir_fd = -1; gboolean is_just_usr; @@ -1076,7 +1076,7 @@ pv_runtime_unpack (PvRuntime *self, GError **error) { g_autoptr(GString) debug_tarball = NULL; - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; g_autofree gchar *deploy_basename = NULL; g_autofree gchar *unpack_dir = NULL; @@ -3026,7 +3026,7 @@ pv_runtime_remove_overridden_libraries (PvRuntime *self, GError **error) { g_autoptr(GPtrArray) dirs = NULL; - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; GHashTable **delete = NULL; GLnxDirFdIterator *iters = NULL; gboolean ret = FALSE; @@ -3655,6 +3655,7 @@ collect_vulkan_layers (PvRuntime *self, _srt_profiling_start ("Collecting Vulkan %s layers", dir_name); g_return_val_if_fail (self->provider != NULL, FALSE); + g_return_val_if_fail (layer_details != NULL, FALSE); g_return_val_if_fail (dependency_patterns != NULL, FALSE); g_return_val_if_fail (dir_name != NULL, FALSE); @@ -3760,7 +3761,7 @@ pv_runtime_get_ld_so (PvRuntime *self, { if (self->mutable_sysroot != NULL) { - glnx_autofd int fd = -1; + G_GNUC_UNUSED glnx_autofd int fd = -1; fd = _srt_resolve_in_sysroot (self->mutable_sysroot_fd, arch->ld_so, @@ -4733,7 +4734,7 @@ pv_runtime_use_provider_graphics_stack (PvRuntime *self, g_autoptr(GPtrArray) vulkan_icd_details = NULL; /* (element-type IcdDetails) */ g_autoptr(GPtrArray) vulkan_exp_layer_details = NULL; /* (element-type IcdDetails) */ g_autoptr(GPtrArray) vulkan_imp_layer_details = NULL; /* (element-type IcdDetails) */ - g_autoptr(SrtProfilingTimer) timer = NULL; + G_GNUC_UNUSED g_autoptr(SrtProfilingTimer) timer = NULL; g_autoptr(SrtProfilingTimer) part_timer = NULL; guint n_egl_icds; guint n_vulkan_icds; diff --git a/pressure-vessel/wrap-flatpak.c b/pressure-vessel/wrap-flatpak.c index d19bcb01e..9a8674472 100644 --- a/pressure-vessel/wrap-flatpak.c +++ b/pressure-vessel/wrap-flatpak.c @@ -95,7 +95,8 @@ pv_wrap_check_flatpak (const char *tools_dir, { g_auto(GStrv) devices = NULL; g_auto(GStrv) features = NULL; - g_auto(GStrv) filesystems = NULL; + /* This might be used for an additional check in the future */ + G_GNUC_UNUSED g_auto(GStrv) filesystems = NULL; g_warning ("Using experimental Flatpak sub-sandboxing " "(requires Flatpak 1.11.x commit 1.10.1-80-gcb47d83b " -- GitLab