media: v4l2-ctrls: Set error v4l2_ctrl_new_fwnode_properties consistently
PATCH 1/1 media: v4l2-ctrls: Set error v4l2_ctrl_new_fwnode_properties consistently
The vast majority of the callers of v4l2_ctrl_new_fwnode_properties() do check the returned error code but the function does not set the control handler's error on failure. This will make error handling more complicated and prone for bugs.
Always assign the control handler's error field on error in v4l2_ctrl_new_fwnode_properties().
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 3 ++- include/media/v4l2-ctrls.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls-core.c +2 -1
@@ -2780,7 +2780,8 @@ int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, orientation_ctrl =V4L2_CAMERA_ORIENTATION_EXTERNAL ;break ;default : -return -EINVAL ; + hdl->error = -EINVAL ; +return hdl->error; } if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, V4L2_CID_CAMERA_ORIENTATION,
include/media/v4l2-ctrls.h +3 -0
@@ -1581,6 +1581,9 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);* not overwritten. Callers should register the controls they want to handle * themselves before calling this function. * +* This function will set the control handler's error field on failure, just as +* other functions adding controls to the handler. +* * Return: 0 on success, a negative error code on failure. */ int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
Signature · 1 line
2.47.3
Hi Sakari
Quoted 9 lines · Sakari Ailus
The vast majority of the callers of
v4l2_ctrl_new_fwnode_properties()do check the returned error code but the function does not set the control handler's error on failure. This will make error handling more complicated and prone for bugs.Always assign the control handler's error field on error in
v4l2_ctrl_new_fwnode_properties().Signed-off-by Sakari Ailus <[email protected]>
I think it makes sense indeed
Thanks
j
Quoted 37 lines
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 3 ++- include/media/v4l2-ctrls.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-ctrls-core.c +2
-1@@ -2780,7 +2780,8 @@ int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, orientation_ctrl =V4L2_CAMERA_ORIENTATION_EXTERNAL ;break ;default : -return -EINVAL ; + hdl->error = -EINVAL ; +return hdl->error; } if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, V4L2_CID_CAMERA_ORIENTATION,include/media/v4l2-ctrls.h +3
-1@@ -1581,6 +1581,9 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);* not overwritten. Callers should register the controls they want to handle * themselves before calling this function. * +* This function will set the control handler's error field on failure, just as +* other functions adding controls to the handler. +* * Return: 0 on success, a negative error code on failure. */ int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, --2.47.3