regulator: wm831x-dcdc: Use pointer after NULL check
Hello charles,
Quoted 5 lines
Quoted 5 lines
pdata is used before NULL check, so it looks misleading. If pdata validation is required then we have to first check for pdata validation, then calculate id, and then second check for pdata->dcdc[id].
Quoted 8 lines
Quoted 4 lines
and it is better to use !pointer than (pointer == NULL)
Signed-off-by Maninder Singh <[email protected]>---
The patch basically looks fine, but it feels a bit like needless churn. The current code is perfectly correct and feels clear enough to me.
Reason for patch is we are checking a pointer which is already dereferenced before NULL check, which looks misleading.
If we know code is working correctly, Then we may simply drop NULL check, rather than these changes.
Thanks,
Maninder ........ÿôèº{.nÇ+‰·Ÿ®‰†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºÊ‡Ú™ë,j¢f£¢·hš�ï�êÿ‘êçz_è®(階ŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨èÚ&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿÃÿ¶ìÿ¢¸?–I¥
Quoted 11 lines · Maninder Singh
Hello charles,
Quoted 9 lines
Quoted 9 lines
pdata is used before NULL check, so it looks misleading. If pdata validation is required then we have to first check for pdata validation, then calculate id, and then second check for pdata->dcdc[id].
and it is better to use !pointer than (pointer == NULL)
Signed-off-by Maninder Singh <[email protected]>---
Quoted 8 lines
Quoted 3 lines
The patch basically looks fine, but it feels a bit like needless churn. The current code is perfectly correct and feels clear enough to me.
Reason for patch is we are checking a pointer which is already dereferenced before NULL check, which looks misleading.
If we know code is working correctly, Then we may simply drop NULL check, rather than these changes.
You can't drop the NULL check because then we might dereference a NULL pointer. ARRAY_SIZE(pdata->dcdc) is perfectly save because sizeof only works on types so no actual dereference takes place.
Thanks,
Charles