Skip to content

Commit 2a36dde

Browse files
committed
fix / ignore some more warnings
1 parent 3403816 commit 2a36dde

File tree

12 files changed

+42
-23
lines changed

12 files changed

+42
-23
lines changed

.codechecker.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"clang-diagnostic-sign-compare",
1111
"-d",
1212
"clang-diagnostic-implicit-int-float-conversion",
13+
"-d",
14+
"clang-diagnostic-switch-enum",
1315
"--analyzers",
1416
"clangsa",
1517
"clang-tidy",

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ target_link_libraries(flutterpi_module PUBLIC
164164
target_include_directories(flutterpi_module PUBLIC
165165
${CMAKE_SOURCE_DIR}/src
166166
${CMAKE_BINARY_DIR}
167+
${CMAKE_SOURCE_DIR}/third_party/mesa3d/include
167168
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
168169
)
169170

src/compositor_ng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <semaphore.h>
2121

2222
#include <flutter_embedder.h>
23+
#include <mesa3d/dynarray.h>
2324
#include <systemd/sd-event.h>
2425

2526
#include "cursor.h"
@@ -33,7 +34,6 @@
3334
#include "surface.h"
3435
#include "tracer.h"
3536
#include "util/collection.h"
36-
#include "util/dynarray.h"
3737
#include "util/logging.h"
3838
#include "util/refcounting.h"
3939
#include "window.h"

src/egl_gbm_render_surface.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ static int egl_gbm_render_surface_init(
171171
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT
172172
);
173173
if (gbm_surface == NULL) {
174-
ok = errno ? errno : EIO;
174+
ok = errno;
175+
175176
if (allowed_modifiers != NULL) {
176177
LOG_ERROR(
177178
"Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s, gbm_surface_create: %s\n",
@@ -182,7 +183,9 @@ static int egl_gbm_render_surface_init(
182183
LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok));
183184
}
184185

185-
return ok;
186+
// Return an error != 0 in any case, so the caller doesn't think
187+
// that the surface was created successfully.
188+
return ok ? ok : EIO;
186189
}
187190
}
188191

src/flutter-pi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static int on_execute_flutter_task(void *userdata) {
770770

771771
result = flutterpi->flutter.procs.RunTask(flutterpi->flutter.engine, task);
772772
if (result != kSuccess) {
773-
LOG_ERROR("Error running platform task. FlutterEngineRunTask: %d\n", result);
773+
LOG_ERROR("Error running platform task. FlutterEngineRunTask: %u\n", result);
774774
free(task);
775775
return EINVAL;
776776
}

src/modesetting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ struct kms_req_builder *drmdev_create_request_builder(struct drmdev *drmdev, uin
22682268
}
22692269

22702270
if (crtc == NULL) {
2271-
LOG_ERROR("Invalid CRTC id: %" PRId32 "\n", crtc_id);
2271+
LOG_ERROR("Invalid CRTC id: %" PRIu32 "\n", crtc_id);
22722272
goto fail_unlock;
22732273
}
22742274

src/platformchannel.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,9 +959,8 @@ int platch_decode_json(char *string, struct json_value *out) {
959959
int platch_decode(const uint8_t *buffer, size_t size, enum platch_codec codec, struct platch_obj *object_out) {
960960
int ok;
961961

962-
if ((size == 0) && (buffer == NULL)) {
963-
object_out->codec = kNotImplemented;
964-
return 0;
962+
if (codec != kNotImplemented && ((size == 0) || (buffer == NULL))) {
963+
return EINVAL;
965964
}
966965

967966
const uint8_t *buffer_cursor = buffer;

src/pluginregistry.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,17 @@ int plugin_registry_set_receiver(const char *channel, enum platch_codec codec, p
392392
int plugin_registry_remove_receiver_v2_locked(struct plugin_registry *registry, const char *channel) {
393393
struct platch_obj_cb_data *data;
394394

395-
data = get_cb_data_by_channel_locked(registry, channel);
396-
if (data == NULL) {
397-
return EINVAL;
398-
}
395+
// clang analyzer reports false-positives for using deallocated memory here.
396+
ANALYZER_SUPPRESS({
397+
data = get_cb_data_by_channel_locked(registry, channel);
398+
if (data == NULL) {
399+
return EINVAL;
400+
}
399401

400-
list_del(&data->entry);
401-
free(data->channel);
402-
free(data);
402+
list_del(&data->entry);
403+
free(data->channel);
404+
free(data);
405+
});
403406

404407
return 0;
405408
}

src/util/macros.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
#if __has_attribute(noreturn)
123123
#define HAVE_FUNC_ATTRIBUTE_NORETURN
124124
#endif
125+
#if __has_attribute(suppress)
126+
#define HAVE_STMT_ATTRIBUTE_SUPPRESS
127+
#endif
125128

126129
/**
127130
* __builtin_expect macros
@@ -405,6 +408,12 @@
405408
#define ATTR_NOINLINE
406409
#endif
407410

411+
#if HAVE_STMT_ATTRIBUTE_SUPPRESS
412+
#define ANALYZER_SUPPRESS(stmt) __attribute__((suppress)) stmt
413+
#else
414+
#define ANALYZER_SUPPRESS(stmt) stmt
415+
#endif
416+
408417
/**
409418
* Check that STRUCT::FIELD can hold MAXVAL. We use a lot of bitfields
410419
* in Mesa/gallium. We have to be sure they're of sufficient size to

src/vk_renderer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static VkBool32 on_debug_utils_message(
5252
UNUSED void *userdata
5353
) {
5454
LOG_DEBUG(
55-
"[%s] (%d, %s) %s (queues: %d, cmdbufs: %d, objects: %d)\n",
55+
"[%s] (%d, %s) %s (queues: %u, cmdbufs: %u, objects: %u)\n",
5656
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT ? "VERBOSE" :
5757
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT ? "INFO" :
5858
severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT ? "WARNING" :

0 commit comments

Comments
 (0)