提交 a3471469 编写于 作者: R Russell King 提交者: Mark Brown

regmap: regmap: avoid spurious warning in regmap_read_debugfs

Gcc warns about the case where regmap_read_debugfs tries to walk an
empty map->debugfs_off_cache list, which would results in uninitialized
variable getting returned, if we hadn't checked the same condition
just before that.

After an originally suggested inferior patch from Arnd Bergmann,
this is the solution that Russell King came up with, sidestepping
the problem by merging the error case for an empty list with the
normal path.

Without this patch, building mxs_defconfig results in:

drivers/base/regmap/regmap-debugfs.c: In function 'regmap_read_debugfs':
drivers/base/regmap/regmap-debugfs.c:147:9: : warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
Reported-by: NVincent Stehle <v-stehle@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 949db153
...@@ -128,10 +128,8 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, ...@@ -128,10 +128,8 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
* allocate and we should never be in this code if there are * allocate and we should never be in this code if there are
* no registers at all. * no registers at all.
*/ */
if (list_empty(&map->debugfs_off_cache)) { WARN_ON(list_empty(&map->debugfs_off_cache));
WARN_ON(list_empty(&map->debugfs_off_cache)); ret = base;
return base;
}
/* Find the relevant block */ /* Find the relevant block */
list_for_each_entry(c, &map->debugfs_off_cache, list) { list_for_each_entry(c, &map->debugfs_off_cache, list) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册