All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: vsp1: cleanup a false positive warning
@ 2018-05-04 12:13 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2018-05-04 12:13 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Laurent Pinchart, linux-renesas-soc

With the new vsp1 code changes introduced by changeset
f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines dynamically"),
smatch complains with:
	drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru() error: we previously assumed 'pipe->bru' could be null (see line 180)

This is a false positive, as, if pipe->bru is NULL, the brx
var will be different, with ends by calling a code that will
set pipe->bru to another value.

Yet, cleaning this false positive is as easy as adding an explicit
check if pipe->bru is NULL.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index 095dc48aa25a..cb6b60843400 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
 		brx = &vsp1->brs->entity;
 
 	/* Switch BRx if needed. */
-	if (brx != pipe->brx) {
+	if (brx != pipe->brx || !pipe->brx) {
 		struct vsp1_entity *released_brx = NULL;
 
 		/* Release our BRx if we have one. */
-- 
2.17.0

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

* [PATCH] media: vsp1: cleanup a false positive warning
@ 2018-05-04 12:13 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2018-05-04 12:13 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Laurent Pinchart, linux-renesas-soc

With the new vsp1 code changes introduced by changeset
f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines dynamically"),
smatch complains with:
	drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru() error: we previously assumed 'pipe->bru' could be null (see line 180)

This is a false positive, as, if pipe->bru is NULL, the brx
var will be different, with ends by calling a code that will
set pipe->bru to another value.

Yet, cleaning this false positive is as easy as adding an explicit
check if pipe->bru is NULL.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index 095dc48aa25a..cb6b60843400 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
 		brx = &vsp1->brs->entity;
 
 	/* Switch BRx if needed. */
-	if (brx != pipe->brx) {
+	if (brx != pipe->brx || !pipe->brx) {
 		struct vsp1_entity *released_brx = NULL;
 
 		/* Release our BRx if we have one. */
-- 
2.17.0

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

* Re: [PATCH] media: vsp1: cleanup a false positive warning
  2018-05-04 12:13 ` Mauro Carvalho Chehab
  (?)
@ 2018-05-04 14:37 ` Geert Uytterhoeven
  2018-05-04 15:32   ` Mauro Carvalho Chehab
  -1 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2018-05-04 14:37 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab,
	Laurent Pinchart, Linux-Renesas

Hi Mauro,

On Fri, May 4, 2018 at 2:13 PM, Mauro Carvalho Chehab
<mchehab+samsung@kernel.org> wrote:
> With the new vsp1 code changes introduced by changeset
> f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines dynamically"),
> smatch complains with:
>         drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru() error: we previously assumed 'pipe->bru' could be null (see line 180)
>
> This is a false positive, as, if pipe->bru is NULL, the brx
> var will be different, with ends by calling a code that will
> set pipe->bru to another value.
>
> Yet, cleaning this false positive is as easy as adding an explicit
> check if pipe->bru is NULL.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Thanks for your patch!

s/bru/brx/

> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
>                 brx = &vsp1->brs->entity;
>
>         /* Switch BRx if needed. */
> -       if (brx != pipe->brx) {
> +       if (brx != pipe->brx || !pipe->brx) {
>                 struct vsp1_entity *released_brx = NULL;
>
>                 /* Release our BRx if we have one. */

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

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

* Re: [PATCH] media: vsp1: cleanup a false positive warning
  2018-05-04 14:37 ` Geert Uytterhoeven
@ 2018-05-04 15:32   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2018-05-04 15:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab,
	Laurent Pinchart, Linux-Renesas

Em Fri, 4 May 2018 16:37:23 +0200
Geert Uytterhoeven <geert@linux-m68k.org> escreveu:

> Hi Mauro,
> 
> On Fri, May 4, 2018 at 2:13 PM, Mauro Carvalho Chehab
> <mchehab+samsung@kernel.org> wrote:
> > With the new vsp1 code changes introduced by changeset
> > f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines dynamically"),
> > smatch complains with:
> >         drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru() error: we previously assumed 'pipe->bru' could be null (see line 180)
> >
> > This is a false positive, as, if pipe->bru is NULL, the brx
> > var will be different, with ends by calling a code that will
> > set pipe->bru to another value.
> >
> > Yet, cleaning this false positive is as easy as adding an explicit
> > check if pipe->bru is NULL.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>  
> 
> Thanks for your patch!
> 
> s/bru/brx/

Hah, yeah... there was a rename from bru->brx... 
I guess that confused me, as I saw this error before the renaming patch
(even though I wrote it to be applied after them) :-)

> 
> > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > @@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
> >                 brx = &vsp1->brs->entity;
> >
> >         /* Switch BRx if needed. */
> > -       if (brx != pipe->brx) {
> > +       if (brx != pipe->brx || !pipe->brx) {
> >                 struct vsp1_entity *released_brx = NULL;
> >
> >                 /* Release our BRx if we have one. */  
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 



Thanks,
Mauro

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

* Re: [PATCH] media: vsp1: cleanup a false positive warning
  2018-05-04 12:13 ` Mauro Carvalho Chehab
  (?)
  (?)
@ 2018-05-07 14:05 ` Laurent Pinchart
  2018-05-07 15:21   ` Mauro Carvalho Chehab
  -1 siblings, 1 reply; 7+ messages in thread
From: Laurent Pinchart @ 2018-05-07 14:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, linux-renesas-soc

Hi Mauro,

Thank you for the patch.

On Friday, 4 May 2018 15:13:58 EEST Mauro Carvalho Chehab wrote:
> With the new vsp1 code changes introduced by changeset
> f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines
> dynamically"), smatch complains with:
> 	drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru()
> error: we previously assumed 'pipe->bru' could be null (see line 180)
> 
> This is a false positive, as, if pipe->bru is NULL, the brx
> var will be different, with ends by calling a code that will
> set pipe->bru to another value.
> 
> Yet, cleaning this false positive is as easy as adding an explicit
> check if pipe->bru is NULL.

It's not very difficult indeed, but it really is a false positive. I think the 
proposed change decreases readability, the condition currently reads as "if 
(new brx != old brx)", why does smatch even flag that as an error ?

> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
> ---
>  drivers/media/platform/vsp1/vsp1_drm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c
> b/drivers/media/platform/vsp1/vsp1_drm.c index 095dc48aa25a..cb6b60843400
> 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device
> *vsp1, brx = &vsp1->brs->entity;
> 
>  	/* Switch BRx if needed. */
> -	if (brx != pipe->brx) {
> +	if (brx != pipe->brx || !pipe->brx) {
>  		struct vsp1_entity *released_brx = NULL;
> 
>  		/* Release our BRx if we have one. */

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] media: vsp1: cleanup a false positive warning
  2018-05-07 14:05 ` Laurent Pinchart
@ 2018-05-07 15:21   ` Mauro Carvalho Chehab
  2018-08-08 13:58     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2018-05-07 15:21 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, linux-renesas-soc

Em Mon, 07 May 2018 17:05:24 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Friday, 4 May 2018 15:13:58 EEST Mauro Carvalho Chehab wrote:
> > With the new vsp1 code changes introduced by changeset
> > f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines
> > dynamically"), smatch complains with:
> > 	drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru()
> > error: we previously assumed 'pipe->bru' could be null (see line 180)
> > 
> > This is a false positive, as, if pipe->bru is NULL, the brx
> > var will be different, with ends by calling a code that will
> > set pipe->bru to another value.
> > 
> > Yet, cleaning this false positive is as easy as adding an explicit
> > check if pipe->bru is NULL.  
> 
> It's not very difficult indeed, but it really is a false positive. I think the 
> proposed change decreases readability, the condition currently reads as "if 
> (new brx != old brx)", why does smatch even flag that as an error ?

I've no idea. Never studied smatch code. If you don't think that
this is a fix for it, do you have an alternative patch (either to
smatch or to vsp1)?

Regards,
Mauro

> 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
> > ---
> >  drivers/media/platform/vsp1/vsp1_drm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/vsp1/vsp1_drm.c
> > b/drivers/media/platform/vsp1/vsp1_drm.c index 095dc48aa25a..cb6b60843400
> > 100644
> > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > @@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device
> > *vsp1, brx = &vsp1->brs->entity;
> > 
> >  	/* Switch BRx if needed. */
> > -	if (brx != pipe->brx) {
> > +	if (brx != pipe->brx || !pipe->brx) {
> >  		struct vsp1_entity *released_brx = NULL;
> > 
> >  		/* Release our BRx if we have one. */  
> 



Thanks,
Mauro

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

* Re: [PATCH] media: vsp1: cleanup a false positive warning
  2018-05-07 15:21   ` Mauro Carvalho Chehab
@ 2018-08-08 13:58     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-08 13:58 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List, linux-renesas-soc

Em Mon, 7 May 2018 12:21:03 -0300
Mauro Carvalho Chehab <mchehab+samsung@kernel.org> escreveu:

> Em Mon, 07 May 2018 17:05:24 +0300
> Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:
> 
> > Hi Mauro,
> > 
> > Thank you for the patch.
> > 
> > On Friday, 4 May 2018 15:13:58 EEST Mauro Carvalho Chehab wrote:  
> > > With the new vsp1 code changes introduced by changeset
> > > f81f9adc4ee1 ("media: v4l: vsp1: Assign BRU and BRS to pipelines
> > > dynamically"), smatch complains with:
> > > 	drivers/media/platform/vsp1/vsp1_drm.c:262 vsp1_du_pipeline_setup_bru()
> > > error: we previously assumed 'pipe->bru' could be null (see line 180)
> > > 
> > > This is a false positive, as, if pipe->bru is NULL, the brx
> > > var will be different, with ends by calling a code that will
> > > set pipe->bru to another value.
> > > 
> > > Yet, cleaning this false positive is as easy as adding an explicit
> > > check if pipe->bru is NULL.    
> > 
> > It's not very difficult indeed, but it really is a false positive. I think the 
> > proposed change decreases readability, the condition currently reads as "if 
> > (new brx != old brx)", why does smatch even flag that as an error ?  
> 
> I've no idea. Never studied smatch code. If you don't think that
> this is a fix for it, do you have an alternative patch (either to
> smatch or to vsp1)?

Ping.

We're carrying this warning since the latest Kernel release. If you
don't have a better fix, let's apply it for 4.19. You may work on
a different solution if you think you'll be able to either patch
smatch in order to identify such complex logic or do something else
at the vsp1 code to simplify the logic on future Kernel revisions.

> 
> Regards,
> Mauro
> 
> >   
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
> > > ---
> > >  drivers/media/platform/vsp1/vsp1_drm.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/vsp1/vsp1_drm.c
> > > b/drivers/media/platform/vsp1/vsp1_drm.c index 095dc48aa25a..cb6b60843400
> > > 100644
> > > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > > @@ -185,7 +185,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device
> > > *vsp1, brx = &vsp1->brs->entity;
> > > 
> > >  	/* Switch BRx if needed. */
> > > -	if (brx != pipe->brx) {
> > > +	if (brx != pipe->brx || !pipe->brx) {
> > >  		struct vsp1_entity *released_brx = NULL;
> > > 
> > >  		/* Release our BRx if we have one. */    
> >   
> 
> 
> 
> Thanks,
> Mauro



Thanks,
Mauro

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

end of thread, other threads:[~2018-08-08 16:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 12:13 [PATCH] media: vsp1: cleanup a false positive warning Mauro Carvalho Chehab
2018-05-04 12:13 ` Mauro Carvalho Chehab
2018-05-04 14:37 ` Geert Uytterhoeven
2018-05-04 15:32   ` Mauro Carvalho Chehab
2018-05-07 14:05 ` Laurent Pinchart
2018-05-07 15:21   ` Mauro Carvalho Chehab
2018-08-08 13:58     ` Mauro Carvalho Chehab

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.