Search Linux Wireless

Re: [PATCH 1/2] ath11k: mac: fix too long line

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

 



Jeff Johnson <quic_jjohnson@xxxxxxxxxxx> writes:

> On 5/3/2022 10:58 PM, Kalle Valo wrote:
>> Jeff Johnson <quic_jjohnson@xxxxxxxxxxx> writes:
> pe>> is there a reason to not declare deflink here?
>>> then its scope of definition would equal the scope of usage
>>
>> In ath10k and ath11k I have tried to avoid that and instead declare all
>> variables in the beginning of the function, this is to keep the code
>> simple. Of course there are few cases where a variable is declared in
>> the middle of the function, but that's just sloppy review on my part. I
>> feel that it's better to refactor the function into smaller functions
>> than start declaring variables in the middle of functions. Does that
>> make sense?
>>
>
> This is really an academic question.
>
> In the larger kernel community I'm seeing a push to reduce the scope
> of identifiers in some cases:
> 1) declaring loop control variables within the actual loop control operation
> 2) prohibiting the access to list iterators outside the list iteration loop

Yeah, those are definitely good examples when to limit scope.

And of course this isn't a hard rule, in some cases we have to make
exceptions. For example ath11k_mac_op_bss_info_changed() and
ath11k_mac_op_sta_state() are long functions but trying to split them to
smaller functions most likely makes them harder to read. So for these
functions having variables declared within if blocks would sound like a
good idea, I think it would make the functions more readable.

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

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



[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