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


Groups > linux.kernel > #1576574

Re: [PATCH] staging: comedi: Fix incorrect type assignment

From Karthik Nayak <karthik.188@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: comedi: Fix incorrect type assignment
Date 2017-02-08 14:30 +0100
Message-ID <t8AtP-Rq-3@gated-at.bofh.it> (permalink)
References <t8jsZ-6U2-7@gated-at.bofh.it> <t8AtP-Rq-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

On Wed, Feb 8, 2017 at 6:43 PM, Ian Abbott <abbotti@mev.co.uk> wrote:
> On 07/02/17 19:06, Karthik Nayak wrote:
>>
>> This patch fixes the following sparse error:
>> drivers/staging/comedi/drivers//ni_pcimio.c:1229:32: warning: incorrect
>> type in assignment (different base types)
>> drivers/staging/comedi/drivers//ni_pcimio.c:1229:32:    expected
>> restricted __be32 [usertype] serial_number
>> drivers/staging/comedi/drivers//ni_pcimio.c:1229:32:    got unsigned int
>>
>> This is done by introducing a temporary variable which is of type
>> '__be32' and converting the existing variable to type 'unsigned int'.
>>
>> Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
>> ---
>>  drivers/staging/comedi/drivers/ni_pcimio.c | 5 +++--
>>  drivers/staging/comedi/drivers/ni_stc.h    | 2 +-
>>  2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c
>> b/drivers/staging/comedi/drivers/ni_pcimio.c
>> index cdb66eab1292..4f45a5c230ad 100644
>> --- a/drivers/staging/comedi/drivers/ni_pcimio.c
>> +++ b/drivers/staging/comedi/drivers/ni_pcimio.c
>> @@ -1207,6 +1207,7 @@ static void m_series_init_eeprom_buffer(struct
>> comedi_device *dev)
>>         unsigned int old_iodwbsr_bits;
>>         unsigned int old_iodwbsr1_bits;
>>         unsigned int old_iodwcr1_bits;
>> +       __be32 serial_number;
>>         int i;
>>
>>         /* IO Window 1 needs to be temporarily mapped to read the eeprom
>> */
>> @@ -1223,10 +1224,10 @@ static void m_series_init_eeprom_buffer(struct
>> comedi_device *dev)
>>
>>         BUG_ON(serial_number_eeprom_length >
>> sizeof(devpriv->serial_number));
>>         for (i = 0; i < serial_number_eeprom_length; ++i) {
>> -               char *byte_ptr = (char *)&devpriv->serial_number + i;
>> +               char *byte_ptr = (char *)&serial_number + i;
>>                 *byte_ptr = ni_readb(dev, serial_number_eeprom_offset +
>> i);
>>         }
>> -       devpriv->serial_number = be32_to_cpu(devpriv->serial_number);
>> +       devpriv->serial_number = be32_to_cpu(serial_number);
>>
>>         for (i = 0; i < M_SERIES_EEPROM_SIZE; ++i)
>>                 devpriv->eeprom_buffer[i] = ni_readb(dev, Start_Cal_EEPROM
>> + i);
>> diff --git a/drivers/staging/comedi/drivers/ni_stc.h
>> b/drivers/staging/comedi/drivers/ni_stc.h
>> index f27b545f83eb..b5eca0da71eb 100644
>> --- a/drivers/staging/comedi/drivers/ni_stc.h
>> +++ b/drivers/staging/comedi/drivers/ni_stc.h
>> @@ -1031,7 +1031,7 @@ struct ni_private {
>>
>>         unsigned short ai_fifo_buffer[0x2000];
>>         u8 eeprom_buffer[M_SERIES_EEPROM_SIZE];
>> -       __be32 serial_number;
>> +       unsigned int serial_number;
>>
>>         struct mite *mite;
>>         struct mite_channel *ai_mite_chan;
>>
>
> That looks fine, thanks!
>
> (On a side note, nothing actually uses serial number, so the code that reads
> it from the EEPROM could just be ripped out.)
>
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
>

Yea, I saw that, was assuming there might be a purposed use case scenario.

Do you want me to send another patch?

-- 
Regards,
Karthik Nayak

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


Thread

[PATCH] staging: comedi: Fix incorrect type assignment Karthik Nayak <karthik.188@gmail.com> - 2017-02-07 20:20 +0100
  Re: [PATCH] staging: comedi: Fix incorrect type assignment Karthik Nayak <karthik.188@gmail.com> - 2017-02-08 14:30 +0100
    Re: [PATCH] staging: comedi: Fix incorrect type assignment Ian Abbott <abbotti@mev.co.uk> - 2017-02-08 15:10 +0100
      Re: [PATCH] staging: comedi: Fix incorrect type assignment Karthik Nayak <karthik.188@gmail.com> - 2017-02-08 16:40 +0100
  Re: [PATCH] staging: comedi: Fix incorrect type assignment Ian Abbott <abbotti@mev.co.uk> - 2017-02-08 14:30 +0100
  [PATCH 2/2] staging: comedi: drop unused variable from struct 'ni_private' Karthik Nayak <karthik.188@gmail.com> - 2017-02-08 18:30 +0100
    Re: [PATCH 2/2] staging: comedi: drop unused variable from struct  'ni_private' Ian Abbott <abbotti@mev.co.uk> - 2017-02-08 18:50 +0100
      Re: [PATCH 2/2] staging: comedi: drop unused variable from struct 'ni_private' Karthik Nayak <karthik.188@gmail.com> - 2017-02-08 21:20 +0100
        Re: [PATCH 2/2] staging: comedi: drop unused variable from struct 'ni_private' Karthik Nayak <karthik.188@gmail.com> - 2017-02-08 23:30 +0100

csiph-web