Re: \\ 答复: [PATCH] of: del redundant type conversion

2019-04-10 Thread xiaojiangfeng
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.l...@gmail.com] 
发送时间: 2019年4月11日 2:50
收件人: xiaojiangfeng ; robh...@kernel.org; 
r...@kernel.org
抄送: devicet...@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 
> ---
>  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", );
>   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


[PATCH] of: fix expression using sizeof(void)

2019-04-10 Thread xiaojiangfeng
problem detected by sparse:
drivers/of/fdt.c:1094:34: warning: expression using sizeof(void)

Signed-off-by: xiaojiangfeng 
---
 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..75c6c55 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", );
if (p != NULL && l > 0)
-   strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
+   strlcpy(data, p, COMMAND_LINE_SIZE);
 
/*
 * CONFIG_CMDLINE is meant to be a default in case nothing else
-- 
1.8.5.6



[PATCH] of: del redundant type conversion

2019-04-10 Thread xiaojiangfeng
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 
---
 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", );
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
-- 
1.8.5.6