net/ice/base: use macro to get variable size array length
Use the FLEX_ARRAY_SIZE() helper with the recently added flexible array members in structures. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com> Acked-by: Qiming Yang <qiming.yang@intel.com>
This commit is contained in:
parent
fd1173d75c
commit
b2176f760b
@ -1704,7 +1704,7 @@ ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
|
||||
if (!buf)
|
||||
return ICE_ERR_PARAM;
|
||||
|
||||
if (buf_size < (num_entries * sizeof(buf->elem[0])))
|
||||
if (buf_size < FLEX_ARRAY_SIZE(buf, elem, num_entries))
|
||||
return ICE_ERR_PARAM;
|
||||
|
||||
ice_fill_dflt_direct_cmd_desc(&desc, opc);
|
||||
|
@ -1833,7 +1833,7 @@ ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count)
|
||||
bld->reserved_section_table_entries += count;
|
||||
|
||||
data_end = LE16_TO_CPU(buf->data_end) +
|
||||
(count * sizeof(buf->section_entry[0]));
|
||||
FLEX_ARRAY_SIZE(buf, section_entry, count);
|
||||
buf->data_end = CPU_TO_LE16(data_end);
|
||||
|
||||
return ICE_SUCCESS;
|
||||
|
@ -44,6 +44,10 @@
|
||||
#define ice_struct_size(ptr, field, num) \
|
||||
(sizeof(*(ptr)) + sizeof(*(ptr)->field) * (num))
|
||||
|
||||
#ifndef FLEX_ARRAY_SIZE
|
||||
#define FLEX_ARRAY_SIZE(_ptr, _mem, cnt) ((cnt) * sizeof(_ptr->_mem[0]))
|
||||
#endif /* FLEX_ARRAY_SIZE */
|
||||
|
||||
#include "ice_status.h"
|
||||
#include "ice_hw_autogen.h"
|
||||
#include "ice_devids.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user