Skip to contentSkip to conversation

libdrm compile warnings fixes

PATCH In review Matthew W. S. Bell 2 participants 3 messages Feb 4, 2010 – Feb 6, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libdrm compile warnings fixes

Hi,

I've fixed up some compile warnings in the attached patch; I think a couple of cases may actually have been bugs. One case I have not touched is converting between void * (64 bit here) and drm_handle_t (32 bit here), as I don't understand the issues here; it would be nice if no warnings were emitted if it is safe.

Additionally, the function libdrm/xf86drmSL.c:drmSLLookupNeighbors() appears to be completely broken as it computes on the variable update which is unconditionally undefined.

Matthew W.S. Bell

From 605963e604b8d7e3aa5ffa9ed87738bf1a0f0b7d Mon Sep 17 00:00:00 2001
Message-Id: <605963e604b8d7e3aa5ffa9ed87738bf1a0f0b7d.1265309634.git.matthew@bells23.org.uk>
From: Matthew W. S. Bell <[email protected]>
Date: Sat, 30 Jan 2010 02:14:44 +0000
Subject: [PATCH] Tidy up compile warnings by cleaning up types.

---
 tests/dristat.c             |    3 ++-
 tests/drmtest.c             |    4 +++-
 tests/modeprint/modeprint.c |    8 ++++----
 tests/modetest/modetest.c   |   38 +++++++++++++++++---------------------
 xf86drmSL.c                 |    3 ---
 5 files changed, 26 insertions(+), 30 deletions(-)
tests/dristat.c +2 -1
index 48c3b51..900a3e6 100644
@@ -108,7 +108,8 @@ static void getvm(int fd)
 	flagname[6] = '\0';
 	
 	printf("    %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ",
-	       i, offset, (unsigned long)size, typename, flagname, handle);
+	       i, (unsigned long)offset, (unsigned long)size,
+	       typename, flagname, (unsigned long)handle);
 	if (mtrr < 0) printf("none\n");
 	else          printf("%4d\n", mtrr);
     }
tests/drmtest.c +3 -1
index 15e5c4a..685a652 100644
@@ -25,9 +25,11 @@
  *
  */
 
+#include <string.h>
 #include <fcntl.h>
 #include <fnmatch.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include "drmtest.h"
 
 #define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
@@ -60,7 +62,7 @@ int drm_open_matching(const char *pci_glob, int flags)
 	struct udev_device *device, *parent;
         struct udev_list_entry *entry;
 	const char *pci_id, *path;
-	int i, fd;
+	int fd;
 
 	udev = udev_new();
 	if (udev == NULL) {
tests/modeprint/modeprint.c +4 -4
index 595d444..8971914 100644
@@ -89,7 +89,7 @@ int printMode(struct drm_mode_modeinfo *mode)
 
 int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t value)
 {
-	const unsigned char *name = NULL;
+	const char *name = NULL;
 	int j;
 
 	printf("Property: %s\n", props->name);
@@ -101,7 +101,7 @@ int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t
 	if (props->count_values) {
 		printf("\tvalues       :");
 		for (j = 0; j < props->count_values; j++)
-			printf(" %lld", props->values[j]);
+			printf(" %llu", props->values[j]);
 		printf("\n");
 	}
 
@@ -116,7 +116,7 @@ int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t
 			printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data);
 			drmModeFreePropertyBlob(blob);
 		} else {
-			printf("error getting blob %lld\n", value);
+			printf("error getting blob %llu\n", value);
 		}
 
 	} else {
@@ -169,7 +169,7 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin
 
 	if (modes) {
 		for (i = 0; i < connector->count_modes; i++) {
-			mode = &connector->modes[i];
+			mode = (struct drm_mode_modeinfo *)&connector->modes[i];
 			printMode(mode);
 		}
 	}
tests/modetest/modetest.c +17 -21
index 34d40ca..26405f4 100644
@@ -47,6 +47,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include <sys/time.h>
 
 #include "xf86drm.h"
 #include "xf86drmMode.h"
@@ -255,9 +256,10 @@ void dump_framebuffers(void)
 				resources->fbs[i], strerror(errno));
 			continue;
 		}
