Skip to content

Commit

Permalink
fix / ignore some more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ardera committed Sep 16, 2024
1 parent 3403816 commit 2a36dde
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .codechecker.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"clang-diagnostic-sign-compare",
"-d",
"clang-diagnostic-implicit-int-float-conversion",
"-d",
"clang-diagnostic-switch-enum",
"--analyzers",
"clangsa",
"clang-tidy",
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ target_link_libraries(flutterpi_module PUBLIC
target_include_directories(flutterpi_module PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/third_party/mesa3d/include
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
)

Expand Down
2 changes: 1 addition & 1 deletion src/compositor_ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <semaphore.h>

#include <flutter_embedder.h>
#include <mesa3d/dynarray.h>
#include <systemd/sd-event.h>

#include "cursor.h"
Expand All @@ -33,7 +34,6 @@
#include "surface.h"
#include "tracer.h"
#include "util/collection.h"
#include "util/dynarray.h"
#include "util/logging.h"
#include "util/refcounting.h"
#include "window.h"
Expand Down
7 changes: 5 additions & 2 deletions src/egl_gbm_render_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ static int egl_gbm_render_surface_init(
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT
);
if (gbm_surface == NULL) {
ok = errno ? errno : EIO;
ok = errno;

if (allowed_modifiers != NULL) {
LOG_ERROR(
"Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s, gbm_surface_create: %s\n",
Expand All @@ -182,7 +183,9 @@ static int egl_gbm_render_surface_init(
LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok));
}

return ok;
// Return an error != 0 in any case, so the caller doesn't think
// that the surface was created successfully.
return ok ? ok : EIO;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/flutter-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ static int on_execute_flutter_task(void *userdata) {

result = flutterpi->flutter.procs.RunTask(flutterpi->flutter.engine, task);
if (result != kSuccess) {
LOG_ERROR("Error running platform task. FlutterEngineRunTask: %d\n", result);
LOG_ERROR("Error running platform task. FlutterEngineRunTask: %u\n", result);
free(task);
return EINVAL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modesetting.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ struct kms_req_builder *drmdev_create_request_builder(struct drmdev *drmdev, uin
}

if (crtc == NULL) {
LOG_ERROR("Invalid CRTC id: %" PRId32 "\n", crtc_id);
LOG_ERROR("Invalid CRTC id: %" PRIu32 "\n", crtc_id);
goto fail_unlock;
}

Expand Down
5 changes: 2 additions & 3 deletions src/platformchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,8 @@ int platch_decode_json(char *string, struct json_value *out) {
int platch_decode(const uint8_t *buffer, size_t size, enum platch_codec codec, struct platch_obj *object_out) {
int ok;

if ((size == 0) && (buffer == NULL)) {
object_out->codec = kNotImplemented;
return 0;
if (codec != kNotImplemented && ((size == 0) || (buffer == NULL))) {
return EINVAL;
}

const uint8_t *buffer_cursor = buffer;
Expand Down
17 changes: 10 additions & 7 deletions src/pluginregistry.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,17 @@ int plugin_registry_set_receiver(const char *channel, enum platch_codec codec, p
int plugin_registry_remove_receiver_v2_locked(struct plugin_registry *registry, const char *channel) {
struct platch_obj_cb_data *data;

data = get_cb_data_by_channel_locked(registry, channel);
if (data == NULL) {
return EINVAL;
}
// clang analyzer reports false-positives for using deallocated memory here.
ANALYZER_SUPPRESS({
data = get_cb_data_by_channel_locked(registry, channel);
if (data == NULL) {
return EINVAL;
}

list_del(&data->entry);
free(data->channel);
free(data);
list_del(&data->entry);
free(data->channel);
free(data);
});

return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions src/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
#if __has_attribute(noreturn)
#define HAVE_FUNC_ATTRIBUTE_NORETURN
#endif
#if __has_attribute(suppress)
#define HAVE_STMT_ATTRIBUTE_SUPPRESS
#endif

/**
* __builtin_expect macros
Expand Down Expand Up @@ -405,6 +408,12 @@
#define ATTR_NOINLINE
#endif

#if HAVE_STMT_ATTRIBUTE_SUPPRESS
#define ANALYZER_SUPPRESS(stmt) __attribute__((suppress)) stmt
#else
#define ANALYZER_SUPPRESS(stmt) stmt
#endif

/**
* Check that STRUCT::FIELD can hold MAXVAL. We use a lot of bitfields
* in Mesa/gallium. We have to be sure they're of sufficient size to
Expand Down
2 changes: 1 addition & 1 deletion src/vk_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static VkBool32 on_debug_utils_message(
UNUSED void *userdata
) {
LOG_DEBUG(
"[%s] (%d, %s) %s (queues: %d, cmdbufs: %d, objects: %d)\n",
"[%s] (%d, %s) %s (queues: %u, cmdbufs: %u, objects: %u)\n",
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT ? "VERBOSE" :
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT ? "INFO" :
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT ? "WARNING" :
Expand Down
14 changes: 9 additions & 5 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,11 +1429,15 @@ static struct render_surface *kms_window_get_render_surface_internal(struct wind
drm_plane_for_each_modified_format(plane, count_modifiers_for_pixel_format, &context);

n_allowed_modifiers = context.n_modifiers;
allowed_modifiers = calloc(n_allowed_modifiers, sizeof(*context.modifiers));
context.modifiers = allowed_modifiers;
if (n_allowed_modifiers) {
allowed_modifiers = calloc(n_allowed_modifiers, sizeof(*context.modifiers));
context.modifiers = allowed_modifiers;

// Next, fill context.modifiers with the allowed modifiers.
drm_plane_for_each_modified_format(plane, extract_modifiers_for_pixel_format, &context);
// Next, fill context.modifiers with the allowed modifiers.
drm_plane_for_each_modified_format(plane, extract_modifiers_for_pixel_format, &context);
} else {
allowed_modifiers = NULL;
}
break;
}
}
Expand Down Expand Up @@ -1754,7 +1758,7 @@ static EGLSurface dummy_window_get_egl_surface(struct window *window) {
if (render_surface == NULL) {
return EGL_NO_SURFACE;
}

return egl_gbm_render_surface_get_egl_surface(CAST_EGL_GBM_RENDER_SURFACE(render_surface));
} else {
return EGL_NO_SURFACE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <stdlib.h>
#include <string.h>

#include "macros.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

0 comments on commit 2a36dde

Please sign in to comment.