nullb: make config_item_type const
PATCH 1/1 nullb: make config_item_type const
This is a followup patch for: https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/
Make these structures const as they are either passed to the functions having the argument as const or stored as a reference in the "ci_type" const field of a config_item structure.
Done using Coccienlle.
--- drivers/block/null_blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/null_blk.c +2 -2
@@ -480,7 +480,7 @@ static void nullb_device_release(struct config_item *item) .release = nullb_device_release, }; -static struct config_item_type nullb_device_type = { +static const struct config_item_type nullb_device_type = { .ct_item_ops = &nullb_device_ops, .ct_attrs = nullb_device_attrs, .ct_owner =THIS_MODULE ,
@@ -532,7 +532,7 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page) .drop_item = nullb_group_drop_item, }; -static struct config_item_type nullb_group_type = { +static const struct config_item_type nullb_group_type = { .ct_group_ops = &nullb_group_ops, .ct_attrs = nullb_group_attrs, .ct_owner =THIS_MODULE ,
Signature · 1 line
1.9.1
Quoted 6 lines · Bhumika Goyal
This is a followup patch for: https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/Make these structures const as they are either passed to the functions having the argument as const or stored as a reference in the "
ci_type" const field of aconfig_itemstructure.
Thanks, applied.
Signature · 1 line
Jens Axboe
Quoted 10 lines · Jens Axboe
Quoted 6 lines · Bhumika Goyal
This is a followup patch for: https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/Make these structures const as they are either passed to the functions having the argument as const or stored as a reference in the "
ci_type" const field of aconfig_itemstructure.Thanks, applied.
Hello,
Actually, this patch is dependent on the patches in the links
https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/. Therefore, this patch won't be correct unless the patches in these links gets applied.
Thanks,
Bhumika
Quoted 3 lines
--
Jens Axboe
Jens Axboe
maintainerQuoted 12 lines · Bhumika Goyal
Quoted 10 lines · Jens Axboe
Quoted 6 lines · Bhumika Goyal
This is a followup patch for: https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/Make these structures const as they are either passed to the functions having the argument as const or stored as a reference in the "
ci_type" const field of aconfig_itemstructure.Thanks, applied.
Quoted 6 lines
Hello,
Actually, this patch is dependent on the patches in the links
https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/. Therefore, this patch won't be correct unless the patches in these links gets applied.
Gah, I do see that now. That should have been made much clearer in the patch description!
When you send out patches with hard dependencies like that, either wait until the dependency has been solved in mainline, or make it explicitly clear in the patch submission.
Signature · 1 line
Jens Axboe
Quoted 20 lines · Jens Axboe
Quoted 12 lines · Bhumika Goyal
Quoted 10 lines · Jens Axboe
Quoted 6 lines · Bhumika Goyal
This is a followup patch for: https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/Make these structures const as they are either passed to the functions having the argument as const or stored as a reference in the "
ci_type" const field of aconfig_itemstructure.Thanks, applied.
Quoted 6 lines
Hello,
Actually, this patch is dependent on the patches in the links
https://lkml.org/lkml/2017/10/11/375 and
https://patchwork.kernel.org/patch/9999649/. Therefore, this patch won't be correct unless the patches in these links gets applied.
Quoted 7 lines
Gah, I do see that now. That should have been made much clearer in the patch description!
When you send out patches with hard dependencies like that, either wait until the dependency has been solved in mainline, or make it explicitly clear in the patch submission.
Sorry, for not mentioning the dependencies clearly. I will keep the pointer in mind.
Thanks,
Bhumika
Quoted 3 lines
--
Jens Axboe
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Bhumika-Goyal/nullb-make-config_item_type-const/20171015-060539 config: x86_64-randconfig-x001-201742 (attached as .config) compiler: gcc-6 (Debian…
Hi Bhumika,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.14-rc4 next-20171013]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Bhumika-Goyal/nullb-make-config_item_type-const/20171015-060539
config: x86_64-randconfig-x001-201742 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All warnings (new ones prefixed by >>):
drivers/block/null_blk.c: In function 'nullb_group_make_item':
>> drivers/block/null_blk.c:494:47: warning: passing argument 3 of 'config_item_init_type_name' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
config_item_init_type_name(&dev->item, name, &nullb_device_type);
^
In file included from drivers/block/null_blk.c:16:0:
include/linux/configfs.h:73:13: note: expected 'struct config_item_type *' but argument is of type 'const struct config_item_type *'
extern void config_item_init_type_name(struct config_item *item,
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/null_blk.c: At top level:
>> drivers/block/null_blk.c:541:15: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] .ci_type = &nullb_group_type,
^
Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size Cyclomatic Complexity 2 arch/x86/include/asm/bitops.h:set_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:__set_bit Cyclomatic Complexity 2 arch/x86/include/asm/bitops.h:clear_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:clear_bit_unlock Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:__clear_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit_lock Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_clear_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64 Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD Cyclomatic Complexity 1 include/linux/list.h:__list_del
Cyclomatic Complexity 1 include/linux/list.h:list_empty
Cyclomatic Complexity 1 arch/x86/include/asm/current.h:get_current Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order Cyclomatic Complexity 3 include/linux/string.h:strncpy
Cyclomatic Complexity 3 include/linux/string.h:memset
Cyclomatic Complexity 4 include/linux/string.h:memcpy
Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:atomic64_read Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:atomic64_set Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:atomic64_add_return Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:atomic64_sub_return Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_read Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_set Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_sub_return Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
Cyclomatic Complexity 5 arch/x86/include/asm/preempt.h:__preempt_count_add Cyclomatic Complexity 5 arch/x86/include/asm/preempt.h:__preempt_count_sub Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock_irq Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irq Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irqrestore Cyclomatic Complexity 1 include/linux/wait.h:waitqueue_active Cyclomatic Complexity 1 arch/x86/include/asm/topology.h:numa_node_id Cyclomatic Complexity 1 include/linux/topology.h:numa_mem_id Cyclomatic Complexity 1 include/linux/radix-tree.h:radix_tree_empty Cyclomatic Complexity 1 include/linux/radix-tree.h:radix_tree_preload_end Cyclomatic Complexity 1 include/linux/hrtimer.h:hrtimer_get_expires Cyclomatic Complexity 1 include/linux/hrtimer.h:hrtimer_get_softexpires Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index Cyclomatic Complexity 1 include/linux/slab.h:__kmalloc_node Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_node_trace Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc_node
Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
Cyclomatic Complexity 1 include/linux/slab.h:kzalloc_node
Cyclomatic Complexity 1 include/linux/genhd.h:set_capacity
Cyclomatic Complexity 1 include/linux/mm.h:lowmem_page_address Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disabled_inc Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disabled_dec Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disable Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_enable Cyclomatic Complexity 1 include/linux/highmem.h:kmap_atomic Cyclomatic Complexity 1 include/linux/highmem.h:__kunmap_atomic Cyclomatic Complexity 1 include/linux/blk_types.h:op_is_write Cyclomatic Complexity 4 include/linux/bio.h:bio_no_advance_iter Cyclomatic Complexity 1 include/linux/blkdev.h:queue_flag_set_unlocked Cyclomatic Complexity 1 include/linux/blkdev.h:queue_flag_clear_unlocked Cyclomatic Complexity 1 include/linux/blkdev.h:blk_rq_pos
Cyclomatic Complexity 1 include/linux/blkdev.h:blk_rq_bytes Cyclomatic Complexity 1 include/linux/blkdev.h:blk_rq_sectors Cyclomatic Complexity 1 include/linux/blk-mq.h:blk_mq_rq_to_pdu Cyclomatic Complexity 1 drivers/block/null_blk.c:mb_per_tick Cyclomatic Complexity 1 drivers/block/null_blk.c:null_cache_active Cyclomatic Complexity 2 drivers/block/null_blk.c:nullb_to_queue Cyclomatic Complexity 1 drivers/block/null_blk.c:null_nvm_unregister Cyclomatic Complexity 1 drivers/block/null_blk.c:null_open
Cyclomatic Complexity 1 drivers/block/null_blk.c:null_release Cyclomatic Complexity 2 drivers/block/null_blk.c:setup_queues Cyclomatic Complexity 12 drivers/block/null_blk.c:null_validate_conf Cyclomatic Complexity 4 drivers/block/null_blk.c:null_param_store_val Cyclomatic Complexity 1 drivers/block/null_blk.c:null_set_queue_mode Cyclomatic Complexity 1 drivers/block/null_blk.c:null_set_irqmode Cyclomatic Complexity 1 drivers/block/null_blk.c:memb_group_features_show Cyclomatic Complexity 1 include/linux/kernel.h:kstrtoul
Cyclomatic Complexity 2 drivers/block/null_blk.c:nullb_device_ulong_attr_store Cyclomatic Complexity 4 drivers/block/null_blk.c:setup_commands Cyclomatic Complexity 1 drivers/block/null_blk.c:cleanup_queue Cyclomatic Complexity 2 drivers/block/null_blk.c:cleanup_queues Cyclomatic Complexity 1 drivers/block/null_blk.c:null_free_dev Cyclomatic Complexity 3 drivers/block/null_blk.c:to_nullb_device Cyclomatic Complexity 2 drivers/block/null_blk.c:nullb_device_cache_size_store Cyclomatic Complexity 2 drivers/block/null_blk.c:nullb_device_completion_nsec_store Cyclomatic Complexity 2 drivers/block/null_blk.c:nullb_device_size_store Cyclomatic Complexity 1 include/linux/string.h:strstrip
Cyclomatic Complexity 9 drivers/block/null_blk.c:nullb_device_badblocks_store Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_badblocks_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_ulong_attr_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_cache_size_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_completion_nsec_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_size_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_uint_attr_show Cyclomatic Complexity 1 drivers/block/null_blk.c:nullb_device_mbps_show
vim +494 drivers/block/null_blk.c
3bf2bd207 Shaohua Li 2017-08-14 484
3bf2bd207 Shaohua Li 2017-08-14 485 static struct
3bf2bd207 Shaohua Li 2017-08-14 486 config_item *nullb_group_make_item(struct config_group *group, const char *name)
3bf2bd207 Shaohua Li 2017-08-14 487 {
3bf2bd207 Shaohua Li 2017-08-14 488 struct nullb_device *dev;
3bf2bd207 Shaohua Li 2017-08-14 489
3bf2bd207 Shaohua Li 2017-08-14 490 dev = null_alloc_dev();
3bf2bd207 Shaohua Li 2017-08-14 491 if (!dev)
3bf2bd207 Shaohua Li 2017-08-14 492 return ERR_PTR(-ENOMEM);
3bf2bd207 Shaohua Li 2017-08-14 493
3bf2bd207 Shaohua Li 2017-08-14 @494 config_item_init_type_name(&dev->item, name, &nullb_device_type);
3bf2bd207 Shaohua Li 2017-08-14 495
3bf2bd207 Shaohua Li 2017-08-14 496 return &dev->item;
3bf2bd207 Shaohua Li 2017-08-14 497 }
3bf2bd207 Shaohua Li 2017-08-14 498
3bf2bd207 Shaohua Li 2017-08-14 499 static void
3bf2bd207 Shaohua Li 2017-08-14 500 nullb_group_drop_item(struct config_group *group, struct config_item *item)
3bf2bd207 Shaohua Li 2017-08-14 501 {
cedcafad8 Shaohua Li 2017-08-14 502 struct nullb_device *dev = to_nullb_device(item);
cedcafad8 Shaohua Li 2017-08-14 503
cedcafad8 Shaohua Li 2017-08-14 504 if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
cedcafad8 Shaohua Li 2017-08-14 505 mutex_lock(&lock);
cedcafad8 Shaohua Li 2017-08-14 506 dev->power = false;
cedcafad8 Shaohua Li 2017-08-14 507 null_del_dev(dev->nullb);
cedcafad8 Shaohua Li 2017-08-14 508 mutex_unlock(&lock);
cedcafad8 Shaohua Li 2017-08-14 509 }
cedcafad8 Shaohua Li 2017-08-14 510
3bf2bd207 Shaohua Li 2017-08-14 511 config_item_put(item);
3bf2bd207 Shaohua Li 2017-08-14 512 }
3bf2bd207 Shaohua Li 2017-08-14 513
3bf2bd207 Shaohua Li 2017-08-14 514 static ssize_t memb_group_features_show(struct config_item *item, char *page)
3bf2bd207 Shaohua Li 2017-08-14 515 {
2f54a613c Shaohua Li 2017-08-14 516 return snprintf(page, PAGE_SIZE, "memory_backed,discard,bandwidth,cache,badblocks\n");
3bf2bd207 Shaohua Li 2017-08-14 517 }
3bf2bd207 Shaohua Li 2017-08-14 518
3bf2bd207 Shaohua Li 2017-08-14 519 CONFIGFS_ATTR_RO(memb_group_, features);
3bf2bd207 Shaohua Li 2017-08-14 520
3bf2bd207 Shaohua Li 2017-08-14 521 static struct configfs_attribute *nullb_group_attrs[] = {
3bf2bd207 Shaohua Li 2017-08-14 522 &memb_group_attr_features,
3bf2bd207 Shaohua Li 2017-08-14 523 NULL,
3bf2bd207 Shaohua Li 2017-08-14 524 };
3bf2bd207 Shaohua Li 2017-08-14 525
3bf2bd207 Shaohua Li 2017-08-14 526 static struct configfs_group_operations nullb_group_ops = {
3bf2bd207 Shaohua Li 2017-08-14 527 .make_item = nullb_group_make_item,
3bf2bd207 Shaohua Li 2017-08-14 528 .drop_item = nullb_group_drop_item,
3bf2bd207 Shaohua Li 2017-08-14 529 };
3bf2bd207 Shaohua Li 2017-08-14 530
d2358d8dd Bhumika Goyal 2017-10-12 531 static const struct config_item_type nullb_group_type = {
3bf2bd207 Shaohua Li 2017-08-14 532 .ct_group_ops = &nullb_group_ops,
3bf2bd207 Shaohua Li 2017-08-14 533 .ct_attrs = nullb_group_attrs,
3bf2bd207 Shaohua Li 2017-08-14 534 .ct_owner = THIS_MODULE,
3bf2bd207 Shaohua Li 2017-08-14 535 };
3bf2bd207 Shaohua Li 2017-08-14 536
3bf2bd207 Shaohua Li 2017-08-14 537 static struct configfs_subsystem nullb_subsys = {
3bf2bd207 Shaohua Li 2017-08-14 538 .su_group = {
3bf2bd207 Shaohua Li 2017-08-14 539 .cg_item = {
3bf2bd207 Shaohua Li 2017-08-14 540 .ci_namebuf = "nullb",
3bf2bd207 Shaohua Li 2017-08-14 @541 .ci_type = &nullb_group_type,
3bf2bd207 Shaohua Li 2017-08-14 542 },
3bf2bd207 Shaohua Li 2017-08-14 543 },
3bf2bd207 Shaohua Li 2017-08-14 544 };
3bf2bd207 Shaohua Li 2017-08-14 545 :::::: The code at line 494 was first introduced by commit
:::::: 3bf2bd20734e3e6ffda53719a9c10fb3ee9c5ffa nullb: add configfs interface
:::::: TO: Shaohua Li <[email protected]>
:::::: CC: Jens Axboe <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation