diff mbox

[v3,1/2] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev

Message ID 2a3a6d999502db1b6a47706b4da92d396075b22b.1495029016.git-series.kieran.bingham+renesas@ideasonboard.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kieran Bingham May 17, 2017, 2:13 p.m. UTC
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Return NULL, if a null entity is parsed for it's v4l2_subdev

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
 include/media/v4l2-subdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Geert Uytterhoeven May 17, 2017, 2:25 p.m. UTC | #1
Hi Kieran,

On Wed, May 17, 2017 at 4:13 PM, Kieran Bingham <kbingham@kernel.org> wrote:
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -829,7 +829,7 @@ struct v4l2_subdev {
>  };
>
>  #define media_entity_to_v4l2_subdev(ent) \
> -       container_of(ent, struct v4l2_subdev, entity)
> +       ent ? container_of(ent, struct v4l2_subdev, entity) : NULL

Due to the low precedence level of the ternary operator, you want
to enclose this in parentheses.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Kieran Bingham May 17, 2017, 2:37 p.m. UTC | #2
On 17/05/17 15:25, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Wed, May 17, 2017 at 4:13 PM, Kieran Bingham <kbingham@kernel.org> wrote:
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -829,7 +829,7 @@ struct v4l2_subdev {
>>  };
>>
>>  #define media_entity_to_v4l2_subdev(ent) \
>> -       container_of(ent, struct v4l2_subdev, entity)
>> +       ent ? container_of(ent, struct v4l2_subdev, entity) : NULL
> 
> Due to the low precedence level of the ternary operator, you want
> to enclose this in parentheses.

Thanks Geert - That's quick to respin ;)

--
Kieran

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
>
diff mbox

Patch

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5f1669c45642..d43fa7ca3a92 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -829,7 +829,7 @@  struct v4l2_subdev {
 };
 
 #define media_entity_to_v4l2_subdev(ent) \
-	container_of(ent, struct v4l2_subdev, entity)
+	ent ? container_of(ent, struct v4l2_subdev, entity) : NULL
 #define vdev_to_v4l2_subdev(vdev) \
 	((struct v4l2_subdev *)video_get_drvdata(vdev))