regmap: debugfs: Fix compilation warning
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review
Quoted 4 lines · Vincent Stehlé
This fixes the following compilation warning:
(quoted diff) +1
-1- unsigned int i, ret; + unsigned int i, ret = 0;
This sort of fix is not a good idea, you're just shutting the warning up without any sort of analysis explaining why it's generated in error. If it's generating a spurious error that's a compiler bug.
On 01/22/2013 07:41 AM, Mark Brown wrote:
(..)
Quoted 4 lines
This sort of fix is not a good idea, you're just shutting the warning up without any sort of analysis explaining why it's generated in error. If it's generating a spurious error that's a compiler bug.
In the regmap_debugfs_get_dump_start() function control flow, I think the compiler cannot know for sure that the list_for_each_entry() iterates at least once.:
regmap_debugfs_get_dump_start()
{
unsigned int ret;
<snip some code, which does not touch ret>
list_for_each_entry() {
<snip some code>
ret = <value>;
}
return ret;
}Do you think there is a way to "mark" the list_for_each_entry() as iterating at least once? an __attribute__ maybe?
Best regards,
V.
Quoted 2 lines · Vincent Stehlé
Do you think there is a way to "mark" the
list_for_each_entry()as iterating at least once? an__attribute__maybe?
No - but are you sure that's true?
Quoted 6 lines · Mark Brown
Quoted 2 lines · Vincent Stehlé
Do you think there is a way to "mark" the
list_for_each_entry()as iterating at least once? an__attribute__maybe?No - but are you sure that's true?
If you mean "am I sure the loop iterates at least once", then yes, as we have an explicit check just before the concerned list_for_each_entry():
/*
* This should never happen; we return above if we fail to
* allocate and we should never be in this code if there are
* no registers at all.
*/
if (list_empty(&map->debugfs_off_cache)) {
WARN_ON(list_empty(&map->debugfs_off_cache));
return base;
}Best regards,
V.
Quoted 2 lines · Vincent Stehlé
If you mean "am I sure the loop iterates at least once", then yes, as we have an explicit check just before the concerned
list_for_each_entry():
So, I hadn't realised this was triggered by a new compiler version - Arnd just tried the same bodge. I've committed a workaround for the compiler which avoids the problems that setting 0 will have and allows the flow analyis to run where it can.