]> git.baikalelectronics.ru Git - kernel.git/commit
cifs: misc: Use array_size() in if-statement controlling expression
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 15 Jun 2020 22:41:12 +0000 (17:41 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 24 Jun 2020 00:06:27 +0000 (19:06 -0500)
commit6929be2bf616e51ee592c81131b38b146a346919
tree51048f8904b98eb8d54af4bcaf0469117405eec7
parent5dd9bab1444a3b5424e4ddce8d94af2072f88490
cifs: misc: Use array_size() in if-statement controlling expression

Use array_size() instead of the open-coded version in the controlling
expression of the if statement.

Also, while there, use the preferred form for passing a size of a struct.
The alternative form where struct name is spelled out hurts readability
and introduces an opportunity for a bug when the pointer variable type is
changed but the corresponding sizeof that is passed as argument is not.

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/misc.c