From: Tom Rix <[email protected]>
Clang static analysis reports this representative problem
counter-chrdev.c:482:3: warning: Undefined or garbage value
returned to caller
return ret;
^~~~~~~~~~
counter_get_data() has a multilevel switches, some without
defaults, so ret is sometimes not set.
Add returning -EINVAL similar to other defaults.
Signed-off-by: Tom Rix <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: William Breathitt Gray <[email protected]>
---
drivers/counter/counter-chrdev.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index b7c62f957a6a..69d340be9c93 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter,
case COUNTER_SCOPE_COUNT:
ret = comp->count_u8_read(counter, parent, &value_u8);
break;
+ default:
+ return -EINVAL;
}
*value = value_u8;
return ret;
@@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter,
case COUNTER_SCOPE_COUNT:
ret = comp->count_u32_read(counter, parent, &value_u32);
break;
+ default:
+ return -EINVAL;
}
*value = value_u32;
return ret;
--
2.35.1
On Wed, Mar 16, 2022 at 12:43 PM William Breathitt Gray
<[email protected]> wrote:
>
> From: Tom Rix <[email protected]>
>
> Clang static analysis reports this representative problem
> counter-chrdev.c:482:3: warning: Undefined or garbage value
> returned to caller
> return ret;
> ^~~~~~~~~~
>
> counter_get_data() has a multilevel switches, some without
> defaults, so ret is sometimes not set.
> Add returning -EINVAL similar to other defaults.
>
> Signed-off-by: Tom Rix <[email protected]>
> Reviewed-by: Jonathan Cameron <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: William Breathitt Gray <[email protected]>
> ---
> drivers/counter/counter-chrdev.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
> index b7c62f957a6a..69d340be9c93 100644
> --- a/drivers/counter/counter-chrdev.c
> +++ b/drivers/counter/counter-chrdev.c
> @@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter,
> case COUNTER_SCOPE_COUNT:
> ret = comp->count_u8_read(counter, parent, &value_u8);
> break;
> + default:
> + return -EINVAL;
> }
> *value = value_u8;
> return ret;
> @@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter,
> case COUNTER_SCOPE_COUNT:
> ret = comp->count_u32_read(counter, parent, &value_u32);
> break;
> + default:
> + return -EINVAL;
> }
> *value = value_u32;
> return ret;
> --
> 2.35.1
>
Acked-by: Syed Nayyar Waris <[email protected]>
Thanks