[PATCH v3 1/4] modetest: Fix warnings
Enable all standard automake warnings except for -Wpointer-arith (as the test pattern generation code uses void pointer arithmetics) and fix them. Signed-off-by: Laurent Pinchart --- tests/modetest/Makefile.am | 4 +++- tests/modetest/buffers.c | 13 +++-- tests/modetest/buffers.h | 5 +++-- tests/modetest/modetest.c | 44 ++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am index 065ae13..9376767 100644 --- a/tests/modetest/Makefile.am +++ b/tests/modetest/Makefile.am @@ -1,4 +1,6 @@ -AM_CFLAGS = \ +AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS)) + +AM_CFLAGS += \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/libkms/ \ -I$(top_srcdir) diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 5086381..3c93994 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -882,8 +882,8 @@ fill_pattern(unsigned int format, enum fill_pattern pattern, void *planes[3], */ static struct kms_bo * -allocate_buffer(struct kms_driver *kms, - int width, int height, int *stride) +allocate_buffer(struct kms_driver *kms, unsigned int width, unsigned int height, + unsigned int *stride) { struct kms_bo *bo; unsigned bo_attribs[] = { @@ -917,13 +917,14 @@ allocate_buffer(struct kms_driver *kms, struct kms_bo * create_test_buffer(struct kms_driver *kms, unsigned int format, - int width, int height, int handles[4], - int pitches[4], int offsets[4], enum fill_pattern pattern) + unsigned int width, unsigned int height, + unsigned int handles[4], unsigned int pitches[4], + unsigned int offsets[4], enum fill_pattern pattern) { struct kms_bo *bo; - int ret, stride; - void *planes[3]; + void *planes[3] = { 0, }; void *virtual; + int ret; bo = allocate_buffer(kms, width, height, [0]); if (!bo) diff --git a/tests/modetest/buffers.h b/tests/modetest/buffers.h index 2b15ce5..e320389 100644 --- a/tests/modetest/buffers.h +++ b/tests/modetest/buffers.h @@ -37,8 +37,9 @@ enum fill_pattern { }; struct kms_bo *create_test_buffer(struct kms_driver *kms, unsigned int format, - int width, int height, int handles[4], int pitches[4], - int offsets[4], enum fill_pattern pattern); + unsigned int width, unsigned int height, + unsigned int handles[4], unsigned int pitches[4], + unsigned int offsets[4], enum fill_pattern pattern); unsigned int format_fourcc(const char *name); diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index c91bb9d..1081c78 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -64,11 +64,11 @@ int fd, modes; struct type_name { int type; - char *name; + const char *name; }; #define type_name_fn(res) \ -char * res##_str(int type) { \ +const char * res##_str(int type) { \ unsigned int i; \ for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ if (res##_names[i].type == type)\ @@ -85,7 +85,7 @@ struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_TVDAC, "TVDAC" }, }; -type_name_fn(encoder_type) +static type_name_fn(encoder_type) struct type_name connector_status_names[] = { { DRM_MODE_CONNECTED, "connected" }, @@ -93,7 +93,7 @@ struct type_name connector_status_names[] = { { DRM_MODE_UNKNOWNCONNECTION, "unknown" }, }; -type_name_fn(connector_status) +static type_name_fn(connector_status) struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_Unknown, "unknown" }, @@ -113,11 +113,11 @@ struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_eDP, "embedded displayport" }, }; -type_name_fn(connector_type) +static type_name_fn(connector_type) #define bit_name_fn(res) \ -char * res##_str(int type) { \ - int i; \ +const char * res##_str(int type) { \ + unsigned int i; \ const char *sep = ""; \ for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ if (type & (1 << i)) { \ @@ -138,7 +138,7 @@ static const char *mode_type_names[] = { "driver", }; -bit_name_fn(mode_type) +static bit_name_fn(mode_type) static const char *mode_flag_names[] = { "phsync", @@ -157,9 +157,9 @@ static const char *mode_flag_names[] = { "clkdiv2" }; -bit_name_fn(mode_flag) +static bit_name_fn(mode_flag) -void dump_encoders(void)
[PATCH v3 1/4] modetest: Fix warnings
Enable all standard automake warnings except for -Wpointer-arith (as the test pattern generation code uses void pointer arithmetics) and fix them. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/Makefile.am | 4 +++- tests/modetest/buffers.c | 13 +++-- tests/modetest/buffers.h | 5 +++-- tests/modetest/modetest.c | 44 ++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am index 065ae13..9376767 100644 --- a/tests/modetest/Makefile.am +++ b/tests/modetest/Makefile.am @@ -1,4 +1,6 @@ -AM_CFLAGS = \ +AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS)) + +AM_CFLAGS += \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/libkms/ \ -I$(top_srcdir) diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 5086381..3c93994 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -882,8 +882,8 @@ fill_pattern(unsigned int format, enum fill_pattern pattern, void *planes[3], */ static struct kms_bo * -allocate_buffer(struct kms_driver *kms, - int width, int height, int *stride) +allocate_buffer(struct kms_driver *kms, unsigned int width, unsigned int height, + unsigned int *stride) { struct kms_bo *bo; unsigned bo_attribs[] = { @@ -917,13 +917,14 @@ allocate_buffer(struct kms_driver *kms, struct kms_bo * create_test_buffer(struct kms_driver *kms, unsigned int format, - int width, int height, int handles[4], - int pitches[4], int offsets[4], enum fill_pattern pattern) + unsigned int width, unsigned int height, + unsigned int handles[4], unsigned int pitches[4], + unsigned int offsets[4], enum fill_pattern pattern) { struct kms_bo *bo; - int ret, stride; - void *planes[3]; + void *planes[3] = { 0, }; void *virtual; + int ret; bo = allocate_buffer(kms, width, height, pitches[0]); if (!bo) diff --git a/tests/modetest/buffers.h b/tests/modetest/buffers.h index 2b15ce5..e320389 100644 --- a/tests/modetest/buffers.h +++ b/tests/modetest/buffers.h @@ -37,8 +37,9 @@ enum fill_pattern { }; struct kms_bo *create_test_buffer(struct kms_driver *kms, unsigned int format, - int width, int height, int handles[4], int pitches[4], - int offsets[4], enum fill_pattern pattern); + unsigned int width, unsigned int height, + unsigned int handles[4], unsigned int pitches[4], + unsigned int offsets[4], enum fill_pattern pattern); unsigned int format_fourcc(const char *name); diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index c91bb9d..1081c78 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -64,11 +64,11 @@ int fd, modes; struct type_name { int type; - char *name; + const char *name; }; #define type_name_fn(res) \ -char * res##_str(int type) { \ +const char * res##_str(int type) { \ unsigned int i; \ for (i = 0; i ARRAY_SIZE(res##_names); i++) { \ if (res##_names[i].type == type)\ @@ -85,7 +85,7 @@ struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_TVDAC, TVDAC }, }; -type_name_fn(encoder_type) +static type_name_fn(encoder_type) struct type_name connector_status_names[] = { { DRM_MODE_CONNECTED, connected }, @@ -93,7 +93,7 @@ struct type_name connector_status_names[] = { { DRM_MODE_UNKNOWNCONNECTION, unknown }, }; -type_name_fn(connector_status) +static type_name_fn(connector_status) struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_Unknown, unknown }, @@ -113,11 +113,11 @@ struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_eDP, embedded displayport }, }; -type_name_fn(connector_type) +static type_name_fn(connector_type) #define bit_name_fn(res) \ -char * res##_str(int type) { \ - int i; \ +const char * res##_str(int type) { \ + unsigned int i; \ const char *sep = ; \ for (i = 0; i ARRAY_SIZE(res##_names); i++) { \ if (type (1 i)) { \ @@ -138,7 +138,7 @@ static const char *mode_type_names[] = { driver, }; -bit_name_fn(mode_type) +static bit_name_fn(mode_type) static const char *mode_flag_names[] = { phsync, @@ -157,9 +157,9 @@ static const char *mode_flag_names[] = { clkdiv2 }; -bit_name_fn(mode_flag) +static bit_name_fn(mode_flag)