]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cifs: cifspdu.h: Replace one-element array with flexible-array member
authorGustavo A. R. Silva <gustavoars@kernel.org>
Fri, 26 Mar 2021 01:11:17 +0000 (20:11 -0500)
committerSteve French <stfrench@microsoft.com>
Tue, 13 Apr 2021 04:54:49 +0000 (23:54 -0500)
commitcc2b8993f5d35372935f5891fcce11600c1b093f
tree375034ee598db1f6b6019b4ad9c1e6449db91624
parent69a04d6d84dba70ef35fd55e72365723b4312239
cifs: cifspdu.h: Replace one-element array with flexible-array member

There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Also, this helps with the ongoing efforts to enable -Warray-bounds by
fixing the following warning:

  CC [M]  fs/cifs/cifssmb.o
fs/cifs/cifssmb.c: In function ‘CIFSFindNext’:
fs/cifs/cifssmb.c:4636:23: warning: array subscript 1 is above array bounds of ‘char[1]’ [-Warray-bounds]
 4636 |   pSMB->ResumeFileName[name_len+1] = 0;
      |   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifspdu.h