Turn on -Wdeclaration-after-statement

Enforces code style.
This commit is contained in:
Simon Ser 2023-02-16 20:03:42 +01:00
parent fb8ede8f89
commit 99ed53677a
6 changed files with 22 additions and 16 deletions

View file

@ -673,10 +673,10 @@ update_layers_priority(struct liftoff_device *device)
{
struct liftoff_output *output;
struct liftoff_layer *layer;
bool period_elapsed;
device->page_flip_counter++;
bool period_elapsed =
device->page_flip_counter >= LIFTOFF_PRIORITY_PERIOD;
period_elapsed = device->page_flip_counter >= LIFTOFF_PRIORITY_PERIOD;
if (period_elapsed) {
device->page_flip_counter = 0;
}

View file

@ -87,10 +87,14 @@ dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, uint32_t width,
{
int ret;
uint32_t fb_id;
struct drm_mode_create_dumb create;
uint32_t handles[4] = {0};
uint32_t strides[4] = {0};
uint32_t offsets[4] = { 0 };
assert(format == DRM_FORMAT_ARGB8888 || format == DRM_FORMAT_XRGB8888);
struct drm_mode_create_dumb create = {
create = (struct drm_mode_create_dumb) {
.width = width,
.height = height,
.bpp = 32,
@ -101,9 +105,8 @@ dumb_fb_init(struct dumb_fb *fb, int drm_fd, uint32_t format, uint32_t width,
return false;
}
uint32_t handles[4] = { create.handle };
uint32_t strides[4] = { create.pitch };
uint32_t offsets[4] = { 0 };
handles[0] = create.handle;
strides[0] = create.pitch;
ret = drmModeAddFB2(drm_fd, width, height, format, handles, strides,
offsets, &fb_id, 0);
if (ret < 0) {

3
log.c
View file

@ -38,11 +38,12 @@ log_has(enum liftoff_log_priority priority)
void
liftoff_log(enum liftoff_log_priority priority, const char *fmt, ...)
{
va_list args;
if (!log_has(priority)) {
return;
}
va_list args;
va_start(args, fmt);
log_handler(priority, fmt, args);
va_end(args);

View file

@ -17,6 +17,7 @@ add_project_arguments(cc.get_supported_arguments([
'-Wundef',
'-Wmissing-prototypes',
'-Walloca',
'-Wdeclaration-after-statement',
'-Wno-missing-braces',
'-Wno-unused-parameter',

View file

@ -47,6 +47,7 @@ main(int argc, char *argv[])
struct liftoff_layer *layers[MAX_LAYERS];
drmModeAtomicReq *req;
int ret;
double dur_ms;
planes_len = 5;
layers_len = 10;
@ -108,8 +109,8 @@ main(int argc, char *argv[])
clock_gettime(CLOCK_MONOTONIC, &end);
double dur_ms = ((double)end.tv_sec - (double)start.tv_sec) * 1000 +
((double)end.tv_nsec - (double)start.tv_nsec) / 1000000;
dur_ms = ((double)end.tv_sec - (double)start.tv_sec) * 1000 +
((double)end.tv_nsec - (double)start.tv_nsec) / 1000000;
printf("Plane allocation took %fms\n", dur_ms);
printf("Plane allocation performed %zu atomic test commits\n",
liftoff_mock_commit_count);

View file

@ -50,14 +50,15 @@ test_prop_default(const char *prop_name)
struct liftoff_device *device;
struct liftoff_output *output;
struct liftoff_layer *layer;
uint64_t require_prop_value, default_value;
drmModePropertyRes prop = {0};
mock_plane_without_prop = liftoff_mock_drm_create_plane(DRM_PLANE_TYPE_OVERLAY);
mock_plane_with_prop = liftoff_mock_drm_create_plane(DRM_PLANE_TYPE_OVERLAY);
/* Value that requires the prop for the plane allocation to succeed */
uint64_t require_prop_value;
/* Value that doesn't require the prop to be present */
uint64_t default_value;
/* require_prop_value is a value that requires the prop for the plane
* allocation to succeed. default_value is a value that requires the
* prop for the plane allocation to succeed. */
if (strcmp(prop_name, "alpha") == 0) {
require_prop_value = (uint16_t)(0.5 * 0xFFFF);
default_value = 0xFFFF; /* opaque */
@ -71,7 +72,6 @@ test_prop_default(const char *prop_name)
/* We need to setup mock plane properties before creating the liftoff
* device */
drmModePropertyRes prop = {0};
strncpy(prop.name, prop_name, sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(mock_plane_with_prop, &prop, 0);
@ -473,7 +473,7 @@ test_bitmask(void)
int
main(int argc, char *argv[])
{
const char *test_name;
const char *test_name, *default_test_prefix;
liftoff_log_set_priority(LIFTOFF_DEBUG);
@ -483,7 +483,7 @@ main(int argc, char *argv[])
}
test_name = argv[1];
const char default_test_prefix[] = "default-";
default_test_prefix = "default-";
if (strncmp(test_name, default_test_prefix,
strlen(default_test_prefix)) == 0) {
return test_prop_default(test_name + strlen(default_test_prefix));