mtd: mtdpart: Do not supply NULL to printf()
PATCH 1/1 mtd: mtdpart: Do not supply NULL to printf()
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.
--- drivers/mtd/mtdpart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdpart.c +1 -1
@@ -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);
Signature · 1 line
2.47.2
Quoted 1 line · Andy Shevchenko
Compiler is not happy about NULL being supplied as
printf()parameter:
printf -> printk? The title has the same issue.
Quoted 10 lines
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 <[email protected]>--- drivers/mtd/mtdpart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
drivers/mtd/mtdpart.c +1
-1@@ -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);
Quoted 10 lines · Zhihao Cheng
Quoted 1 line · Andy Shevchenko
Compiler is not happy about NULL being supplied as
printf()parameter:printf -> printk? The title has the same issue.
Quoted 4 lines
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 <[email protected]>
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.
Quoted 7 lines
drivers/mtd/mtdpart.c int parse_mtd_partitions(struct mtd_info *master, const char *const *types, · line 696
Quoted 7 lines
if (!parser && !request_module("%s", *types)) parser = mtd_part_parser_get(*types); pr_debug("%s: got parser %s\n", master->name,drivers/mtd/mtdpart.c +1
-1- parser ? parser->name : NULL); + parser ? parser->name : "(null)");if (!parser)continue ;
(move it here)
Quoted 1 line
Quoted 1 line
ret = mtd_part_do_parse(parser, master, &pparts, data);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
Quoted 10 lines · Zhihao Cheng
Quoted 1 line · Andy Shevchenko
Compiler is not happy about NULL being supplied as
printf()parameter:printf -> printk? The title has the same issue.
Quoted 4 lines
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 <[email protected]>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.
Quoted 9 lines
Quoted 7 lines
drivers/mtd/mtdpart.c int parse_mtd_partitions(struct mtd_info *master, const char *const *types, · line 696
Quoted 7 lines
if (!parser && !request_module("%s", *types)) parser = mtd_part_parser_get(*types); pr_debug("%s: got parser %s\n", master->name,drivers/mtd/mtdpart.c +1
-1- 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'.
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
ret = mtd_part_do_parse(parser, master, &pparts, data);
Quoted 32 lines · Zhihao Cheng
Quoted 21 lines · Andy Shevchenko
Quoted 10 lines · Zhihao Cheng
Quoted 1 line · Andy Shevchenko
Compiler is not happy about NULL being supplied as
printf()parameter:printf -> printk? The title has the same issue.
Quoted 4 lines
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 <[email protected]>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.
Quoted 9 lines
Quoted 7 lines
drivers/mtd/mtdpart.c int parse_mtd_partitions(struct mtd_info *master, const char *const *types, · line 696
Quoted 7 lines
if (!parser && !request_module("%s", *types)) parser = mtd_part_parser_get(*types); pr_debug("%s: got parser %s\n", master->name,drivers/mtd/mtdpart.c +1
-1- parser ? parser->name : NULL); + parser ? parser->name : "(null)");if (!parser)continue ;(move it here)
Quoted 6 lines
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_parseinforms us the result of the 'parser->parse_fn'.
See v2, please. From information point of view no piece would be lost.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
ret = mtd_part_do_parse(parser, master, &pparts, data);
Signature · 2 lines
With Best Regards, Andy Shevchenko