Re: [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with --

From: kernel test robot
Date: Thu Jun 30 2022 - 08:30:02 EST


Hi hmy,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v5.19-rc4 next-20220630]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-a011 (https://download.01.org/0day-ci/archive/20220630/202206302025.8eyzYH5h-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/a68da93a13a9544ea17147828f16894ab6cfd204
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
git checkout a68da93a13a9544ea17147828f16894ab6cfd204
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/of/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/of/fdt.c: In function 'early_init_dt_scan_chosen':
>> drivers/of/fdt.c:1163:15: warning: unused variable 'q' [-Wunused-variable]
1163 | char *q;
| ^


vim +/q +1163 drivers/of/fdt.c

1158
1159 int __init early_init_dt_scan_chosen(char *cmdline)
1160 {
1161 int l, node;
1162 const char *p;
> 1163 char *q;
1164 const void *rng_seed;
1165 const void *fdt = initial_boot_params;
1166
1167 node = fdt_path_offset(fdt, "/chosen");
1168 if (node < 0)
1169 node = fdt_path_offset(fdt, "/chosen@0");
1170 if (node < 0)
1171 return -ENOENT;
1172
1173 chosen_node_offset = node;
1174
1175 early_init_dt_check_for_initrd(node);
1176 early_init_dt_check_for_elfcorehdr(node);
1177
1178 /* Retrieve command line */
1179 p = of_get_flat_dt_prop(node, "bootargs", &l);
1180 if (p != NULL && l > 0)
1181 strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
1182
1183 /*
1184 * CONFIG_CMDLINE is meant to be a default in case nothing else
1185 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
1186 * is set in which case we override whatever was found earlier.
1187 */
1188 #ifdef CONFIG_CMDLINE
1189 #if defined(CONFIG_CMDLINE_EXTEND)
1190 strlcat(cmdline, " ", COMMAND_LINE_SIZE);
1191 strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1192 q = strstr(data, "--");
1193 if (q)
1194 *q = '\0';
1195 #elif defined(CONFIG_CMDLINE_FORCE)
1196 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1197 #else
1198 /* No arguments from boot loader, use kernel's cmdl*/
1199 if (!((char *)cmdline)[0])
1200 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1201 #endif
1202 #endif /* CONFIG_CMDLINE */
1203
1204 pr_debug("Command line is: %s\n", (char *)cmdline);
1205
1206 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
1207 if (rng_seed && l > 0) {
1208 add_bootloader_randomness(rng_seed, l);
1209
1210 /* try to clear seed so it won't be found. */
1211 fdt_nop_property(initial_boot_params, node, "rng-seed");
1212
1213 /* update CRC check value */
1214 of_fdt_crc32 = crc32_be(~0, initial_boot_params,
1215 fdt_totalsize(initial_boot_params));
1216 }
1217
1218 return 0;
1219 }
1220

--
0-DAY CI Kernel Test Service
https://01.org/lkp