public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf()
@ 2025-03-12 20:16 Andy Shevchenko
  2025-03-13  1:24 ` Zhihao Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-12 20:16 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

Compiler is not happy about NULL being supplied as printf() parameter:

drivers/mtd/mtdpart.c:693:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

Replace that with "(null)" to fix compilation error.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/mtdpart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 6811a714349d..6f7e250ef710 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -691,7 +691,7 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types,
 			if (!parser && !request_module("%s", *types))
 				parser = mtd_part_parser_get(*types);
 			pr_debug("%s: got parser %s\n", master->name,
-				parser ? parser->name : NULL);
+				parser ? parser->name : "(null)");
 			if (!parser)
 				continue;
 			ret = mtd_part_do_parse(parser, master, &pparts, data);
-- 
2.47.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf()
  2025-03-12 20:16 [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf() Andy Shevchenko
@ 2025-03-13  1:24 ` Zhihao Cheng
  2025-03-13  9:09   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Zhihao Cheng @ 2025-03-13  1:24 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

在 2025/3/13 4:16, Andy Shevchenko 写道:
> Compiler is not happy about NULL being supplied as printf() parameter:

printf -> printk? The title has the same issue.
> 
> drivers/mtd/mtdpart.c:693:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> 
> Replace that with "(null)" to fix compilation error.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/mtd/mtdpart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 6811a714349d..6f7e250ef710 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -691,7 +691,7 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types,
>   			if (!parser && !request_module("%s", *types))
>   				parser = mtd_part_parser_get(*types);
>   			pr_debug("%s: got parser %s\n", master->name,
> -				parser ? parser->name : NULL);
> +				parser ? parser->name : "(null)");
>   			if (!parser)
>   				continue;
>   			ret = mtd_part_do_parse(parser, master, &pparts, data);
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf()
  2025-03-13  1:24 ` Zhihao Cheng
@ 2025-03-13  9:09   ` Andy Shevchenko
  2025-03-13 10:54     ` Zhihao Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-13  9:09 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra

On Thu, Mar 13, 2025 at 09:24:21AM +0800, Zhihao Cheng wrote:
> 在 2025/3/13 4:16, Andy Shevchenko 写道:
> > Compiler is not happy about NULL being supplied as printf() parameter:
> 
> printf -> printk? The title has the same issue.
> > 
> > drivers/mtd/mtdpart.c:693:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> > 
> > Replace that with "(null)" to fix compilation error.

> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

Thank you!

But I think my approach is a hack, the best is to move this message to the
after the follow up conditional and drop that ternary completely as we have
already another debug message before that. So, the parser == NULL can be
deducted from the appearance of the one and not the other one.

I'll send a v2.

> >   			if (!parser && !request_module("%s", *types))
> >   				parser = mtd_part_parser_get(*types);
> >   			pr_debug("%s: got parser %s\n", master->name,
> > -				parser ? parser->name : NULL);
> > +				parser ? parser->name : "(null)");
> >   			if (!parser)
> >   				continue;

(move it here)

> >   			ret = mtd_part_do_parse(parser, master, &pparts, data);

-- 
With Best Regards,
Andy Shevchenko



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf()
  2025-03-13  9:09   ` Andy Shevchenko
@ 2025-03-13 10:54     ` Zhihao Cheng
  2025-03-13 12:10       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Zhihao Cheng @ 2025-03-13 10:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra

在 2025/3/13 17:09, Andy Shevchenko 写道:
> On Thu, Mar 13, 2025 at 09:24:21AM +0800, Zhihao Cheng wrote:
>> 在 2025/3/13 4:16, Andy Shevchenko 写道:
>>> Compiler is not happy about NULL being supplied as printf() parameter:
>>
>> printf -> printk? The title has the same issue.
>>>
>>> drivers/mtd/mtdpart.c:693:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
>>>
>>> Replace that with "(null)" to fix compilation error.
> 
>> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> Thank you!
> 
> But I think my approach is a hack, the best is to move this message to the
> after the follow up conditional and drop that ternary completely as we have
> already another debug message before that. So, the parser == NULL can be
> deducted from the appearance of the one and not the other one.
> 
> I'll send a v2.
> 
>>>    			if (!parser && !request_module("%s", *types))
>>>    				parser = mtd_part_parser_get(*types);
>>>    			pr_debug("%s: got parser %s\n", master->name,
>>> -				parser ? parser->name : NULL);
>>> +				parser ? parser->name : "(null)");
>>>    			if (!parser)
>>>    				continue;
> 
> (move it here)

After looking through 8e2c992b59fc("mtd: mtdpart: add debug prints to 
partition parser.") and 01f9c7240a90("mtd: partitions: factor out code 
calling parser"), I think we'd better keep the debug message before the 
condition 'if (!parser)', it is used to inform us whether we get a 
parser and which name it is. And the debug message in mtd_part_do_parse 
informs us the result of the 'parser->parse_fn'.
> 
>>>    			ret = mtd_part_do_parse(parser, master, &pparts, data);
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf()
  2025-03-13 10:54     ` Zhihao Cheng
@ 2025-03-13 12:10       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-13 12:10 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra

On Thu, Mar 13, 2025 at 06:54:40PM +0800, Zhihao Cheng wrote:
> 在 2025/3/13 17:09, Andy Shevchenko 写道:
> > On Thu, Mar 13, 2025 at 09:24:21AM +0800, Zhihao Cheng wrote:
> > > 在 2025/3/13 4:16, Andy Shevchenko 写道:
> > > > Compiler is not happy about NULL being supplied as printf() parameter:
> > > 
> > > printf -> printk? The title has the same issue.
> > > > 
> > > > drivers/mtd/mtdpart.c:693:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> > > > 
> > > > Replace that with "(null)" to fix compilation error.
> > 
> > > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> > 
> > Thank you!
> > 
> > But I think my approach is a hack, the best is to move this message to the
> > after the follow up conditional and drop that ternary completely as we have
> > already another debug message before that. So, the parser == NULL can be
> > deducted from the appearance of the one and not the other one.
> > 
> > I'll send a v2.
> > 
> > > >    			if (!parser && !request_module("%s", *types))
> > > >    				parser = mtd_part_parser_get(*types);
> > > >    			pr_debug("%s: got parser %s\n", master->name,
> > > > -				parser ? parser->name : NULL);
> > > > +				parser ? parser->name : "(null)");
> > > >    			if (!parser)
> > > >    				continue;
> > 
> > (move it here)
> 
> After looking through 8e2c992b59fc("mtd: mtdpart: add debug prints to
> partition parser.") and 01f9c7240a90("mtd: partitions: factor out code
> calling parser"), I think we'd better keep the debug message before the
> condition 'if (!parser)', it is used to inform us whether we get a parser
> and which name it is. And the debug message in mtd_part_do_parse informs us
> the result of the 'parser->parse_fn'.

See v2, please. From information point of view no piece would be lost.

> > > >    			ret = mtd_part_do_parse(parser, master, &pparts, data);

-- 
With Best Regards,
Andy Shevchenko



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2025-03-13 12:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 20:16 [PATCH v1 1/1] mtd: mtdpart: Do not supply NULL to printf() Andy Shevchenko
2025-03-13  1:24 ` Zhihao Cheng
2025-03-13  9:09   ` Andy Shevchenko
2025-03-13 10:54     ` Zhihao Cheng
2025-03-13 12:10       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox