Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: target: Constify struct configfs_item_operations and configfs_group_operations

'struct configfs_item_operations' and 'configfs_group_operations' are
not modified in this driver.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
151831 80058 4832 236721 39cb1 drivers/target/target_core_configfs.o
45200 16658 0 61858 f1a2 drivers/target/target_core_fabric_configfs.o

After:
=====
text data bss dec hex filename
152599 79290 4832 236721 39cb1 drivers/target/target_core_configfs.o
46352 15506 0 61858 f1a2 drivers/target/target_core_fabric_configfs.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/a0f25237ae86b8c4dd7a3876c4ed2dc3de200173.1767008082.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Christophe JAILLET and committed by
Martin K. Petersen
ae62d62b 8e8e8e7e

+24 -24
+9 -9
drivers/target/target_core_configfs.c
··· 288 288 config_item_put(item); 289 289 } 290 290 291 - static struct configfs_group_operations target_core_fabric_group_ops = { 291 + static const struct configfs_group_operations target_core_fabric_group_ops = { 292 292 .make_group = &target_core_register_fabric, 293 293 .drop_item = &target_core_deregister_fabric, 294 294 }; ··· 2860 2860 core_alua_free_lu_gp(lu_gp); 2861 2861 } 2862 2862 2863 - static struct configfs_item_operations target_core_alua_lu_gp_ops = { 2863 + static const struct configfs_item_operations target_core_alua_lu_gp_ops = { 2864 2864 .release = target_core_alua_lu_gp_release, 2865 2865 }; 2866 2866 ··· 2917 2917 config_item_put(item); 2918 2918 } 2919 2919 2920 - static struct configfs_group_operations target_core_alua_lu_gps_group_ops = { 2920 + static const struct configfs_group_operations target_core_alua_lu_gps_group_ops = { 2921 2921 .make_group = &target_core_alua_create_lu_gp, 2922 2922 .drop_item = &target_core_alua_drop_lu_gp, 2923 2923 }; ··· 3290 3290 core_alua_free_tg_pt_gp(tg_pt_gp); 3291 3291 } 3292 3292 3293 - static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { 3293 + static const struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { 3294 3294 .release = target_core_alua_tg_pt_gp_release, 3295 3295 }; 3296 3296 ··· 3348 3348 config_item_put(item); 3349 3349 } 3350 3350 3351 - static struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = { 3351 + static const struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = { 3352 3352 .make_group = &target_core_alua_create_tg_pt_gp, 3353 3353 .drop_item = &target_core_alua_drop_tg_pt_gp, 3354 3354 }; ··· 3389 3389 return; 3390 3390 } 3391 3391 3392 - static struct configfs_group_operations target_core_stat_group_ops = { 3392 + static const struct configfs_group_operations target_core_stat_group_ops = { 3393 3393 .make_group = &target_core_stat_mkdir, 3394 3394 .drop_item = &target_core_stat_rmdir, 3395 3395 }; ··· 3516 3516 mutex_unlock(&hba->hba_access_mutex); 3517 3517 } 3518 3518 3519 - static struct configfs_group_operations target_core_hba_group_ops = { 3519 + static const struct configfs_group_operations target_core_hba_group_ops = { 3520 3520 .make_group = target_core_make_subdev, 3521 3521 .drop_item = target_core_drop_subdev, 3522 3522 }; ··· 3595 3595 NULL, 3596 3596 }; 3597 3597 3598 - static struct configfs_item_operations target_core_hba_item_ops = { 3598 + static const struct configfs_item_operations target_core_hba_item_ops = { 3599 3599 .release = target_core_hba_release, 3600 3600 }; 3601 3601 ··· 3676 3676 config_item_put(item); 3677 3677 } 3678 3678 3679 - static struct configfs_group_operations target_core_group_ops = { 3679 + static const struct configfs_group_operations target_core_group_ops = { 3680 3680 .make_group = target_core_call_addhbatotarget, 3681 3681 .drop_item = target_core_call_delhbafromtarget, 3682 3682 };
+15 -15
drivers/target/target_core_fabric_configfs.c
··· 59 59 pr_debug("Setup generic %s\n", __stringify(_name)); \ 60 60 } 61 61 62 - static struct configfs_item_operations target_fabric_port_item_ops; 62 + static const struct configfs_item_operations target_fabric_port_item_ops; 63 63 64 64 /* Start of tfc_tpg_mappedlun_cit */ 65 65 ··· 219 219 core_dev_free_initiator_node_lun_acl(se_tpg, lacl); 220 220 } 221 221 222 - static struct configfs_item_operations target_fabric_mappedlun_item_ops = { 222 + static const struct configfs_item_operations target_fabric_mappedlun_item_ops = { 223 223 .release = target_fabric_mappedlun_release, 224 224 .allow_link = target_fabric_mappedlun_link, 225 225 .drop_link = target_fabric_mappedlun_unlink, ··· 246 246 return; 247 247 } 248 248 249 - static struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = { 249 + static const struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = { 250 250 .make_group = target_core_mappedlun_stat_mkdir, 251 251 .drop_item = target_core_mappedlun_stat_rmdir, 252 252 }; ··· 345 345 core_tpg_del_initiator_node_acl(se_nacl); 346 346 } 347 347 348 - static struct configfs_item_operations target_fabric_nacl_base_item_ops = { 348 + static const struct configfs_item_operations target_fabric_nacl_base_item_ops = { 349 349 .release = target_fabric_nacl_base_release, 350 350 }; 351 351 352 - static struct configfs_group_operations target_fabric_nacl_base_group_ops = { 352 + static const struct configfs_group_operations target_fabric_nacl_base_group_ops = { 353 353 .make_group = target_fabric_make_mappedlun, 354 354 .drop_item = target_fabric_drop_mappedlun, 355 355 }; ··· 433 433 config_item_put(item); 434 434 } 435 435 436 - static struct configfs_group_operations target_fabric_nacl_group_ops = { 436 + static const struct configfs_group_operations target_fabric_nacl_group_ops = { 437 437 .make_group = target_fabric_make_nodeacl, 438 438 .drop_item = target_fabric_drop_nodeacl, 439 439 }; ··· 454 454 tf->tf_ops->fabric_drop_np(se_tpg_np); 455 455 } 456 456 457 - static struct configfs_item_operations target_fabric_np_base_item_ops = { 457 + static const struct configfs_item_operations target_fabric_np_base_item_ops = { 458 458 .release = target_fabric_np_base_release, 459 459 }; 460 460 ··· 499 499 config_item_put(item); 500 500 } 501 501 502 - static struct configfs_group_operations target_fabric_np_group_ops = { 502 + static const struct configfs_group_operations target_fabric_np_group_ops = { 503 503 .make_group = &target_fabric_make_np, 504 504 .drop_item = &target_fabric_drop_np, 505 505 }; ··· 700 700 call_rcu(&lun->rcu_head, target_tpg_free_lun); 701 701 } 702 702 703 - static struct configfs_item_operations target_fabric_port_item_ops = { 703 + static const struct configfs_item_operations target_fabric_port_item_ops = { 704 704 .release = target_fabric_port_release, 705 705 .allow_link = target_fabric_port_link, 706 706 .drop_link = target_fabric_port_unlink, ··· 726 726 return; 727 727 } 728 728 729 - static struct configfs_group_operations target_fabric_port_stat_group_ops = { 729 + static const struct configfs_group_operations target_fabric_port_stat_group_ops = { 730 730 .make_group = target_core_port_stat_mkdir, 731 731 .drop_item = target_core_port_stat_rmdir, 732 732 }; ··· 787 787 config_item_put(item); 788 788 } 789 789 790 - static struct configfs_group_operations target_fabric_lun_group_ops = { 790 + static const struct configfs_group_operations target_fabric_lun_group_ops = { 791 791 .make_group = &target_fabric_make_lun, 792 792 .drop_item = &target_fabric_drop_lun, 793 793 }; ··· 812 812 tf->tf_ops->fabric_drop_tpg(se_tpg); 813 813 } 814 814 815 - static struct configfs_item_operations target_fabric_tpg_base_item_ops = { 815 + static const struct configfs_item_operations target_fabric_tpg_base_item_ops = { 816 816 .release = target_fabric_tpg_release, 817 817 }; 818 818 ··· 998 998 tf->tf_ops->fabric_drop_wwn(wwn); 999 999 } 1000 1000 1001 - static struct configfs_item_operations target_fabric_tpg_item_ops = { 1001 + static const struct configfs_item_operations target_fabric_tpg_item_ops = { 1002 1002 .release = target_fabric_release_wwn, 1003 1003 }; 1004 1004 1005 - static struct configfs_group_operations target_fabric_tpg_group_ops = { 1005 + static const struct configfs_group_operations target_fabric_tpg_group_ops = { 1006 1006 .make_group = target_fabric_make_tpg, 1007 1007 .drop_item = target_fabric_drop_tpg, 1008 1008 }; ··· 1144 1144 config_item_put(item); 1145 1145 } 1146 1146 1147 - static struct configfs_group_operations target_fabric_wwn_group_ops = { 1147 + static const struct configfs_group_operations target_fabric_wwn_group_ops = { 1148 1148 .make_group = target_fabric_make_wwn, 1149 1149 .drop_item = target_fabric_drop_wwn, 1150 1150 };