From: Kees Cook <keescook@chromium.org>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org
Subject: Re: [Intel-wired-lan] [RFC net-next 2/2] ice: make use of DECLARE_FLEX() in ice_switch.c
Date: Tue, 1 Aug 2023 15:35:21 -0700 [thread overview]
Message-ID: <202308011532.A92CFB351@keescook> (raw)
In-Reply-To: <20230801111923.118268-3-przemyslaw.kitszel@intel.com>
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@intel.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
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
prev parent reply other threads:[~2023-08-01 22:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 11:19 [Intel-wired-lan] [RFC net-next 0/2] introduce DECLARE_FLEX() macro Przemek Kitszel
2023-08-01 11:19 ` [Intel-wired-lan] [RFC net-next 1/2] overflow: add DECLARE_FLEX() for on-stack allocs Przemek Kitszel
2023-08-01 13:54 ` Alexander Lobakin
2023-08-01 14:18 ` Przemek Kitszel
2023-08-01 17:15 ` Alexander Lobakin
2023-08-01 22:31 ` Kees Cook
2023-08-04 10:59 ` Przemek Kitszel
2023-08-04 15:49 ` Alexander Lobakin
2023-08-04 13:47 ` Przemek Kitszel
2023-08-04 15:44 ` Alexander Lobakin
2023-08-07 12:42 ` Przemek Kitszel
2023-08-07 14:47 ` Kees Cook
2023-08-04 22:39 ` Kees Cook
2023-08-01 11:19 ` [Intel-wired-lan] [RFC net-next 2/2] ice: make use of DECLARE_FLEX() in ice_switch.c Przemek Kitszel
2023-08-01 13:48 ` Alexander Lobakin
2023-08-01 14:36 ` Przemek Kitszel
2023-08-01 17:22 ` Alexander Lobakin
2023-08-01 22:35 ` Kees Cook [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202308011532.A92CFB351@keescook \
--to=keescook@chromium.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox