[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202308011532.A92CFB351@keescook>
Date: Tue, 1 Aug 2023 15:35:21 -0700
From: Kees Cook <keescook@...omium.org>
To: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Cc: Jacob Keller <jacob.e.keller@...el.com>,
intel-wired-lan@...ts.osuosl.org, netdev@...r.kernel.org,
Alexander Lobakin <aleksander.lobakin@...el.com>
Subject: Re: [RFC net-next 2/2] ice: make use of DECLARE_FLEX() in
ice_switch.c
On Tue, Aug 01, 2023 at 01:19:23PM +0200, Przemek Kitszel wrote:
> Use DECLARE_FLEX() macro for 1-elem flex array members of ice_switch.c
>
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
> ---
> drivers/net/ethernet/intel/ice/ice_switch.c | 53 +++++----------------
> 1 file changed, 12 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
> index a7afb612fe32..41679cb6b548 100644
> --- a/drivers/net/ethernet/intel/ice/ice_switch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_switch.c
> @@ -1812,15 +1812,11 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
> enum ice_sw_lkup_type lkup_type,
> enum ice_adminq_opc opc)
> {
> - struct ice_aqc_alloc_free_res_elem *sw_buf;
> + DECLARE_FLEX(struct ice_aqc_alloc_free_res_elem *, sw_buf, elem, 1);
> + u16 buf_len = struct_size(sw_buf, elem, 1);
With the macro I suggested, I think this line can become:
u16 buf_len = __builtin_object_size(sw_buf, 1);
but either is fine. (N.B. the "1" here is a bitfield, not the "1" size
above).
-Kees
--
Kees Cook
Powered by blists - more mailing lists