提交 04c63387 编写于 作者: T Tom Rix 提交者: Greg Kroah-Hartman

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.comReviewed-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: NSyed Nayyar Waris <syednwaris@gmail.com>
Signed-off-by: NTom Rix <trix@redhat.com>
Signed-off-by: NWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/b98d1a3ed4b0b324b261b23defd1bdddddba4d44.1647373009.git.vilhelm.gray@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 cac229ed
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册