linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: \\ 答复: [PATCH] of: del redundant type conversion
@ 2019-04-11  1:51 xiaojiangfeng
  2019-04-11  4:13 ` Frank Rowand
  0 siblings, 1 reply; 4+ messages in thread
From: xiaojiangfeng @ 2019-04-11  1:51 UTC (permalink / raw)
  To: Frank Rowand, robh+dt, robh; +Cc: devicetree, linux-kernel

My pleasure.

I am very new to sparse.

I guess the warning is caused by the macro min.

Then I submitted my changes.

Thanks for code review.


-----邮件原件-----
发件人: Frank Rowand [mailto:frowand.list@gmail.com] 
发送时间: 2019年4月11日 2:50
收件人: xiaojiangfeng <xiaojiangfeng@huawei.com>; robh+dt@kernel.org; robh@kernel.org
抄送: devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] of: del redundant type conversion

On 4/10/19 1:29 AM, xiaojiangfeng wrote:
> The type of variable l in early_init_dt_scan_chosen is int, there is 
> no need to convert to int.
> 
> Signed-off-by: xiaojiangfeng <xiaojiangfeng@huawei.com>
> ---
>  drivers/of/fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 
> 4734223..de893c9 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -1091,7 +1091,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
>  	/* Retrieve command line */
>  	p = of_get_flat_dt_prop(node, "bootargs", &l);
>  	if (p != NULL && l > 0)
> -		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
> +		strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
>  
>  	/*
>  	 * CONFIG_CMDLINE is meant to be a default in case nothing else
> 

Thanks for catching the redundant cast.

There is a second problem detected by sparse on that line:

  drivers/of/fdt.c:1094:34: warning: expression using sizeof(void)

Can you please fix both issues?

Thanks,

Frank

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \\ 答复: [PATCH] of: del redundant type conversion
  2019-04-11  1:51 \\ 答复: [PATCH] of: del redundant type conversion xiaojiangfeng
@ 2019-04-11  4:13 ` Frank Rowand
  2019-04-11  4:21   ` Frank Rowand
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Rowand @ 2019-04-11  4:13 UTC (permalink / raw)
  To: xiaojiangfeng, robh+dt, robh; +Cc: devicetree, linux-kernel

On 4/10/19 6:51 PM, xiaojiangfeng wrote:
> My pleasure.
> 
> I am very new to sparse.
> 
> I guess the warning is caused by the macro min.

I think the warning is likely because the type of data is 'void *'.

Removing the (int) cast is a good fix, but does not resolve
the sparse warning.

-Frank


> Then I submitted my changes.
> 
> Thanks for code review.
> 
> 
> -----邮件原件-----
> 发件人: Frank Rowand [mailto:frowand.list@gmail.com] 
> 发送时间: 2019年4月11日 2:50
> 收件人: xiaojiangfeng <xiaojiangfeng@huawei.com>; robh+dt@kernel.org; robh@kernel.org
> 抄送: devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> 主题: Re: [PATCH] of: del redundant type conversion
> 
> On 4/10/19 1:29 AM, xiaojiangfeng wrote:
>> The type of variable l in early_init_dt_scan_chosen is int, there is 
>> no need to convert to int.
>>
>> Signed-off-by: xiaojiangfeng <xiaojiangfeng@huawei.com>
>> ---
>>  drivers/of/fdt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 
>> 4734223..de893c9 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -1091,7 +1091,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
>>  	/* Retrieve command line */
>>  	p = of_get_flat_dt_prop(node, "bootargs", &l);
>>  	if (p != NULL && l > 0)
>> -		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
>> +		strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
>>  
>>  	/*
>>  	 * CONFIG_CMDLINE is meant to be a default in case nothing else
>>
> 
> Thanks for catching the redundant cast.
> 
> There is a second problem detected by sparse on that line:
> 
>   drivers/of/fdt.c:1094:34: warning: expression using sizeof(void)
> 
> Can you please fix both issues?
> 
> Thanks,
> 
> Frank
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \\ 答复: [PATCH] of: del redundant type conversion
  2019-04-11  4:13 ` Frank Rowand
@ 2019-04-11  4:21   ` Frank Rowand
  2019-04-11  5:30     ` Frank Rowand
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Rowand @ 2019-04-11  4:21 UTC (permalink / raw)
  To: xiaojiangfeng, robh+dt, robh; +Cc: devicetree, linux-kernel

On 4/10/19 9:13 PM, Frank Rowand wrote:
> On 4/10/19 6:51 PM, xiaojiangfeng wrote:
>> My pleasure.
>>
>> I am very new to sparse.
>>
>> I guess the warning is caused by the macro min.
> 
> I think the warning is likely because the type of data is 'void *'.
> 
> Removing the (int) cast is a good fix, but does not resolve
> the sparse warning.

Let me correct myself.  When I ran sparse, I see the removing min() does
eliminate the sparse warning.  I'm not sure why, so I'll go dig a little
deeper.

-Frank

> 
> -Frank
> 
> 
>> Then I submitted my changes.
>>
>> Thanks for code review.
>>
>>
>> -----邮件原件-----
>> 发件人: Frank Rowand [mailto:frowand.list@gmail.com] 
>> 发送时间: 2019年4月11日 2:50
>> 收件人: xiaojiangfeng <xiaojiangfeng@huawei.com>; robh+dt@kernel.org; robh@kernel.org
>> 抄送: devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
>> 主题: Re: [PATCH] of: del redundant type conversion
>>
>> On 4/10/19 1:29 AM, xiaojiangfeng wrote:
>>> The type of variable l in early_init_dt_scan_chosen is int, there is 
>>> no need to convert to int.
>>>
>>> Signed-off-by: xiaojiangfeng <xiaojiangfeng@huawei.com>
>>> ---
>>>  drivers/of/fdt.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 
>>> 4734223..de893c9 100644
>>> --- a/drivers/of/fdt.c
>>> +++ b/drivers/of/fdt.c
>>> @@ -1091,7 +1091,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
>>>  	/* Retrieve command line */
>>>  	p = of_get_flat_dt_prop(node, "bootargs", &l);
>>>  	if (p != NULL && l > 0)
>>> -		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
>>> +		strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
>>>  
>>>  	/*
>>>  	 * CONFIG_CMDLINE is meant to be a default in case nothing else
>>>
>>
>> Thanks for catching the redundant cast.
>>
>> There is a second problem detected by sparse on that line:
>>
>>   drivers/of/fdt.c:1094:34: warning: expression using sizeof(void)
>>
>> Can you please fix both issues?
>>
>> Thanks,
>>
>> Frank
>>
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \\ 答复: [PATCH] of: del redundant type conversion
  2019-04-11  4:21   ` Frank Rowand
@ 2019-04-11  5:30     ` Frank Rowand
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Rowand @ 2019-04-11  5:30 UTC (permalink / raw)
  To: xiaojiangfeng, robh+dt, robh; +Cc: devicetree, linux-kernel

On 4/10/19 9:21 PM, Frank Rowand wrote:
> On 4/10/19 9:13 PM, Frank Rowand wrote:
>> On 4/10/19 6:51 PM, xiaojiangfeng wrote:
>>> My pleasure.
>>>
>>> I am very new to sparse.
>>>
>>> I guess the warning is caused by the macro min.
>>
>> I think the warning is likely because the type of data is 'void *'.
>>
>> Removing the (int) cast is a good fix, but does not resolve
>> the sparse warning.
> 
> Let me correct myself.  When I ran sparse, I see the removing min() does
> eliminate the sparse warning.  I'm not sure why, so I'll go dig a little
> deeper.

Digging leaves me with more information, but still not sure of the actual
underlying cause.  min() is defined in include/linux/kernel.h.  Unraveling
the defines, the code that sparse is complaining about is in
__no_side_effects(), which is:

#define __no_side_effects(x, y) \
                (__is_constexpr(x) && __is_constexpr(y))

and __is_constexpr() is:

#define __is_constexpr(x) \
        (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))

The compiler warning points to the second sizeof() in the __is_constexpr() for
'l', which expands as:

  (sizeof(int) == sizeof(*(8 ? ((void *)((long)(   l) * 0l)) : (int *)8)))

I'll dig into this a little more, to see if maybe the problem is related to
my compiler version or sparse version.  Or if the reason lies elsewhere.

-Frank


> 
> -Frank
> 
>>
>> -Frank
>>
>>
>>> Then I submitted my changes.
>>>
>>> Thanks for code review.
>>>
>>>
>>> -----邮件原件-----
>>> 发件人: Frank Rowand [mailto:frowand.list@gmail.com] 
>>> 发送时间: 2019年4月11日 2:50
>>> 收件人: xiaojiangfeng <xiaojiangfeng@huawei.com>; robh+dt@kernel.org; robh@kernel.org
>>> 抄送: devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
>>> 主题: Re: [PATCH] of: del redundant type conversion
>>>
>>> On 4/10/19 1:29 AM, xiaojiangfeng wrote:
>>>> The type of variable l in early_init_dt_scan_chosen is int, there is 
>>>> no need to convert to int.
>>>>
>>>> Signed-off-by: xiaojiangfeng <xiaojiangfeng@huawei.com>
>>>> ---
>>>>  drivers/of/fdt.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 
>>>> 4734223..de893c9 100644
>>>> --- a/drivers/of/fdt.c
>>>> +++ b/drivers/of/fdt.c
>>>> @@ -1091,7 +1091,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
>>>>  	/* Retrieve command line */
>>>>  	p = of_get_flat_dt_prop(node, "bootargs", &l);
>>>>  	if (p != NULL && l > 0)
>>>> -		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
>>>> +		strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
>>>>  
>>>>  	/*
>>>>  	 * CONFIG_CMDLINE is meant to be a default in case nothing else
>>>>
>>>
>>> Thanks for catching the redundant cast.
>>>
>>> There is a second problem detected by sparse on that line:
>>>
>>>   drivers/of/fdt.c:1094:34: warning: expression using sizeof(void)
>>>
>>> Can you please fix both issues?
>>>
>>> Thanks,
>>>
>>> Frank
>>>
>>
>>
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-11  5:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  1:51 \\ 答复: [PATCH] of: del redundant type conversion xiaojiangfeng
2019-04-11  4:13 ` Frank Rowand
2019-04-11  4:21   ` Frank Rowand
2019-04-11  5:30     ` Frank Rowand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).