Skip to content

Commit

Permalink
mei: bus: elminate variable length arrays
Browse files Browse the repository at this point in the history
Though VLA are supported by CC99 there are many cavities
and should be avoided.

'const size_t len = sizeof()' that we used may not be set
at the compile time hence generating VLA code.

This fixes also sparse warning
warning: Variable length array is used type.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Tomas Winkler authored and gregkh committed Apr 8, 2017
1 parent 3fcbab6 commit dd04eec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/misc/mei/bus-fixup.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ struct mkhi_msg {
u8 data[0];
} __packed;

#define MKHI_OSVER_BUF_LEN (sizeof(struct mkhi_msg_hdr) + \
sizeof(struct mkhi_fwcaps) + \
sizeof(struct mei_os_ver))
static int mei_osver(struct mei_cl_device *cldev)
{
const size_t size = sizeof(struct mkhi_msg_hdr) +
sizeof(struct mkhi_fwcaps) +
sizeof(struct mei_os_ver);
char buf[size];
const size_t size = MKHI_OSVER_BUF_LEN;
char buf[MKHI_OSVER_BUF_LEN];
struct mkhi_msg *req;
struct mkhi_fwcaps *fwcaps;
struct mei_os_ver *os_ver;
Expand Down

0 comments on commit dd04eec

Please sign in to comment.