NACK: [PATCH] x86/platform/olpc: remove duplicated check on node == -1

From: Colin Ian King
Date: Sun Dec 09 2018 - 12:31:02 EST


On 09/12/2018 17:13, Christophe JAILLET wrote:
> Le 09/12/2018 Ã 16:01, Colin King a ÃcritÂ:
>> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>>
>> Currently the node == -1 check is being performed twice, the
>> second check is redundant and can be removed. Fix this by
>> removing the redundant second check and moving the first check
>> into a combined check with the result from the olpc_ofw call.
>>
>> Detected by cppcheck:
>> Identical condition '(s32)node==-1', second condition is always false
>>
>> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>> ---
>> Â arch/x86/platform/olpc/olpc_dt.c | 5 +----
>> Â 1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/platform/olpc/olpc_dt.c
>> b/arch/x86/platform/olpc/olpc_dt.c
>> index b4ab779f1d47..658363ec3ff3 100644
>> --- a/arch/x86/platform/olpc/olpc_dt.c
>> +++ b/arch/x86/platform/olpc/olpc_dt.c
>> @@ -28,10 +28,7 @@ static phandle __init olpc_dt_getsibling(phandle node)
>> ÂÂÂÂÂ const void *args[] = { (void *)node };
>> ÂÂÂÂÂ void *res[] = { &node };
>> Â -ÂÂÂ if ((s32)node == -1)
>> -ÂÂÂÂÂÂÂ return 0;
>> -
>> -ÂÂÂ if (olpc_ofw("peer", args, res) || (s32)node == -1)
>> +ÂÂÂ if (((s32)node == -1) || olpc_ofw("peer", args, res))
>> ÂÂÂÂÂÂÂÂÂ return 0;
>> Â ÂÂÂÂÂ return node;
>
> 'res' is { &node }
>
> Could 'node' be modified by 'olpc_ofw(..., res)' and set to -1?
>
> In other words, I'm not sure that the 2nd check is a redundant here.

Quite right. My mistake. Urgh.

>
> Just my 2c,
>
> CJ
>