Search Linux Wireless

Re: [PATCH 1/2] wifi: cfg80211: avoid extra calls to strlen() in ieee80211_bss()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2023-08-30 at 07:33 +0300, Dmitry Antipov wrote:
> Since 'sprintf()' returns the number of characters emitted, an
> extra calls to 'strlen()' in 'ieee80211_bss()' may be dropped.

This should probably mention wext/"wireless extensions" somewhere - I
got confused at first why we even had strlen() :-)

> Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
> ---
>  net/wireless/scan.c | 42 ++++++++++++++++++++----------------------
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/net/wireless/scan.c b/net/wireless/scan.c
> index 0cf1ce7b6934..4f4990ca7ba7 100644
> --- a/net/wireless/scan.c
> +++ b/net/wireless/scan.c
> @@ -3422,59 +3422,58 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
>  			cfg = (u8 *)ie + 2;
>  			memset(&iwe, 0, sizeof(iwe));
>  			iwe.cmd = IWEVCUSTOM;
> -			sprintf(buf, "Mesh Network Path Selection Protocol ID: "
> -				"0x%02X", cfg[0]);
> -			iwe.u.data.length = strlen(buf);
> +			iwe.u.data.length = sprintf(buf, "Mesh Network Path "
> +						    "Selection Protocol ID: "
> +						    "0x%02X", cfg[0]);

I don't think we should make this worse and break the strings in _more_
places ... it's OK to go above 80 columns for strings.

So probably better written as

sprintf(buf,
        "....",
        ...);

here and in all the other places too.

johannes




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux