On Tue, Mar 02, 2021 at 04:57:56PM +0800, Yang Li wrote: > These functions always return '0' and no callers use the return > value. So make it a void function.
The reasoning needs to go the other way around: you can make a function return void iff all callees also return void and don't do BUG_ON instead of proper error handling. Which in this case does not hold, because the function itself still does BUG_ON. > It fixes the following warning detected by coccinelle: > ./fs/btrfs/disk-io.c:4522:5-8: Unneeded variable: "ret". Return "0" on > line 4530 Yeah tools can identify the simple cases but fixing that properly needs to extend to the whole callgraph and understand all the contexts where local data are undone and errors propagated up the callchanin.