selinux: use ARRAY_SIZE macro
Subsystems (2)
PATCH 1/1 selinux: use ARRAY_SIZE macro
Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]).
Signed-off-by Nicolas Kaiser <[email protected]>
---
security/selinux/selinuxfs.c +2 -2
@@ -376,7 +376,7 @@ static ssize_t selinux_transaction_writechar *data;ssize_t rv; -if (ino >=sizeof (write_op)/sizeof (write_op[0 ]) || !write_op[ino]) +if (ino >=ARRAY_SIZE (write_op) || !write_op[ino])return -EINVAL ; data =simple_transaction_get (file, buf, size);
@@ -1161,7 +1161,7 @@ static int sel_make_avc_files(struct den#endif }; -for (i =0 ; i <sizeof (files) /sizeof (files[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (files); i++) {struct inode *inode;struct dentry *dentry;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 1 line · Nicolas Kaiser
Use
ARRAY_SIZEmacro instead of sizeof(x)/sizeof(x[0]).
You missed two of them (at least your subjects tells you did the whole security/selinux)
Updated patch attached.
BTW: I've got a whole lot of these hanging here for various areas. I just need some time to submit them. :-/
Signed-off-by Tobias Klauser <[email protected]>
---
selinuxfs.c | 4 ++-- ss/avtab.c | 2 +- ss/policydb.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
security/selinux/selinuxfs.c +2 -2
@@ -376,7 +376,7 @@ static ssize_t selinux_transaction_writechar *data;ssize_t rv; -if (ino >=sizeof (write_op)/sizeof (write_op[0 ]) || !write_op[ino]) +if (ino >=ARRAY_SIZE (write_op) || !write_op[ino])return -EINVAL ; data =simple_transaction_get (file, buf, size);
@@ -1161,7 +1161,7 @@ static int sel_make_avc_files(struct den#endif }; -for (i =0 ; i <sizeof (files) /sizeof (files[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (files); i++) {struct inode *inode;struct dentry *dentry;
security/selinux/ss/avtab.c +1 -1
@@ -359,7 +359,7 @@ int avtab_read_item(void *fp, u32 vers,return -1 ; } -for (i =0 ; i <sizeof (spec_order)/sizeof (u16); i++) { +for (i =0 ; i <ARRAY_SIZE (spec_order); i++) {if (val & spec_order[i]) { key.specified = spec_order[i] | enabled; datum.data =le32_to_cpu (buf32[items++]);
security/selinux/ss/policydb.c +1 -1
@@ -103,7 +103,7 @@ static struct policydb_compat_info *poliint i;struct policydb_compat_info *info =NULL ; -for (i =0 ; i <sizeof (policydb_compat)/sizeof (*info); i++) { +for (i =0 ; i <ARRAY_SIZE (policydb_compat); i++) {if (policydb_compat[i].version == version) { info = &policydb_compat[i];break ;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors