media: pvrusb2: fix parsing error
Subsystems (2)
PATCH 1/1 media: pvrusb2: fix parsing error
pvr2_std_str_to_id() returns 0 on failure and 1 on success, however the caller is checking failure case using <0
--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2 -1
@@ -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 ;
Signature · 1 line
2.25.1
Hi Tong,
Quoted 13 lines · Tong Zhang
pvr2_std_str_to_id()returns 0 on failure and 1 on success, however the caller is checking failure case using <0Signed-off-by Tong Zhang <[email protected]>--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0
drivers/media/usb/pvrusb2/pvrusb2-hdw.c static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr, · line 871
Quoted 6 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2
-1@@ -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
Quoted 4 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0if (mskp) *mskp = id;if (valp) *valp = id;return 0 ;
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
Quoted 42 lines · Hans Verkuil
Hi Tong,
Quoted 13 lines · Tong Zhang
pvr2_std_str_to_id()returns 0 on failure and 1 on success, however the caller is checking failure case using <0Signed-off-by Tong Zhang <[email protected]>--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0drivers/media/usb/pvrusb2/pvrusb2-hdw.c static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr, · line 871
Quoted 6 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2
-1@@ -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_idfailed.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
Quoted 4 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0if (mskp) *mskp = id;if (valp) *valp = id;return 0 ;
PATCH v2 1/1 media: pvrusb2: fix parsing error
In reply to Hans Verkuilpvr2_std_str_to_id() returns 0 on failure and 1 on success, however the caller is checking failure case using <0
---
v2: return -EINVAL as suggested by Hans Verkuil<[email protected]>. I also rebased the code on v5.9-rc1.
drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2 -2
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 18 lines · Tong Zhang
pvr2_std_str_to_id()returns 0 on failure and 1 on success, however the caller is checking failure case using <0Co-developed-by Hans Verkuil<[email protected]>Signed-off-by Tong Zhang <[email protected]>---
v2: return
-EINVALas suggested by Hans Verkuil<[email protected]>. I also rebased the code on v5.9-rc1.drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0
drivers/media/usb/pvrusb2/pvrusb2-hdw.c static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr, · line 867
Quoted 2 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0@@ -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
Quoted 9 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2
-2v4l2_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 ;
PATCH v3 1/1 media: pvrusb2: fix parsing error
pvr2_std_str_to_id() returns 0 on failure and 1 on success, however the caller is checking failure case using <0
---
v2: return -EINVAL as suggested by Hans Verkuil<[email protected]>. 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(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2 -3
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 32 lines · Tong Zhang
pvr2_std_str_to_id()returns 0 on failure and 1 on success, however the caller is checking failure case using <0Co-developed-by Hans Verkuil<[email protected]>Signed-off-by Tong Zhang <[email protected]>---
v2: return
-EINVALas suggested by Hans Verkuil<[email protected]>. I also rebased the code on v5.9-rc1.
v3: remove unused variabledrivers/media/usb/pvrusb2/pvrusb2-hdw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2
-3@@ -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 ;
Signature · 3 lines
Mike Isely isely @ isely (dot) net PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8
Quoted 11 lines · Hans Verkuil
drivers/media/usb/pvrusb2/pvrusb2-hdw.c static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr, · line 867
Quoted 8 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0@@ -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. :-)
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
Quoted 42 lines · Hans Verkuil
Hi Tong,
Quoted 13 lines · Tong Zhang
pvr2_std_str_to_id()returns 0 on failure and 1 on success, however the caller is checking failure case using <0Signed-off-by Tong Zhang <[email protected]>--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0drivers/media/usb/pvrusb2/pvrusb2-hdw.c static int ctrl_std_sym_to_val(struct pvr2_ctrl *cptr, · line 871
Quoted 6 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2
-1@@ -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_idfailed.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
Quoted 4 lines
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +0
-0if (mskp) *mskp = id;if (valp) *valp = id;return 0 ;