Skip to content

Commit

Permalink
media: v4l2-fwnode: simplify v4l2_fwnode_reference_parse_int_props()
Browse files Browse the repository at this point in the history
The logic at v4l2_fwnode_reference_parse_int_props() is somewhat
complex and violates Linux coding style, as it does multiple
statements on a single line. That makes static analyzers to
be confused, as warned by smatch:

	drivers/media/v4l2-core/v4l2-fwnode.c:832 v4l2_fwnode_reference_parse_int_props() warn: passing zero to 'PTR_ERR'

Simplify the logic, in order to make clearer about what happens
when v4l2_fwnode_reference_get_int_prop() returns an error.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Mauro Carvalho Chehab committed Apr 17, 2018
1 parent 76d8124 commit 9879c9d
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions drivers/media/v4l2-core/v4l2-fwnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,17 +819,25 @@ static int v4l2_fwnode_reference_parse_int_props(
unsigned int index;
int ret;

for (index = 0; !IS_ERR((fwnode = v4l2_fwnode_reference_get_int_prop(
dev_fwnode(dev), prop, index, props,
nprops))); index++)
index = 0;
do {
fwnode = v4l2_fwnode_reference_get_int_prop(dev_fwnode(dev),
prop, index,
props, nprops);
if (IS_ERR(fwnode)) {
/*
* Note that right now both -ENODATA and -ENOENT may
* signal out-of-bounds access. Return the error in
* cases other than that.
*/
if (PTR_ERR(fwnode) != -ENOENT &&
PTR_ERR(fwnode) != -ENODATA)
return PTR_ERR(fwnode);
break;
}
fwnode_handle_put(fwnode);

/*
* Note that right now both -ENODATA and -ENOENT may signal
* out-of-bounds access. Return the error in cases other than that.
*/
if (PTR_ERR(fwnode) != -ENOENT && PTR_ERR(fwnode) != -ENODATA)
return PTR_ERR(fwnode);
index++;
} while (1);

ret = v4l2_async_notifier_realloc(notifier,
notifier->num_subdevs + index);
Expand Down

0 comments on commit 9879c9d

Please sign in to comment.