-		printf("%d\t(%dx%d)\t%d\n",
+		printf("%u\t(%ux%u)\t%u\n",
 		       fb->fb_id,
-		       fb->width, fb->height);
+		       fb->width, fb->height,
+		       fb->pitch);
 
 		drmModeFreeFB(fb);
 	}
@@ -272,7 +274,7 @@ void dump_framebuffers(void)
  * can bind it with a free crtc.
  */
 struct connector {
-	int id;
+	uint32_t id;
 	char mode_str[64];
 	drmModeModeInfo *mode;
 	drmModeEncoder *encoder;
@@ -287,7 +289,7 @@ static void
 connector_find_mode(struct connector *c)
 {
 	drmModeConnector *connector;
-	int i, j, size, ret, width, height;
+	int i, j;
 
 	/* First, find the connector & mode */
 	c->mode = NULL;
@@ -358,7 +360,7 @@ create_test_buffer(drm_intel_bufmgr *bufmgr,
 {
 	drm_intel_bo *bo;
 	unsigned int *fb_ptr;
-	int size, ret, i, stride;
+	int size, i, stride;
 	div_t d;
 	cairo_surface_t *surface;
 	cairo_t *cr;
@@ -472,9 +474,7 @@ create_grey_buffer(drm_intel_bufmgr *bufmgr,
 		   int width, int height, int *stride_out, drm_intel_bo **bo_out)
 {
 	drm_intel_bo *bo;
-	unsigned int *fb_ptr;
-	int size, ret, i, stride;
-	div_t d;
+	int size, ret, stride;
 
 	/* Mode size at 32 bpp */
 	stride = width * 4;
@@ -509,7 +509,6 @@ page_flip_handler(int fd, unsigned int frame,
 {
 	struct connector *c;
 	unsigned int new_fb_id;
-	int len, ms;
 	struct timeval end;
 	double t;
 
@@ -536,13 +535,10 @@ page_flip_handler(int fd, unsigned int frame,
 static void
 set_mode(struct connector *c, int count, int page_flip)
 {
-	drmModeConnector *connector;
-	drmModeEncoder *encoder = NULL;
-	struct drm_mode_modeinfo *mode = NULL;
 	drm_intel_bufmgr *bufmgr;
 	drm_intel_bo *bo, *other_bo;
 	unsigned int fb_id, other_fb_id;
-	int i, j, ret, width, height, x, stride;
+	int i, ret, width, height, x, stride;
 	drmEventContext evctx;
 
 	width = 0;
@@ -611,9 +607,9 @@ set_mode(struct connector *c, int count, int page_flip)
 				DRM_MODE_PAGE_FLIP_EVENT, &c[i]);
 		gettimeofday(&c[i].start, NULL);
 		c[i].swap_count = 0;
- 		c[i].fb_id[0] = fb_id;
- 		c[i].fb_id[1] = other_fb_id;
- 		c[i].current_fb_id = fb_id;
+		c[i].fb_id[0] = fb_id;
+		c[i].fb_id[1] = other_fb_id;
+		c[i].current_fb_id = fb_id;
 	}
 
 	memset(&evctx, 0, sizeof evctx);
@@ -676,7 +672,7 @@ static int page_flipping_supported(int fd)
 		return 0;
 	}
 
-	return gp.value;
+	return *gp.value;
 }
 
 int main(int argc, char **argv)
@@ -685,8 +681,8 @@ int main(int argc, char **argv)
 	int encoders = 0, connectors = 0, crtcs = 0, framebuffers = 0;
 	int test_vsync = 0;
 	char *modules[] = { "i915", "radeon" };
-	char *modeset = NULL, *mode, *connector;
-	int i, connector_id, count = 0;
+	char *modeset = NULL;
+	int i, count = 0;
 	struct connector con_args[2];
 	
 	opterr = 0;
@@ -715,11 +711,11 @@ int main(int argc, char **argv)
 			con_args[count].crtc = -1;
 			if (sscanf(optarg, "%d:%64s",
 				   &con_args[count].id,
-				   &con_args[count].mode_str) != 2 &&
+				   con_args[count].mode_str) != 2 &&
 			    sscanf(optarg, "%d@%d:%64s",
 				   &con_args[count].id,
 				   &con_args[count].crtc,
-				   &con_args[count].mode_str) != 3)
+				   con_args[count].mode_str) != 3)
 				usage(argv[0]);
 			count++;				      
 			break;
xf86drmSL.c +0 -3
index 58aefac..acddb54 100644
@@ -265,11 +265,8 @@ int drmSLLookupNeighbors(void *l, unsigned long key,
 {
     SkipListPtr   list = (SkipListPtr)l;
     SLEntryPtr    update[SL_MAX_LEVEL + 1];
-    SLEntryPtr    entry;
     int           retcode = 0;
 
-    entry = SLLocate(list, key, update);
-
     *prev_key   = *next_key   = key;
     *prev_value = *next_value = NULL;
 	
Signature · 1 line
1.6.5

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#1 lore raw
Quoted 7 lines · Matthew W. S. Bell

Hi,

I've fixed up some compile warnings in the attached patch; I think a couple of cases may actually have been bugs. One case I have not touched is converting between void * (64 bit here) and drm_handle_t (32 bit here), as I don't understand the issues here; it would be nice if no warnings were emitted if it is safe.

Thanks for the patch, I just applied it.

Quoted 3 lines

Additionally, the function libdrm/xf86drmSL.c:drmSLLookupNeighbors() appears to be completely broken as it computes on the variable update which is unconditionally undefined.

Yeah, nothing really uses the skip list and I'd like to drop it and the hash table. I guess it's not a big deal though...

cheers,
Kristian

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--

#2 lore raw
Quoted 7 lines · Kristian Høgsberg

On Thu, Feb 4, 2010 at 2:23 PM, Matthew W. S. Bell

Quoted 3 lines

Additionally, the function libdrm/xf86drmSL.c:drmSLLookupNeighbors() appears to be completely broken as it computes on the variable update which is unconditionally undefined.

Yeah, nothing really uses the skip list and I'd like to drop it and the hash table. I guess it's not a big deal though...

Well, it's a small function that's part of a public API, it should either do something other than return undefined results or be removed. As such, here is a patch removing it.

Also attached is a patch for another warning fix.

Matthew W.S. Bell

From 3203bcbae14611fa4c3df8b1c9fe81a738991814 Mon Sep 17 00:00:00 2001
From: Matthew W. S. Bell <[email protected]>
Date: Sat, 6 Feb 2010 04:10:31 +0000
Subject: [PATCH 1/2] Cast type for printf to silence warning.

---
 tests/drmstat.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tests/drmstat.c +1 -1
index 345b8d2..ea9d12f 100644
@@ -288,7 +288,7 @@ int main(int argc, char **argv)
 		drmError(r, argv[0]);
 		return 1;
 	    }
-	    printf("0x%04lx byte shm added at 0x%08lx\n", size, handle);
+	    printf("0x%04lx byte shm added at 0x%08lx\n", size, (unsigned long)handle);
 	    sprintf(buf, "cat /proc/dri/0/vm");
 	    system(buf);
 	    break;
Signature · 1 line
1.6.5

From 04c7443cc7f16578c00d45617c91b51c26bdec17 Mon Sep 17 00:00:00 2001
From: Matthew W. S. Bell <[email protected]>
Date: Sat, 6 Feb 2010 04:11:02 +0000
Subject: [PATCH 2/2] Eliminate drmSLLookupNeighbors as it appears to want an
SLLocateNeighbors function that never existed.

---
 xf86drm.h   |    3 ---
 xf86drmSL.c |   51 ---------------------------------------------------
 2 files changed, 0 insertions(+), 54 deletions(-)
xf86drm.h +0 -3
index 9b89f56..9cec066 100644
@@ -682,9 +682,6 @@ extern int  drmSLDelete(void *l, unsigned long key);
 extern int  drmSLNext(void *l, unsigned long *key, void **value);
 extern int  drmSLFirst(void *l, unsigned long *key, void **value);
 extern void drmSLDump(void *l);
-extern int  drmSLLookupNeighbors(void *l, unsigned long key,
-				 unsigned long *prev_key, void **prev_value,
-				 unsigned long *next_key, void **next_value);
 
 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
 extern void drmCloseOnce(int fd);
xf86drmSL.c +0 -51

75 lines not on this page · raw message

Signature · 1 line
1.6.5

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel