linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: pvrusb2: fix parsing error
@ 2020-08-16  6:49 Tong Zhang
  2020-08-19 14:38 ` Hans Verkuil
  0 siblings, 1 reply; 9+ messages in thread
From: Tong Zhang @ 2020-08-16  6:49 UTC (permalink / raw)
  To: linux-kernel, linux-media, mchehab, isely; +Cc: ztong0001

pvr2_std_str_to_id() returns 0 on failure and 1 on success,
however the caller is checking failure case using <0

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1cfb7cf64131..db5aa66c1936 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -867,7 +867,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
 	int ret;
 	v4l2_std_id id;
 	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
-	if (ret < 0) return ret;
+	if (ret == 0)
+		return ret;
 	if (mskp) *mskp = id;
 	if (valp) *valp = id;
 	return 0;
-- 
2.25.1


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

* Re: [PATCH] media: pvrusb2: fix parsing error
  2020-08-16  6:49 [PATCH] media: pvrusb2: fix parsing error Tong Zhang
@ 2020-08-19 14:38 ` Hans Verkuil
  2020-08-19 16:37   ` Tong Zhang
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Hans Verkuil @ 2020-08-19 14:38 UTC (permalink / raw)
  To: Tong Zhang, linux-kernel, linux-media, mchehab, isely

Hi Tong,

On 16/08/2020 08:49, Tong Zhang wrote:
> pvr2_std_str_to_id() returns 0 on failure and 1 on success,
> however the caller is checking failure case using <0
> 
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> index 1cfb7cf64131..db5aa66c1936 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> @@ -867,7 +867,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
>  	int ret;
>  	v4l2_std_id id;
>  	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
> -	if (ret < 0) return ret;
> +	if (ret == 0)
> +		return ret;

But now you return 0 instead of an error when pvr2_std_str_to_id failed.

Just do this:

	if (!pvr2_std_str_to_id(&id,bufPtr,bufSize))
		return -EINVAL;

And you can drop the ret variable as well since that's no longer needed.

Regards,

	Hans

>  	if (mskp) *mskp = id;
>  	if (valp) *valp = id;
>  	return 0;
> 


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

* Re: [PATCH] media: pvrusb2: fix parsing error
  2020-08-19 14:38 ` Hans Verkuil
@ 2020-08-19 16:37   ` Tong Zhang
  2020-08-19 21:25   ` [PATCH v2] " Tong Zhang
  2020-08-19 21:26   ` [PATCH] " Tong Zhang
  2 siblings, 0 replies; 9+ messages in thread
From: Tong Zhang @ 2020-08-19 16:37 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-kernel, linux-media, mchehab, isely

Hi Hans,
Thank you very much for your comments.
The change looks good to me.
 -- However, I'm not quite familiar with the patch submission process
in this situation.
Would you like to go ahead and create an improved version?
Thanks,
- Tong

On Wed, Aug 19, 2020 at 10:38 AM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> Hi Tong,
>
> On 16/08/2020 08:49, Tong Zhang wrote:
> > pvr2_std_str_to_id() returns 0 on failure and 1 on success,
> > however the caller is checking failure case using <0
> >
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> > ---
> >  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > index 1cfb7cf64131..db5aa66c1936 100644
> > --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > @@ -867,7 +867,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
> >       int ret;
> >       v4l2_std_id id;
> >       ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
> > -     if (ret < 0) return ret;
> > +     if (ret == 0)
> > +             return ret;
>
> But now you return 0 instead of an error when pvr2_std_str_to_id failed.
>
> Just do this:
>
>         if (!pvr2_std_str_to_id(&id,bufPtr,bufSize))
>                 return -EINVAL;
>
> And you can drop the ret variable as well since that's no longer needed.
>
> Regards,
>
>         Hans
>
> >       if (mskp) *mskp = id;
> >       if (valp) *valp = id;
> >       return 0;
> >
>

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

* [PATCH v2] media: pvrusb2: fix parsing error
  2020-08-19 14:38 ` Hans Verkuil
  2020-08-19 16:37   ` Tong Zhang
@ 2020-08-19 21:25   ` Tong Zhang
  2020-08-20 11:44     ` Hans Verkuil
  2020-08-19 21:26   ` [PATCH] " Tong Zhang
  2 siblings, 1 reply; 9+ messages in thread
From: Tong Zhang @ 2020-08-19 21:25 UTC (permalink / raw)
  To: isely, mchehab, linux-media, linux-kernel, hverkuil; +Cc: ztong0001

