summaryrefslogtreecommitdiffstats
path: root/drivers/counter
diff options
context:
space:
mode:
authorTom Rix <trix@redhat.com>2022-03-15 15:38:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-18 14:04:30 +0100
commit04c633873c01ce0591b05404af6481100871a921 (patch)
tree54d6a1b06e891a4e96fb723d409be89bf7f9518d /drivers/counter
parentcac229ed3fde01c7dd488032b77a8f7459362660 (diff)
downloadlinux-04c633873c01ce0591b05404af6481100871a921.tar.bz2
counter: add defaults to switch-statements
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. Link: https://lore.kernel.org/r/20220227161746.82776-1-trix@redhat.com Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Syed Nayyar Waris <syednwaris@gmail.com> Signed-off-by: Tom Rix <trix@redhat.com> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Link: https://lore.kernel.org/r/b98d1a3ed4b0b324b261b23defd1bdddddba4d44.1647373009.git.vilhelm.gray@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/counter')
-rw-r--r--drivers/counter/counter-chrdev.c4
1 files changed, 4 insertions, 0 deletions
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;