Re: [PATCH v2 1/2] fs/proc: optimize exactly register one ctl_table
From: kernel test robot
Date: Tue Mar 01 2022 - 11:06:50 EST
Hi Meng,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mcgrof/sysctl-next]
[also build test WARNING on jack-fs/fsnotify rostedt-trace/for-next linus/master v5.17-rc6 next-20220301]
[cannot apply to kees/for-next/pstore]
[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/0day-ci/linux/commits/Meng-Tang/fs-proc-optimize-exactly-register-one-ctl_table/20220301-195515
base: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git sysctl-next
config: hexagon-randconfig-r045-20220301 (https://download.01.org/0day-ci/archive/20220301/202203012340.8d5kZylK-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d9e9a410cf46b383390d668770fff70540e27528
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Meng-Tang/fs-proc-optimize-exactly-register-one-ctl_table/20220301-195515
git checkout d9e9a410cf46b383390d668770fff70540e27528
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash fs/proc/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
>> fs/proc/proc_sysctl.c:1281:6: warning: mixing declarations and code is a C99 extension [-Wdeclaration-after-statement]
int len = strlen(table->procname) + 1;
^
fs/proc/proc_sysctl.c:1638:26: warning: no previous prototype for function '__register_sysctl_table_single' [-Wmissing-prototypes]
struct ctl_table_header *__register_sysctl_table_single(
^
fs/proc/proc_sysctl.c:1638:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
struct ctl_table_header *__register_sysctl_table_single(
^
static
fs/proc/proc_sysctl.c:1988:27: warning: mixing declarations and code is a C99 extension [-Wdeclaration-after-statement]
struct ctl_table_header *link_head;
^
3 warnings generated.
vim +1281 fs/proc/proc_sysctl.c
1256
1257 static struct ctl_table_header *new_links_single(struct ctl_dir *dir, struct ctl_table *table,
1258 struct ctl_table_root *link_root)
1259 {
1260 struct ctl_table *link_table;
1261 struct ctl_table_header *links;
1262 struct ctl_node *node;
1263 char *link_name;
1264 int name_bytes = 0;
1265
1266 name_bytes += strlen(table->procname) + 1;
1267
1268 links = kzalloc(sizeof(struct ctl_table_header) +
1269 sizeof(struct ctl_node) +
1270 sizeof(struct ctl_table)*2 +
1271 name_bytes,
1272 GFP_KERNEL);
1273
1274 if (!links)
1275 return NULL;
1276
1277 node = (struct ctl_node *)(links + 1);
1278 link_table = (struct ctl_table *)(node + 1);
1279 link_name = (char *)&link_table[2];
1280
> 1281 int len = strlen(table->procname) + 1;
1282
1283 memcpy(link_name, table->procname, len);
1284 link_table->procname = link_name;
1285 link_table->mode = S_IFLNK|S_IRWXUGO;
1286 link_table->data = link_root;
1287 link_name += len;
1288
1289 init_header_single(links, dir->header.root, dir->header.set, node, link_table);
1290 links->nreg = 1;
1291
1292 return links;
1293 }
1294 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
1295 struct ctl_table_root *link_root)
1296 {
1297 struct ctl_table *link_table, *entry, *link;
1298 struct ctl_table_header *links;
1299 struct ctl_node *node;
1300 char *link_name;
1301 int nr_entries, name_bytes;
1302
1303 name_bytes = 0;
1304 nr_entries = 0;
1305 for (entry = table; entry->procname; entry++) {
1306 nr_entries++;
1307 name_bytes += strlen(entry->procname) + 1;
1308 }
1309
1310 links = kzalloc(sizeof(struct ctl_table_header) +
1311 sizeof(struct ctl_node)*nr_entries +
1312 sizeof(struct ctl_table)*(nr_entries + 1) +
1313 name_bytes,
1314 GFP_KERNEL);
1315
1316 if (!links)
1317 return NULL;
1318
1319 node = (struct ctl_node *)(links + 1);
1320 link_table = (struct ctl_table *)(node + nr_entries);
1321 link_name = (char *)&link_table[nr_entries + 1];
1322
1323 for (link = link_table, entry = table; entry->procname; link++, entry++) {
1324 int len = strlen(entry->procname) + 1;
1325 memcpy(link_name, entry->procname, len);
1326 link->procname = link_name;
1327 link->mode = S_IFLNK|S_IRWXUGO;
1328 link->data = link_root;
1329 link_name += len;
1330 }
1331 init_header(links, dir->header.root, dir->header.set, node, link_table);
1332 links->nreg = nr_entries;
1333
1334 return links;
1335 }
1336
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx