modetest: fix some compiler warnings
PATCH 1/4 modetest: fix some compiler warnings
From: Paulo Zanoni <[email protected]>
Use unsigned int instead of int:
- modetest.c:90:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:98:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:118:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:286:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:303:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:694:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:1088:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
The 'fd' variable is global, we don't need to pass it as an argument:
- modetest.c:998:40: warning: unused parameter ‘fd’ [-Wunused-parameter]
We don't use the 'modeset' variable:
- modetest.c:1025:8: warning: variable ‘modeset’ set but not used [-Wunused-but-set-variable]
V2: rebase, clear some more warnings
--- tests/modetest/modetest.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Hi
I'm sending this patch series again. These 4 patches are independent from the object properties patches, so once reviewed, it would be nice if someone could push them.
Patch 1 had to be rebased and patch 3 is new.
Thanks,
Paulo
tests/modetest/modetest.c +8 -8
@@ -71,7 +71,7 @@ struct type_name {#define type_name_fn (res) \ char * res##_str(int type) { \ - int i; \ + unsigned int i; \ for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ if (res##_names[i].type == type) \ return res##_names[i].name; \
@@ -272,7 +272,7 @@ static void dump_planes(void) {drmModePlaneRes *plane_resources;drmModePlane *ovr; -int i, j; +unsigned int i, j; plane_resources =drmModeGetPlaneResources (fd);if (!plane_resources) {
@@ -681,7 +681,8 @@ set_plane(struct kms_driver *kms, struct connector *c, struct plane *p)uint32_t plane_id =0 ;struct kms_bo *plane_bo;uint32_t plane_flags =0 , format; -int i, ret, crtc_x, crtc_y, crtc_w, crtc_h; +int ret, crtc_x, crtc_y, crtc_w, crtc_h; +unsigned int i;/* find an unused plane which can be connected to our crtc */ plane_resources =drmModeGetPlaneResources (fd);
@@ -995,7 +996,7 @@ void usage(char *name)#define dump_resource (res) if (res) dump_##res() -static int page_flipping_supported (int fd) +static int page_flipping_supported (void ) {/*FIXME: generic ioctl needed? */ return 1 ;
@@ -1022,8 +1023,8 @@ int main(int argc, char **argv)int encoders =0 , connectors =0 , crtcs =0 , planes =0 , framebuffers =0 ;int test_vsync =0 ;char *modules[] = {"i915" ,"radeon" ,"nouveau" ,"vmwgfx" ,"omapdrm" }; -char *modeset =NULL ; -int i, count =0 , plane_count =0 ; +unsigned int i; +int count =0 , plane_count =0 ;struct connector con_args[2 ];struct plane plane_args[2 ] = {0 };
@@ -1050,7 +1051,6 @@ int main(int argc, char **argv) test_vsync =1 ;break ;case 's' : - modeset =strdup (optarg); con_args[count].crtc =-1 ; if (sscanf(optarg, "%d:%64s", &con_args[count].id,
@@ -1096,7 +1096,7 @@ int main(int argc, char **argv) } } -if (test_vsync && !page_flipping_supported (fd)) { +if (test_vsync && !page_flipping_supported ()) {fprintf (stderr,"page flipping not supported by drm.\n" );return -1 ; }
Signature · 6 lines
1.7.9.5 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 modetest: fix drmModeGetConnector memory leak
From: Paulo Zanoni <[email protected]>
Don't "continue" without freeing the connector.
192 bytes in 6 blocks are indirectly lost in loss record 6 of 12
at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E30DD8: drmMalloc (xf86drm.c:147)
by 0x4E35024: drmAllocCpy (xf86drmMode.c:73)
by 0x4E35D69: drmModeGetConnector (xf86drmMode.c:507)
by 0x402F22: dump_connectors (modetest.c:181)
by 0x40261B: main (modetest.c:801)
--- tests/modetest/modetest.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
tests/modetest/modetest.c +10 -11
@@ -199,17 +199,16 @@ void dump_connectors(void)printf ("%s%d" , j >0 ?", " :"" , connector->encoders[j]);printf ("\n" ); -if (!connector->count_modes) -continue ; - -printf (" modes:\n" ); -printf (" name refresh (Hz) hdisp hss hse htot vdisp " -"vss vse vtot)\n" ); -for (j =0 ; j < connector->count_modes; j++) -dump_mode (&connector->modes[j]); - -printf (" props:\n" ); -dump_props (connector); +if (connector->count_modes) { +printf (" modes:\n" ); +printf (" name refresh (Hz) hdisp hss hse htot vdisp " +"vss vse vtot)\n" ); +for (j =0 ; j < connector->count_modes; j++) +dump_mode (&connector->modes[j]); + +printf (" props:\n" ); +dump_props (connector); + }drmModeFreeConnector (connector); }
Signature · 1 line
1.7.9.5
PATCH 3/4 modetest: call drmModeFreePlaneResources
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
24 (16 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 7
at 0x402994D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4A25950: drmMalloc (xf86drm.c:147)
by 0x4A2E26D: drmModeGetPlaneResources (xf86drmMode.c:951)
by 0x4025FF: dump_planes (modetest.c:276)
by 0x4052AF: main (modetest.c:1120)
--- tests/modetest/modetest.c | 1 + 1 file changed, 1 insertion(+)
tests/modetest/modetest.c +1 -0
@@ -307,6 +307,7 @@ static void dump_planes(void) }printf ("\n" ); +drmModeFreePlaneResources (plane_resources);return ; }
Signature · 1 line
1.7.9.5
PATCH 4/4 modetest: print more about our properties
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
In the future we'll have more than just connector properties, so create a dump_prop function that can handle any property (instead of the current dump_props function that only handles connector properties).
Also, make this function print a lot more information about the existing properties.
Also change the printed indentation of the modes to make the output more readable.
The previous function dump_props also segfaulted when we didn't have enought permissions. The new function does not segfault in this case (by checking for the return value of drmModeGetProperty).
--- tests/modetest/modetest.c | 95 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 9 deletions(-)
tests/modetest/modetest.c +86 -9
@@ -43,6 +43,7 @@#include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <inttypes.h> #include <unistd.h> #include <string.h> #include <errno.h>
@@ -145,7 +146,7 @@ void dump_encoders(void)void dump_mode (drmModeModeInfo *mode) { - printf(" %s %d %d %d %d %d %d %d %d %d\n", + printf("\t%s %d %d %d %d %d %d %d %d %d\n", mode->name, mode->vrefresh, mode->hdisplay,
@@ -159,16 +160,90 @@ void dump_mode(drmModeModeInfo *mode) }static void -dump_props (drmModeConnector *connector) +dump_blob (uint32_t blob_id) +{ +uint32_t i; +unsigned char *blob_data; +drmModePropertyBlobPtr blob; + + blob =drmModeGetPropertyBlob (fd, blob_id); +if (!blob) +return ; + + blob_data = blob->data; + +for (i =0 ; i < blob->length; i++) { +if (i %16 ==0 ) +printf ("\n\t\t\t" ); +printf ("%.2hhx" , blob_data[i]); + } +printf ("\n" ); + +drmModeFreePropertyBlob (blob); +} + +static void +dump_prop (uint32_t prop_id,uint64_t value) { -drmModePropertyPtr props;int i; +drmModePropertyPtr prop; + + prop =drmModeGetProperty (fd, prop_id); + +printf ("\t%d" , prop_id); +if (!prop) { +printf ("\n" ); +return ; + } + +printf (" %s:\n" , prop->name); + +printf ("\t\tflags:" ); +if (prop->flags &DRM_MODE_PROP_PENDING ) +printf (" pending" ); +if (prop->flags &DRM_MODE_PROP_RANGE ) +printf (" range" ); +if (prop->flags &DRM_MODE_PROP_IMMUTABLE ) +printf (" immutable" ); +if (prop->flags &DRM_MODE_PROP_ENUM ) +printf (" enum" ); +if (prop->flags &DRM_MODE_PROP_BLOB ) +printf (" blob" ); +printf ("\n" ); + +if (prop->flags &DRM_MODE_PROP_RANGE ) { +printf ("\t\tvalues:" ); +for (i =0 ; i < prop->count_values; i++) +printf (" %" PRIu64, prop->values[i]); +printf ("\n" ); + } -for (i =0 ; i < connector->count_props; i++) { - props =drmModeGetProperty (fd, connector->props[i]); -printf ("\t%s, flags %d\n" , props->name, props->flags); -drmModeFreeProperty (props); +if (prop->flags &DRM_MODE_PROP_ENUM ) { +printf ("\t\tenums:" ); +for (i =0 ; i < prop->count_enums; i++) +printf (" %s=%llu" , prop->enums[i].name, + prop->enums[i].value); +printf ("\n" ); + }else { +assert (prop->count_enums ==0 ); } + +if (prop->flags &DRM_MODE_PROP_BLOB ) { +printf ("\t\tblobs:\n" ); +for (i =0 ; i < prop->count_blobs; i++) +dump_blob (prop->blob_ids[i]); +printf ("\n" ); + }else { +assert (prop->count_blobs ==0 ); + } + +printf ("\t\tvalue:" ); +if (prop->flags &DRM_MODE_PROP_BLOB ) +dump_blob (value); +else +printf (" %" PRIu64"\n" , value); + +drmModeFreeProperty (prop); }void dump_connectors (void )
@@ -201,13 +276,15 @@ void dump_connectors(void)if (connector->count_modes) {printf (" modes:\n" ); -printf (" name refresh (Hz) hdisp hss hse htot vdisp " +printf ("\tname refresh (Hz) hdisp hss hse htot vdisp " "vss vse vtot)\n" );for (j =0 ; j < connector->count_modes; j++)dump_mode (&connector->modes[j]);printf (" props:\n" ); -dump_props (connector); +for (j =0 ; j < connector->count_props; j++) +dump_prop (connector->props[j], + connector->prop_values[j]); }drmModeFreeConnector (connector);
Signature · 1 line
1.7.9.5
Re: [PATCH libdrm 4/4] modetest: print more about our properties
Quoted 12 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
In the future we'll have more than just connector properties, so create a
dump_propfunction that can handle any property (instead of the currentdump_propsfunction that only handles connector properties).Also, make this function print a lot more information about the existing properties.
Also change the printed indentation of the modes to make the output more readable.
Quoted 6 lines
The previous function
dump_propsalso segfaulted when we didn't have enought permissions. The new function does not segfault in this case (by checking for the return value of drmModeGetProperty).Reviewed-by Eugeni Dodonov <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
Looks like this series here has been lost a bit. I've pushed all 4 patches, thanks.
-Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48