dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libdrm 1/2] automake: set --enable-valgrind during make distcheck
@ 2015-09-07  9:53 Emil Velikov
  2015-09-07  9:53 ` [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API Emil Velikov
  0 siblings, 1 reply; 4+ messages in thread
From: Emil Velikov @ 2015-09-07  9:53 UTC (permalink / raw)
  To: dri-devel; +Cc: emil.l.velikov

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index a7a0cca..ca41508 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,7 +37,8 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
 	--enable-tegra-experimental-api \
 	--enable-install-test-programs \
 	--enable-cairo-tests \
-	--enable-manpages
+	--enable-manpages \
+	--enable-valgrind
 
 pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm.pc
-- 
2.5.0

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

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

* [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API
  2015-09-07  9:53 [PATCH libdrm 1/2] automake: set --enable-valgrind during make distcheck Emil Velikov
@ 2015-09-07  9:53 ` Emil Velikov
  2015-09-07 13:06   ` Ville Syrjälä
  0 siblings, 1 reply; 4+ messages in thread
From: Emil Velikov @ 2015-09-07  9:53 UTC (permalink / raw)
  To: dri-devel; +Cc: emil.l.velikov, Rob Clark, Daniel Stone

As going through the modetest patches for atomic support I've noticed
that if we pass NULL for the drmModeAtomicReqPtr argument we'll crash.

So let's handle things appropriately if the user forgot to check the
return value of drmModeAtomicAlloc and drmModeAtomicDuplicate or made a
typo somewhere along the way.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rob Clark <robclark@freedesktop.org>
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 xf86drmMode.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 23800dd..ab6b519 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1189,6 +1189,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
 {
 	drmModeAtomicReqPtr new;
 
+	if (!old)
+		return NULL;
+
 	new = drmMalloc(sizeof *new);
 	if (!new)
 		return NULL;
@@ -1213,6 +1216,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
 
 int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
 {
+	if (!base)
+		return -EINVAL;
+
 	if (!augment || augment->cursor == 0)
 		return 0;
 
@@ -1239,12 +1245,15 @@ int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
 
 int drmModeAtomicGetCursor(drmModeAtomicReqPtr req)
 {
+	if (!req)
+		return -EINVAL;
 	return req->cursor;
 }
 
 void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor)
 {
-	req->cursor = cursor;
+	if (req)
+		req->cursor = cursor;
 }
 
 int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
@@ -1252,6 +1261,9 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
 			     uint32_t property_id,
 			     uint64_t value)
 {
+	if (!req)
+		return -EINVAL;
+
 	if (req->cursor >= req->size_items) {
 		drmModeAtomicReqItemPtr new;
 
@@ -1309,6 +1321,9 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
 	int obj_idx = -1;
 	int ret = -1;
 
+	if (!req)
+		return -EINVAL;
+
 	if (req->cursor == 0)
 		return 0;
 
-- 
2.5.0

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

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

* Re: [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API
  2015-09-07  9:53 ` [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API Emil Velikov
@ 2015-09-07 13:06   ` Ville Syrjälä
  2015-09-10 11:10     ` Emil Velikov
  0 siblings, 1 reply; 4+ messages in thread
From: Ville Syrjälä @ 2015-09-07 13:06 UTC (permalink / raw)
  To: Emil Velikov; +Cc: Rob Clark, dri-devel, Daniel Stone

On Mon, Sep 07, 2015 at 10:53:06AM +0100, Emil Velikov wrote:
> As going through the modetest patches for atomic support I've noticed
> that if we pass NULL for the drmModeAtomicReqPtr argument we'll crash.
> 
> So let's handle things appropriately if the user forgot to check the
> return value of drmModeAtomicAlloc and drmModeAtomicDuplicate or made a
> typo somewhere along the way.

I'm not sure hand-holding the user to such an extent is actually useful.
OTOH I guess one NULL check per function call isn't all that expensive
either.

> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Rob Clark <robclark@freedesktop.org>
> Cc: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> ---
>  xf86drmMode.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/xf86drmMode.c b/xf86drmMode.c
> index 23800dd..ab6b519 100644
> --- a/xf86drmMode.c
> +++ b/xf86drmMode.c
> @@ -1189,6 +1189,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
>  {
>  	drmModeAtomicReqPtr new;
>  
> +	if (!old)
> +		return NULL;
> +
>  	new = drmMalloc(sizeof *new);
>  	if (!new)
>  		return NULL;
> @@ -1213,6 +1216,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
>  
>  int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
>  {
> +	if (!base)
> +		return -EINVAL;
> +
>  	if (!augment || augment->cursor == 0)
>  		return 0;
>  
> @@ -1239,12 +1245,15 @@ int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
>  
>  int drmModeAtomicGetCursor(drmModeAtomicReqPtr req)
>  {
> +	if (!req)
> +		return -EINVAL;
>  	return req->cursor;
>  }
>  
>  void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor)
>  {
> -	req->cursor = cursor;
> +	if (req)
> +		req->cursor = cursor;
>  }
>  
>  int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
> @@ -1252,6 +1261,9 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
>  			     uint32_t property_id,
>  			     uint64_t value)
>  {
> +	if (!req)
> +		return -EINVAL;
> +
>  	if (req->cursor >= req->size_items) {
>  		drmModeAtomicReqItemPtr new;
>  
> @@ -1309,6 +1321,9 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
>  	int obj_idx = -1;
>  	int ret = -1;
>  
> +	if (!req)
> +		return -EINVAL;
> +
>  	if (req->cursor == 0)
>  		return 0;
>  
> -- 
> 2.5.0

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API
  2015-09-07 13:06   ` Ville Syrjälä
@ 2015-09-10 11:10     ` Emil Velikov
  0 siblings, 0 replies; 4+ messages in thread
From: Emil Velikov @ 2015-09-10 11:10 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: emil.l.velikov, Rob Clark, dri-devel, Daniel Stone

On 07/09/15 14:06, Ville Syrjälä wrote:
> On Mon, Sep 07, 2015 at 10:53:06AM +0100, Emil Velikov wrote:
>> As going through the modetest patches for atomic support I've noticed
>> that if we pass NULL for the drmModeAtomicReqPtr argument we'll crash.
>>
>> So let's handle things appropriately if the user forgot to check the
>> return value of drmModeAtomicAlloc and drmModeAtomicDuplicate or made a
>> typo somewhere along the way.
> 
> I'm not sure hand-holding the user to such an extent is actually useful.
From what I've gathered "smoke-testing" is not meant to be smart.

> OTOH I guess one NULL check per function call isn't all that expensive
> either.
> 
This is pretty much the reason why I bothered :)

Although if anyone feels strongly against it I'll drop the patch.

Thanks
Emil

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

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

end of thread, other threads:[~2015-09-10 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-07  9:53 [PATCH libdrm 1/2] automake: set --enable-valgrind during make distcheck Emil Velikov
2015-09-07  9:53 ` [PATCH libdrm 2/2] xf86drmMode: smoke-test the atomic API Emil Velikov
2015-09-07 13:06   ` Ville Syrjälä
2015-09-10 11:10     ` Emil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).