All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 0/4] Minor cleanups
@ 2014-04-08 20:49 Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 1/4] Mark functions printf-like where possible Thierry Reding
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-08 20:49 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

These four patches clean up some minor issues in libdrm. Patch 1 makes
gcc aware of various functions (such as drmMsg(), drm_debug_print(),
etc) being printf-like and patches 2 and 3 fix up a number of warnings
flagged as a result of that.

Patch 4 uses drmFreeVersion() instead of drmFree() to free a drmVersion
structure to prevent memory leaks.

Thierry

Thierry Reding (4):
  Mark functions printf-like where possible
  intel: Fix some format strings
  libdrm: Remove extraneous parameter
  tests: Use drmFreeVersion() instead of drmFree()

 intel/intel_bufmgr_fake.c | 20 ++++++++++----------
 intel/intel_decode.c      |  7 ++-----
 tests/drmstat.c           |  2 +-
 tests/getversion.c        |  2 +-
 xf86drm.c                 | 12 ++++++++----
 xf86drm.h                 |  2 +-
 6 files changed, 23 insertions(+), 22 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH libdrm 1/4] Mark functions printf-like where possible
  2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
@ 2014-04-08 20:49 ` Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 2/4] intel: Fix some format strings Thierry Reding
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-08 20:49 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

These functions all take a format string and either a list of variable
arguments or a va_list. Use the new DRM_PRINTFLIKE macro to tell the
compiler about it so that the arguments can be checked against the
format string.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 intel/intel_decode.c |  7 ++-----
 tests/drmstat.c      |  2 +-
 xf86drm.c            | 10 +++++++---
 xf86drm.h            |  2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/intel/intel_decode.c b/intel/intel_decode.c
index c0a0cafc904e..61239dd96d27 100644
--- a/intel/intel_decode.c
+++ b/intel/intel_decode.c
@@ -29,6 +29,7 @@
 #include <stdarg.h>
 #include <string.h>
 
+#include "xf86drm.h"
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
 
@@ -104,11 +105,7 @@ static float int_as_float(uint32_t intval)
 	return uval.f;
 }
 
-static void
-instr_out(struct drm_intel_decode *ctx, unsigned int index,
-	  const char *fmt, ...) __attribute__((format(__printf__, 3, 4)));
-
-static void
+static void DRM_PRINTFLIKE(3, 4)
 instr_out(struct drm_intel_decode *ctx, unsigned int index,
 	  const char *fmt, ...)
 {
diff --git a/tests/drmstat.c b/tests/drmstat.c
index 345b8d2cda31..c51cbc6c9f61 100644
--- a/tests/drmstat.c
+++ b/tests/drmstat.c
@@ -425,7 +425,7 @@ int main(int argc, char **argv)
     return r; 
 }
 
-void
+void DRM_PRINTFLIKE(4, 0)
 xf86VDrvMsgVerb(int scrnIndex, int type, int verb, const char *format,
                 va_list args)
 {
diff --git a/xf86drm.c b/xf86drm.c
index 720952ff2cbd..fa5701abae51 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -104,12 +104,16 @@ void drmSetServerInfo(drmServerInfoPtr info)
  * This function is a wrapper around vfprintf().
  */
 
-static int drmDebugPrint(const char *format, va_list ap)
+static int DRM_PRINTFLIKE(1, 0)
+drmDebugPrint(const char *format, va_list ap)
 {
     return vfprintf(stderr, format, ap);
 }
 
-static int (*drm_debug_print)(const char *format, va_list ap) = drmDebugPrint;
+typedef int DRM_PRINTFLIKE(1, 0) (*debug_msg_func_t)(const char *format,
+						     va_list ap);
+
+static debug_msg_func_t drm_debug_print = drmDebugPrint;
 
 void
 drmMsg(const char *format, ...)
@@ -129,7 +133,7 @@ drmMsg(const char *format, ...)
 }
 
 void
-drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char *format, va_list ap))
+drmSetDebugMsgFunction(debug_msg_func_t debug_msg_ptr)
 {
     drm_debug_print = debug_msg_ptr;
 }
diff --git a/xf86drm.h b/xf86drm.h
index 5e170f86fe5e..c024cc446354 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -704,7 +704,7 @@ extern int  drmSLLookupNeighbors(void *l, unsigned long key,
 
 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
 extern void drmCloseOnce(int fd);
-extern void drmMsg(const char *format, ...);
+extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
 
 extern int drmSetMaster(int fd);
 extern int drmDropMaster(int fd);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH libdrm 2/4] intel: Fix some format strings
  2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 1/4] Mark functions printf-like where possible Thierry Reding
@ 2014-04-08 20:49 ` Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 3/4] libdrm: Remove extraneous parameter Thierry Reding
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-08 20:49 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Some of the format strings for debug messages use the wrong modifier to
print sizes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 intel/intel_bufmgr_fake.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/intel/intel_bufmgr_fake.c b/intel/intel_bufmgr_fake.c
index d9b5cfdc8952..d63fc815cf9c 100644
--- a/intel/intel_bufmgr_fake.c
+++ b/intel/intel_bufmgr_fake.c
@@ -505,7 +505,7 @@ alloc_backing_store(drm_intel_bo *bo)
 
 	bo_fake->backing_store = malloc(bo->size);
 
