Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1229552

Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters

From Raphaël Beamonte <raphael.beamonte@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
Date 2015-09-21 18:40 +0200
Message-ID <qbcie-3Gm-25@gated-at.bofh.it> (permalink)
References <q7r69-3lW-3@gated-at.bofh.it> <qaQrn-6fo-9@gated-at.bofh.it> <qaQB5-6qO-21@gated-at.bofh.it> <qb13r-4sC-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


2015-09-20 22:16 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
> On Sun, Sep 20, 2015 at 01:14:14PM -0400, Raphaël Beamonte wrote:
>> Add some temporary variables to reduce line length under the maximum
>> of 80 characters, as per the kernel code style.
>>
>> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
>> ---
>>  drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
>>  1 file changed, 94 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
>> index 28b54ba..2abc3e77 100644
>> --- a/drivers/staging/rtl8192u/r8192U_core.c
>> +++ b/drivers/staging/rtl8192u/r8192U_core.c
>> @@ -171,6 +171,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>>  {
>>       int i, max_chan = -1, min_chan = -1;
>>       struct ieee80211_device *ieee = priv->ieee80211;
>> +     struct CHANNEL_LIST cl;
>
> A whole structure on the stack?  Are you sure you want to do that?

Nope. I don't want to. I don't know what I was thinking, or if even I
was. Sorry for that, should have been a pointer.

>>
>>       switch (channel_plan) {
>>       case COUNTRY_CODE_FCC:
>> @@ -194,15 +195,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>>                                "unknown rf chip, can't set channel map in function:%s()\n",
>>                                __func__);
>>               }
>> -             if (ChannelPlan[channel_plan].Len != 0) {
>> +             cl = ChannelPlan[channel_plan];
>
> You just did a memory copy of a whole structure, did you really want to
> do that?  If so, why?  You just changed the logic of this function,
> potentially slowing things down and setting yourself up for causing real
> bugs (hint, anything you now change in that structure is not going to be
> ever saved, it will go away after the function is exited.)

You're right. Should have been a pointer. Sorry again, that wasn't the
intention.

> Please be more aware of how structures and pointers work in C before
> doing changes like this, I can't take this change.
>
>> +             if (cl.Len != 0) {
>>                       /* Clear old channel map */
>>                       memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
>>                              sizeof(GET_DOT11D_INFO(ieee)->channel_map));
>>                       /* Set new channel map */
>> -                     for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
>> -                             if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
>> +                     for (i = 0; i < cl.Len; i++) {
>> +                             u8 chan = cl.Channel[i];
>> +
>> +                             if (chan < min_chan || chan > max_chan)
>>                                       break;
>> -                             GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
>> +                             GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
>>                       }
>>               }
>>               break;
>> @@ -1649,9 +1653,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>>                                         &zero, 0, tx_zero_isr, dev);
>>                       status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
>>                       if (status) {
>> +                             atomic_t tx =
>> +                                     priv->tx_pending[tcb_desc->queue_index];
>
> Oh that's funny, think about what you just did here.

Also should have been a pointer. I'll do a more thorough recheck of
that patch before re-sending it. Thanks for your review and your time!

> Please get some more experience with C before doing kernel development.
> C is tricky and will let you shoot yourself in the foot and any other
> body part if you are not _VERY_ careful.  You just blew off a few limbs
> without realizing it at all in just the first two changes you made.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
    Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
      Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 07:10 +0200
        Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:20 +0200
          Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 20:30 +0200
  [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  Re: [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks  to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
  [PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
    [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
    [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
      Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-21 06:40 +0200
        Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-21 18:40 +0200
    [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200

csiph-web