[PATCH v6 04/11] wifi: ath12k: add P2P IE in beacon template

Kalle Valo kvalo at kernel.org
Tue Feb 6 01:52:35 PST 2024


Jeff Johnson <quic_jjohnson at quicinc.com> writes:

> On 2/5/2024 8:17 AM, Kalle Valo wrote:
>> Kang Yang <quic_kangyang at quicinc.com> writes:
>>> +	if (WARN_ON(skb->len < ie_offset))
>>> +		return -EINVAL;
>>> +
>>> +	ie = (u8 *)cfg80211_find_vendor_ie(oui, oui_type,
>>> +					   skb->data + ie_offset,
>>> +					   skb->len - ie_offset);
>> 
>> So cfg80211_find_vendor_ie() returns:
>> 
>> static inline const u8 *
>> cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
>> 			const u8 *ies, unsigned int len)
>> 
>> You are casting away the const here. I see that other drivers do the
>> same as the assumption is that the pointer points to the same buffer,
>> but I still don't really like casting away const. Thoughts?
>
> I'm not a fan of typecasting either.
>
> However, the problem here is that from the perspective of
> cfg80211_find_vendor_ie() the buffer is const (not modified in any way
> by the function), but from the perspective of every caller the buffer is
> part of a message that is in RAM.
>
> So you have to decide if you want to change the prototype to remove the
> const from cfg80211_find_vendor_ie() or if you want to keep the current
> semantic to cast away the const.
>
> This is one of the rare cases where I think the typecast is ok.

Makes sense, thanks for the comment.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



More information about the ath12k mailing list