-	DBG("alloc_backing - buf %d %p %d\n", bo_fake->id,
+	DBG("alloc_backing - buf %d %p %lu\n", bo_fake->id,
 	    bo_fake->backing_store, bo->size);
 	assert(bo_fake->backing_store);
 }
@@ -716,7 +716,7 @@ evict_and_alloc_block(drm_intel_bo *bo)
 		if (alloc_block(bo))
 			return 1;
 
-	DBG("%s 0x%x bytes failed\n", __FUNCTION__, bo->size);
+	DBG("%s 0x%lx bytes failed\n", __FUNCTION__, bo->size);
 
 	return 0;
 }
@@ -835,7 +835,7 @@ drm_intel_fake_bo_alloc(drm_intel_bufmgr *bufmgr,
 	bo_fake->flags = 0;
 	bo_fake->is_static = 0;
 
-	DBG("drm_bo_alloc: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
+	DBG("drm_bo_alloc: (buf %d: %s, %lu kb)\n", bo_fake->id, bo_fake->name,
 	    bo_fake->bo.size / 1024);
 
 	return &bo_fake->bo;
@@ -894,7 +894,7 @@ drm_intel_bo_fake_alloc_static(drm_intel_bufmgr *bufmgr,
 	bo_fake->flags = BM_PINNED;
 	bo_fake->is_static = 1;
 
-	DBG("drm_bo_alloc_static: (buf %d: %s, %d kb)\n", bo_fake->id,
+	DBG("drm_bo_alloc_static: (buf %d: %s, %lu kb)\n", bo_fake->id,
 	    bo_fake->name, bo_fake->bo.size / 1024);
 
 	return &bo_fake->bo;
@@ -1022,7 +1022,7 @@ static int
 		return 0;
 
 	{
-		DBG("drm_bo_map: (buf %d: %s, %d kb)\n", bo_fake->id,
+		DBG("drm_bo_map: (buf %d: %s, %lu kb)\n", bo_fake->id,
 		    bo_fake->name, bo_fake->bo.size / 1024);
 
 		if (bo->virtual != NULL) {
@@ -1100,7 +1100,7 @@ static int
 	if (--bo_fake->map_count != 0)
 		return 0;
 
-	DBG("drm_bo_unmap: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
+	DBG("drm_bo_unmap: (buf %d: %s, %lu kb)\n", bo_fake->id, bo_fake->name,
 	    bo_fake->bo.size / 1024);
 
 	bo->virtual = NULL;
@@ -1167,7 +1167,7 @@ static int
 
 	bufmgr_fake = (drm_intel_bufmgr_fake *) bo->bufmgr;
 
-	DBG("drm_bo_validate: (buf %d: %s, %d kb)\n", bo_fake->id,
+	DBG("drm_bo_validate: (buf %d: %s, %lu kb)\n", bo_fake->id,
 	    bo_fake->name, bo_fake->bo.size / 1024);
 
 	/* Sanity check: Buffers should be unmapped before being validated.
@@ -1197,7 +1197,7 @@ static int
 
 	/* Upload the buffer contents if necessary */
 	if (bo_fake->dirty) {
-		DBG("Upload dirty buf %d:%s, sz %d offset 0x%x\n", bo_fake->id,
+		DBG("Upload dirty buf %d:%s, sz %lu offset 0x%x\n", bo_fake->id,
 		    bo_fake->name, bo->size, bo_fake->block->mem->ofs);
 
 		assert(!(bo_fake->flags & (BM_NO_BACKING_STORE | BM_PINNED)));
@@ -1522,12 +1522,12 @@ drm_intel_fake_check_aperture_space(drm_intel_bo ** bo_array, int count)
 	}
 
 	if (sz > bufmgr_fake->size) {
-		DBG("check_space: overflowed bufmgr size, %dkb vs %dkb\n",
+		DBG("check_space: overflowed bufmgr size, %ukb vs %lukb\n",
 		    sz / 1024, bufmgr_fake->size / 1024);
 		return -1;
 	}
 
-	DBG("drm_check_space: sz %dkb vs bufgr %dkb\n", sz / 1024,
+	DBG("drm_check_space: sz %ukb vs bufgr %lukb\n", sz / 1024,
 	    bufmgr_fake->size / 1024);
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH libdrm 3/4] libdrm: Remove extraneous parameter
  2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 1/4] Mark functions printf-like where possible Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 2/4] intel: Fix some format strings Thierry Reding
@ 2014-04-08 20:49 ` Thierry Reding
  2014-04-08 20:49 ` [PATCH libdrm 4/4] tests: Use drmFreeVersion() instead of drmFree() Thierry Reding
  2014-04-08 21:38 ` [PATCH libdrm 0/4] Minor cleanups Eric Anholt
  4 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-08 20:49 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The debug message's format string doesn't contain any conversion
specifiers, therefore making the fd argument unused.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 xf86drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xf86drm.c b/xf86drm.c
index fa5701abae51..e94f2cd00c11 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -503,7 +503,7 @@ static int drmOpenByBusid(const char *busid)
 		sv.drm_di_minor = 1;
 		sv.drm_dd_major = -1;       /* Don't care */
 		sv.drm_dd_minor = -1;       /* Don't care */
-		drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n",fd);
+		drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n");
 		drmSetInterfaceVersion(fd, &sv);
 	    }
 	    buf = drmGetBusid(fd);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH libdrm 4/4] tests: Use drmFreeVersion() instead of drmFree()
  2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
                   ` (2 preceding siblings ...)
  2014-04-08 20:49 ` [PATCH libdrm 3/4] libdrm: Remove extraneous parameter Thierry Reding
@ 2014-04-08 20:49 ` Thierry Reding
  2014-04-08 21:38 ` [PATCH libdrm 0/4] Minor cleanups Eric Anholt
  4 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-08 20:49 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

drmFreeVersion() frees the memory allocated for the name, date and desc
fields in addition to that for the struct _drmVersion.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/getversion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/getversion.c b/tests/getversion.c
index 53d1d354ea16..bcec46999140 100644
--- a/tests/getversion.c
+++ b/tests/getversion.c
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
 	assert(strlen(v->desc) != 0);
 	if (strcmp(v->name, "i915") == 0)
 		assert(v->version_major >= 1);
-	drmFree(v);
+	drmFreeVersion(v);
 	close(fd);
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH libdrm 0/4] Minor cleanups
  2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
                   ` (3 preceding siblings ...)
  2014-04-08 20:49 ` [PATCH libdrm 4/4] tests: Use drmFreeVersion() instead of drmFree() Thierry Reding
@ 2014-04-08 21:38 ` Eric Anholt
  2014-04-09  7:30   ` Thierry Reding
  4 siblings, 1 reply; 9+ messages in thread
From: Eric Anholt @ 2014-04-08 21:38 UTC (permalink / raw)
  To: Thierry Reding, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 514 bytes --]

Thierry Reding <thierry.reding@gmail.com> writes:

> From: Thierry Reding <treding@nvidia.com>
>
> These four patches clean up some minor issues in libdrm. Patch 1 makes
> gcc aware of various functions (such as drmMsg(), drm_debug_print(),
> etc) being printf-like and patches 2 and 3 fix up a number of warnings
> flagged as a result of that.
>
> Patch 4 uses drmFreeVersion() instead of drmFree() to free a drmVersion
> structure to prevent memory leaks.

These are:

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH libdrm 0/4] Minor cleanups
  2014-04-08 21:38 ` [PATCH libdrm 0/4] Minor cleanups Eric Anholt
@ 2014-04-09  7:30   ` Thierry Reding
  2014-04-11 20:18     ` Eric Anholt
  0 siblings, 1 reply; 9+ messages in thread
From: Thierry Reding @ 2014-04-09  7:30 UTC (permalink / raw)
  To: Eric Anholt; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 730 bytes --]

On Tue, Apr 08, 2014 at 02:38:22PM -0700, Eric Anholt wrote:
> Thierry Reding <thierry.reding@gmail.com> writes:
> 
> > From: Thierry Reding <treding@nvidia.com>
> >
> > These four patches clean up some minor issues in libdrm. Patch 1 makes
> > gcc aware of various functions (such as drmMsg(), drm_debug_print(),
> > etc) being printf-like and patches 2 and 3 fix up a number of warnings
> > flagged as a result of that.
> >
> > Patch 4 uses drmFreeVersion() instead of drmFree() to free a drmVersion
> > structure to prevent memory leaks.
> 
> These are:
> 
> Reviewed-by: Eric Anholt <eric@anholt.net>

Thanks. I don't have the necessary permissions to push this, can
somebody else help out here?

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH libdrm 0/4] Minor cleanups
  2014-04-09  7:30   ` Thierry Reding
@ 2014-04-11 20:18     ` Eric Anholt
  2014-04-17 14:26       ` Thierry Reding
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Anholt @ 2014-04-11 20:18 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 825 bytes --]

Thierry Reding <thierry.reding@gmail.com> writes:

> On Tue, Apr 08, 2014 at 02:38:22PM -0700, Eric Anholt wrote:
>> Thierry Reding <thierry.reding@gmail.com> writes:
>> 
>> > From: Thierry Reding <treding@nvidia.com>
>> >
>> > These four patches clean up some minor issues in libdrm. Patch 1 makes
>> > gcc aware of various functions (such as drmMsg(), drm_debug_print(),
>> > etc) being printf-like and patches 2 and 3 fix up a number of warnings
>> > flagged as a result of that.
>> >
>> > Patch 4 uses drmFreeVersion() instead of drmFree() to free a drmVersion
>> > structure to prevent memory leaks.
>> 
>> These are:
>> 
>> Reviewed-by: Eric Anholt <eric@anholt.net>
>
> Thanks. I don't have the necessary permissions to push this, can
> somebody else help out here?

I've given you permissions.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH libdrm 0/4] Minor cleanups
  2014-04-11 20:18     ` Eric Anholt
@ 2014-04-17 14:26       ` Thierry Reding
  0 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2014-04-17 14:26 UTC (permalink / raw)
  To: Eric Anholt; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1053 bytes --]

On Fri, Apr 11, 2014 at 01:18:11PM -0700, Eric Anholt wrote:
> Thierry Reding <thierry.reding@gmail.com> writes:
> 
> > On Tue, Apr 08, 2014 at 02:38:22PM -0700, Eric Anholt wrote:
> >> Thierry Reding <thierry.reding@gmail.com> writes:
> >> 
> >> > From: Thierry Reding <treding@nvidia.com>
> >> >
> >> > These four patches clean up some minor issues in libdrm. Patch 1 makes
> >> > gcc aware of various functions (such as drmMsg(), drm_debug_print(),
> >> > etc) being printf-like and patches 2 and 3 fix up a number of warnings
> >> > flagged as a result of that.
> >> >
> >> > Patch 4 uses drmFreeVersion() instead of drmFree() to free a drmVersion
> >> > structure to prevent memory leaks.
> >> 
> >> These are:
> >> 
> >> Reviewed-by: Eric Anholt <eric@anholt.net>
> >
> > Thanks. I don't have the necessary permissions to push this, can
> > somebody else help out here?
> 
> I've given you permissions.

I think Daniel Stone already gave me permissions as well. Anyway, pushed
with your Reviewed-by.

Thanks,
Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-17 14:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08 20:49 [PATCH libdrm 0/4] Minor cleanups Thierry Reding
2014-04-08 20:49 ` [PATCH libdrm 1/4] Mark functions printf-like where possible Thierry Reding
2014-04-08 20:49 ` [PATCH libdrm 2/4] intel: Fix some format strings Thierry Reding
2014-04-08 20:49 ` [PATCH libdrm 3/4] libdrm: Remove extraneous parameter Thierry Reding
2014-04-08 20:49 ` [PATCH libdrm 4/4] tests: Use drmFreeVersion() instead of drmFree() Thierry Reding
2014-04-08 21:38 ` [PATCH libdrm 0/4] Minor cleanups Eric Anholt
2014-04-09  7:30   ` Thierry Reding
2014-04-11 20:18     ` Eric Anholt
2014-04-17 14:26       ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.