pvr2_std_str_to_id() returns 0 on failure and 1 on success,
however the caller is checking failure case using <0

Co-developed-by: Hans Verkuil<hverkuil@xs4all.nl>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---

v2: return -EINVAL as suggested by Hans Verkuil<hverkuil@xs4all.nl>.
I also rebased the code on v5.9-rc1.

 drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1cfb7cf64131..6a444cb27e31 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -866,8 +866,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
 {
 	int ret;
 	v4l2_std_id id;
-	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
-	if (ret < 0) return ret;
+	if (!pvr2_std_str_to_id(&id, bufPtr, bufSize))
+		return -EINVAL;
 	if (mskp) *mskp = id;
 	if (valp) *valp = id;
 	return 0;
-- 
2.25.1


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

* Re: [PATCH] media: pvrusb2: fix parsing error
  2020-08-19 14:38 ` Hans Verkuil
  2020-08-19 16:37   ` Tong Zhang
  2020-08-19 21:25   ` [PATCH v2] " Tong Zhang
@ 2020-08-19 21:26   ` Tong Zhang
  2 siblings, 0 replies; 9+ messages in thread
From: Tong Zhang @ 2020-08-19 21:26 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-kernel, linux-media, mchehab, isely

Hi Hans,
I just made another patch as suggested, I think I need some more work
on the commit log.
Please take a look and let me know -
Thanks,
- Tong

On Wed, Aug 19, 2020 at 10:38 AM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> Hi Tong,
>
> On 16/08/2020 08:49, Tong Zhang wrote:
> > pvr2_std_str_to_id() returns 0 on failure and 1 on success,
> > however the caller is checking failure case using <0
> >
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> > ---
> >  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > index 1cfb7cf64131..db5aa66c1936 100644
> > --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > @@ -867,7 +867,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
> >       int ret;
> >       v4l2_std_id id;
> >       ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
> > -     if (ret < 0) return ret;
> > +     if (ret == 0)
> > +             return ret;
>
> But now you return 0 instead of an error when pvr2_std_str_to_id failed.
>
> Just do this:
>
>         if (!pvr2_std_str_to_id(&id,bufPtr,bufSize))
>                 return -EINVAL;
>
> And you can drop the ret variable as well since that's no longer needed.
>
> Regards,
>
>         Hans
>
> >       if (mskp) *mskp = id;
> >       if (valp) *valp = id;
> >       return 0;
> >
>

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

* Re: [PATCH v2] media: pvrusb2: fix parsing error
  2020-08-19 21:25   ` [PATCH v2] " Tong Zhang
@ 2020-08-20 11:44     ` Hans Verkuil
  2020-08-20 16:52       ` [PATCH v3] " Tong Zhang
  2020-08-20 16:55       ` [PATCH v2] " Tong Zhang
  0 siblings, 2 replies; 9+ messages in thread
From: Hans Verkuil @ 2020-08-20 11:44 UTC (permalink / raw)
  To: Tong Zhang, isely, mchehab, linux-media, linux-kernel

On 19/08/2020 23:25, Tong Zhang wrote:
> pvr2_std_str_to_id() returns 0 on failure and 1 on success,
> however the caller is checking failure case using <0
> 
> Co-developed-by: Hans Verkuil<hverkuil@xs4all.nl>
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
> 
> v2: return -EINVAL as suggested by Hans Verkuil<hverkuil@xs4all.nl>.
> I also rebased the code on v5.9-rc1.
> 
>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> index 1cfb7cf64131..6a444cb27e31 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> @@ -866,8 +866,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
>  {
>  	int ret;

This is no longer used, so can be removed.

And if I compile this patch I get this warning:

drivers/media/usb/pvrusb2/pvrusb2-hdw.c: In function ‘ctrl_std_sym_to_val’:
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:867:6: warning: unused variable ‘ret’ [-Wunused-variable]
  867 |  int ret;
      |      ^~~

Always compile-test before posting a patch :-)

Regards,

	Hans

>  	v4l2_std_id id;
> -	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
> -	if (ret < 0) return ret;
> +	if (!pvr2_std_str_to_id(&id, bufPtr, bufSize))
> +		return -EINVAL;
>  	if (mskp) *mskp = id;
>  	if (valp) *valp = id;
>  	return 0;
> 


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

* [PATCH v3] media: pvrusb2: fix parsing error
  2020-08-20 11:44     ` Hans Verkuil
@ 2020-08-20 16:52       ` Tong Zhang
  2020-08-20 16:55         ` Mike Isely
  2020-08-20 16:55       ` [PATCH v2] " Tong Zhang
  1 sibling, 1 reply; 9+ messages in thread
From: Tong Zhang @ 2020-08-20 16:52 UTC (permalink / raw)
  To: isely, mchehab, linux-media, linux-kernel, hverkuil; +Cc: ztong0001

pvr2_std_str_to_id() returns 0 on failure and 1 on success,
however the caller is checking failure case using <0

Co-developed-by: Hans Verkuil<hverkuil@xs4all.nl>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---

v2: return -EINVAL as suggested by Hans Verkuil<hverkuil@xs4all.nl>.
I also rebased the code on v5.9-rc1.
v3: remove unused variable

 drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1cfb7cf64131..f4a727918e35 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -864,10 +864,9 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
 			       const char *bufPtr,unsigned int bufSize,
 			       int *mskp,int *valp)
 {
-	int ret;
 	v4l2_std_id id;
-	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
-	if (ret < 0) return ret;
+	if (!pvr2_std_str_to_id(&id, bufPtr, bufSize))
+		return -EINVAL;
 	if (mskp) *mskp = id;
 	if (valp) *valp = id;
 	return 0;
-- 
2.25.1


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

* Re: [PATCH v3] media: pvrusb2: fix parsing error
  2020-08-20 16:52       ` [PATCH v3] " Tong Zhang
@ 2020-08-20 16:55         ` Mike Isely
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Isely @ 2020-08-20 16:55 UTC (permalink / raw)
  To: Tong Zhang
  Cc: mchehab, linux-media, Linux Kernel Mailing List, Hans Verkuil,
	Mike Isely at pobox


Acked-by: Mike Isely <isely@pobox.com>

On Thu, 20 Aug 2020, Tong Zhang wrote:

> pvr2_std_str_to_id() returns 0 on failure and 1 on success,
> however the caller is checking failure case using <0
> 
> Co-developed-by: Hans Verkuil<hverkuil@xs4all.nl>
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
> 
> v2: return -EINVAL as suggested by Hans Verkuil<hverkuil@xs4all.nl>.
> I also rebased the code on v5.9-rc1.
> v3: remove unused variable
> 
>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> index 1cfb7cf64131..f4a727918e35 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> @@ -864,10 +864,9 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
>  			       const char *bufPtr,unsigned int bufSize,
>  			       int *mskp,int *valp)
>  {
> -	int ret;
>  	v4l2_std_id id;
> -	ret = pvr2_std_str_to_id(&id,bufPtr,bufSize);
> -	if (ret < 0) return ret;
> +	if (!pvr2_std_str_to_id(&id, bufPtr, bufSize))
> +		return -EINVAL;
>  	if (mskp) *mskp = id;
>  	if (valp) *valp = id;
>  	return 0;
> 

-- 

Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

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

* Re: [PATCH v2] media: pvrusb2: fix parsing error
  2020-08-20 11:44     ` Hans Verkuil
  2020-08-20 16:52       ` [PATCH v3] " Tong Zhang
@ 2020-08-20 16:55       ` Tong Zhang
  1 sibling, 0 replies; 9+ messages in thread
From: Tong Zhang @ 2020-08-20 16:55 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: isely, mchehab, linux-media, linux-kernel

On Thu, Aug 20, 2020 at 7:44 AM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> > diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > index 1cfb7cf64131..6a444cb27e31 100644
> > --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> > @@ -866,8 +866,8 @@ static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr,
> >  {
> >       int ret;
>
> This is no longer used, so can be removed.
>

Thank you Hans.
I removed the unused variable and did a compilation test for the new patch.
Thanks again for being patient guiding me through this. :-)

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

end of thread, other threads:[~2020-08-20 17:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16  6:49 [PATCH] media: pvrusb2: fix parsing error Tong Zhang
2020-08-19 14:38 ` Hans Verkuil
2020-08-19 16:37   ` Tong Zhang
2020-08-19 21:25   ` [PATCH v2] " Tong Zhang
2020-08-20 11:44     ` Hans Verkuil
2020-08-20 16:52       ` [PATCH v3] " Tong Zhang
2020-08-20 16:55         ` Mike Isely
2020-08-20 16:55       ` [PATCH v2] " Tong Zhang
2020-08-19 21:26   ` [PATCH] " Tong Zhang

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).