[PATCH v2 125/148] net/ice/base: fix compile issues on some targets
Bruce Richardson
bruce.richardson at intel.com
Tue Jun 18 19:05:27 CEST 2024
On Wed, Jun 12, 2024 at 04:01:59PM +0100, Anatoly Burakov wrote:
> To avoid triggering compile errors reported on some targets, use
> explicit type casts to specify type conversion.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
> drivers/net/ice/base/ice_flow.h | 2 +-
> drivers/net/ice/base/ice_parser.c | 7 ++++---
> drivers/net/ice/base/ice_ptp_hw.c | 9 +++++----
> drivers/net/ice/base/ice_switch.c | 7 ++++---
> 4 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
> index fd2ec39c1e..65b261beca 100644
> --- a/drivers/net/ice/base/ice_flow.h
> +++ b/drivers/net/ice/base/ice_flow.h
> @@ -485,7 +485,7 @@ struct ice_flow_entry {
> u8 acts_cnt;
> };
>
> -#define ICE_FLOW_ENTRY_HNDL(e) ((intptr_t)e)
> +#define ICE_FLOW_ENTRY_HNDL(e) ((u64)e)
> #define ICE_FLOW_ENTRY_PTR(h) ((struct ice_flow_entry *)(h))
>
> struct ice_flow_prof {
> diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
> index c9bcf9ea5e..e242fa8353 100644
> --- a/drivers/net/ice/base/ice_parser.c
> +++ b/drivers/net/ice/base/ice_parser.c
> @@ -96,7 +96,7 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
> if (index >= LE16_TO_CPU(hdr->count))
> return NULL;
>
> - return (void *)((uintptr_t)section + data_off + index * size);
> + return (void *)((u64)section + data_off + index * size);
> }
>
This change (and below) gives compilation errors with 32-bit, since you are
casting from a 64-bit int to a 32-bit pointer. Better to keep as uintptr_t.
> /**
> @@ -146,9 +146,10 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
> if (no_offset)
> idx++;
> else
> - idx = hdr->offset + state.entry_idx;
> + idx = LE16_TO_CPU(hdr->offset) +
> + state.entry_idx;
> parse_item(hw, idx,
> - (void *)((uintptr_t)table + idx * item_size),
> + (void *)((u64)table + idx * item_size),
> data, item_size);
> }
> } while (data);
/Bruce
More information about the dev
mailing list