Skip to content

Commit 8cd0bad

Browse files
committed
fix: lots of CodeChecker warnings
Mostly double-float casts, functions without arguments without an explicit `void` in the parameter list, but in platformchannel.c there were actually some memory leaks on error paths, which are now fixed. Also enable -pedantic for even more diagnostics.
1 parent 5e5cc51 commit 8cd0bad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1251
-685
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,14 @@ target_link_libraries(flutterpi_module PUBLIC
162162
)
163163

164164
target_include_directories(flutterpi_module PUBLIC
165-
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
166165
${CMAKE_SOURCE_DIR}/src
167166
${CMAKE_BINARY_DIR}
167+
${CMAKE_SOURCE_DIR}/third_party/mesa3d/include
168+
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
168169
)
169170

170171
target_compile_options(flutterpi_module PUBLIC
171-
$<$<CONFIG:Debug>:-O0 -Wall -Wextra -Wno-sign-compare -Werror -ggdb -U_FORTIFY_SOURCE -DDEBUG>
172+
$<$<CONFIG:Debug>:-O0 -Wall -Wextra -Wno-sign-compare -Wswitch-enum -Wformat -Wdouble-promotion -Wno-overlength-strings -Wno-gnu-zero-variadic-macro-arguments -pedantic -Werror -ggdb -U_FORTIFY_SOURCE -DDEBUG>
172173
$<$<CONFIG:RelWithDebInfo>:-O3 -Wall -Wextra -Wno-sign-compare -ggdb -DNDEBUG>
173174
$<$<CONFIG:Release>:-O3 -Wall -Wextra -Wno-sign-compare -DNDEBUG>
174175
)
@@ -237,6 +238,7 @@ if (ENABLE_VULKAN)
237238
target_sources(flutterpi_module PRIVATE
238239
src/vk_gbm_render_surface.c
239240
src/vk_renderer.c
241+
src/vulkan.c
240242
)
241243
target_link_libraries(flutterpi_module PUBLIC
242244
PkgConfig::VULKAN

CMakePresets.json

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,58 @@
77
"description": "Sets Ninja generator, build and install directory",
88
"generator": "Ninja",
99
"binaryDir": "${sourceDir}/out/build/${presetName}",
10+
"hidden": true,
1011
"cacheVariables": {
1112
"CMAKE_BUILD_TYPE": "Debug",
1213
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
14+
"TRY_ENABLE_OPENGL": false,
1315
"ENABLE_OPENGL": true,
16+
"TRY_ENABLE_VULKAN": false,
17+
"ENABLE_VULKAN": true,
18+
"BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN": true,
19+
"TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN": false,
1420
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
21+
"TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": false,
1522
"BUILD_SENTRY_PLUGIN": true,
1623
"ENABLE_TESTS": true
1724
}
1825
},
26+
{
27+
"name": "default-clang",
28+
"displayName": "Default OpenGL host build (clang)",
29+
"description": "Sets Ninja generator, build and install directory",
30+
"generator": "Ninja",
31+
"binaryDir": "${sourceDir}/out/build/${presetName}",
32+
"inherits": "default",
33+
"cacheVariables": {
34+
"CMAKE_C_COMPILER": "clang",
35+
"CMAKE_CXX_COMPILER": "clang++"
36+
}
37+
},
38+
{
39+
"name": "default-clang-20",
40+
"displayName": "Default OpenGL host build (clang-20)",
41+
"description": "Sets Ninja generator, build and install directory",
42+
"generator": "Ninja",
43+
"binaryDir": "${sourceDir}/out/build/${presetName}",
44+
"inherits": "default",
45+
"cacheVariables": {
46+
"CMAKE_C_COMPILER": "clang-20",
47+
"CMAKE_CXX_COMPILER": "clang++-20"
48+
}
49+
},
50+
{
51+
"name": "default-gcc",
52+
"displayName": "Default OpenGL host build (gcc)",
53+
"description": "Sets Ninja generator, build and install directory",
54+
"generator": "Ninja",
55+
"binaryDir": "${sourceDir}/out/build/${presetName}",
56+
"inherits": "default",
57+
"cacheVariables": {
58+
"CMAKE_C_COMPILER": "gcc",
59+
"CMAKE_CXX_COMPILER": "g++"
60+
}
61+
},
1962
{
2063
"name": "cross-aarch64-default",
2164
"displayName": "OpenGL AArch64 cross-build",
@@ -41,4 +84,4 @@
4184
}
4285
}
4386
]
44-
}
87+
}

src/compositor_ng.c

Lines changed: 11 additions & 14 deletions
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"
@@ -231,7 +231,7 @@ static void fill_platform_view_layer_props(
231231
size_t n_mutations,
232232
const struct mat3f *display_to_view_transform,
233233
const struct mat3f *view_to_display_transform,
234-
double device_pixel_ratio
234+
float device_pixel_ratio
235235
) {
236236
(void) view_to_display_transform;
237237

@@ -262,8 +262,8 @@ static void fill_platform_view_layer_props(
262262
* ```
263263
*/
264264

265-
rect.size.x /= device_pixel_ratio;
266-
rect.size.y /= device_pixel_ratio;
265+
rect.size.x /= (double) device_pixel_ratio;
266+
rect.size.y /= (double) device_pixel_ratio;
267267

268268
// okay, now we have the params.finalBoundingRect().x() in aa_back_transformed.x and
269269
// params.finalBoundingRect().y() in aa_back_transformed.y.
@@ -348,8 +348,9 @@ static int compositor_push_fl_layers(struct compositor *compositor, size_t n_fl_
348348
/// TODO: Implement
349349
layer->surface = compositor_get_view_by_id_locked(compositor, fl_layer->platform_view->identifier);
350350
if (layer->surface == NULL) {
351-
layer->surface =
352-
CAST_SURFACE(dummy_render_surface_new(compositor->tracer, VEC2I(fl_layer->size.width, fl_layer->size.height)));
351+
layer->surface = CAST_SURFACE(
352+
dummy_render_surface_new(compositor->tracer, VEC2I((int) fl_layer->size.width, (int) fl_layer->size.height))
353+
);
353354
}
354355
#else
355356
// in release mode, we just assume the id is valid.
@@ -384,10 +385,6 @@ static int compositor_push_fl_layers(struct compositor *compositor, size_t n_fl_
384385

385386
fl_layer_composition_unref(composition);
386387

387-
return 0;
388-
389-
//fail_free_composition:
390-
//fl_layer_composition_unref(composition);
391388
return ok;
392389
}
393390

@@ -556,14 +553,14 @@ void compositor_set_cursor(
556553

557554
struct view_geometry viewgeo = window_get_view_geometry(compositor->main_window);
558555

559-
if (compositor->cursor_pos.x < 0.0f) {
560-
compositor->cursor_pos.x = 0.0f;
556+
if (compositor->cursor_pos.x < 0.0) {
557+
compositor->cursor_pos.x = 0.0;
561558
} else if (compositor->cursor_pos.x > viewgeo.view_size.x) {
562559
compositor->cursor_pos.x = viewgeo.view_size.x;
563560
}
564561

565-
if (compositor->cursor_pos.y < 0.0f) {
566-
compositor->cursor_pos.y = 0.0f;
562+
if (compositor->cursor_pos.y < 0.0) {
563+
compositor->cursor_pos.y = 0.0;
567564
} else if (compositor->cursor_pos.y > viewgeo.view_size.y) {
568565
compositor->cursor_pos.y = viewgeo.view_size.y;
569566
}

src/cursor.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include "util/collection.h"
88
#include "util/geometry.h"
99

10-
#define PIXEL_RATIO_LDPI 1.25
11-
#define PIXEL_RATIO_MDPI 1.6666
12-
#define PIXEL_RATIO_HDPI 2.5
13-
#define PIXEL_RATIO_XHDPI 3.3333
14-
#define PIXEL_RATIO_XXHDPI 5
15-
#define PIXEL_RATIO_XXXHDPI 6.6666
10+
#define PIXEL_RATIO_LDPI 1.25f
11+
#define PIXEL_RATIO_MDPI 1.6666f
12+
#define PIXEL_RATIO_HDPI 2.5f
13+
#define PIXEL_RATIO_XHDPI 3.3333f
14+
#define PIXEL_RATIO_XXHDPI 5.0f
15+
#define PIXEL_RATIO_XXXHDPI 6.6666f
1616

1717
struct pointer_icon {
1818
enum pointer_kind kind;
@@ -1450,7 +1450,7 @@ static void run_length_decode(void *image_buf, const void *rle_data, size_t size
14501450
}
14511451
}
14521452

1453-
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, double pixel_ratio) {
1453+
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, float pixel_ratio) {
14541454
const struct pointer_icon *best;
14551455

14561456
best = NULL;
@@ -1461,7 +1461,7 @@ const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, doub
14611461
if (best == NULL) {
14621462
best = icon;
14631463
continue;
1464-
} else if (fabs(pixel_ratio - icon->pixel_ratio) < fabs(pixel_ratio - best->pixel_ratio)) {
1464+
} else if (fabsf(pixel_ratio - icon->pixel_ratio) < fabsf(pixel_ratio - best->pixel_ratio)) {
14651465
best = icon;
14661466
continue;
14671467
}

src/cursor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum pointer_kind {
5656

5757
struct pointer_icon;
5858

59-
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, double pixel_ratio);
59+
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, float pixel_ratio);
6060

6161
enum pointer_kind pointer_icon_get_kind(const struct pointer_icon *icon);
6262

src/dmabuf_surface.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void refcounted_dmabuf_destroy(struct refcounted_dmabuf *dmabuf) {
6868
free(dmabuf);
6969
}
7070

71-
DEFINE_STATIC_REF_OPS(refcounted_dmabuf, n_refs);
71+
DEFINE_STATIC_REF_OPS(refcounted_dmabuf, n_refs)
7272

7373
struct dmabuf_surface {
7474
struct surface surface;
@@ -298,10 +298,10 @@ static int dmabuf_surface_present_kms(struct surface *_s, const struct fl_layer_
298298
.src_w = DOUBLE_TO_FP1616_ROUNDED(s->next_buf->buf.width),
299299
.src_h = DOUBLE_TO_FP1616_ROUNDED(s->next_buf->buf.height),
300300

301-
.dst_x = props->aa_rect.offset.x,
302-
.dst_y = props->aa_rect.offset.y,
303-
.dst_w = props->aa_rect.size.x,
304-
.dst_h = props->aa_rect.size.y,
301+
.dst_x = (int) round(props->aa_rect.offset.x),
302+
.dst_y = (int) round(props->aa_rect.offset.y),
303+
.dst_w = (int) round(props->aa_rect.size.x),
304+
.dst_h = (int) round(props->aa_rect.size.y),
305305

306306
.has_rotation = false,
307307
.rotation = PLANE_TRANSFORM_ROTATE_0,

src/egl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ static inline const char *egl_strerror(EGLenum result) {
475475
}
476476
}
477477

478-
#define LOG_EGL_ERROR(result, fmt, ...) LOG_ERROR(fmt ": %s\n", __VA_ARGS__ egl_strerror(result))
478+
#define LOG_EGL_ERROR_FMT(result, fmt, ...) LOG_ERROR(fmt ": %s\n", __VA_ARGS__ egl_strerror(result))
479+
#define LOG_EGL_ERROR(result, fmt) LOG_ERROR(fmt ": %s\n", egl_strerror(result))
479480
#endif
480481

481482
#endif // _FLUTTERPI_SRC_EGL_H

0 commit comments

Comments
 (0)