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


Groups > linux.kernel > #1732769

Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code

From Ludovic BARRE <ludovic.barre@st.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code
Date 2017-09-15 10:10 +0200
Message-ID <upTRf-5K-11@gated-at.bofh.it> (permalink)
References (1 earlier) <upCx4-5BF-9@gated-at.bofh.it> <upE5Q-6HF-15@gated-at.bofh.it> <upEfw-6KR-17@gated-at.bofh.it> <upFED-7zL-29@gated-at.bofh.it> <upK1z-1Uw-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 09/14/2017 11:38 PM, Arnd Bergmann wrote:
> On Thu, Sep 14, 2017 at 6:55 PM, Ludovic BARRE <ludovic.barre@st.com> wrote:
>>
>>
>> On 09/14/2017 05:24 PM, Geert Uytterhoeven wrote:
>>>
>>> Hi Ludovic,
>>>
>>> On Thu, Sep 14, 2017 at 5:13 PM, Ludovic BARRE <ludovic.barre@st.com>
>>> wrote:
>>>>
>>>> On 09/14/2017 03:38 PM, Geert Uytterhoeven wrote:
>>>>
>>>> hi Arnd, Geert
>>>>
>>>> sorry, I was forgot this thread while my holidays
>>>>
>>>> Geert: what do you mean like "similar bugs in the future" in "If you
>>>> initialized ret at the beginning, you lose the ability to catch newly
>>>> introduced similar bugs in the future."
>>>
>>>
>>> If you pre-initialize ret at the top, you loose the ability of the
>>> compiler
>>> to detect at compile-time if ret is never written to later. It will just
>>> return
>>> -EINVAL at runtime.
>>>
>>> With my version, if the code is modified later and another "return ret" is
>>> added, the compiler will detect if there's a code path that forgets
>>> to assign a value to ret.
>>
>> Ok, it's clear for me.
>> I favor geert's solution.
>> Arnd what do you think ?
> 
> I usually follow the same rule that Geert explained (and quote
> https://rusty.ozlabs.org/?p=232 when I do so). In this case, there
> did not seem to be much value as the variable is not used
> afterwards, and I kept the 'single return statement' guideline.
> 
> In the end, either version seems totally fine to me here, so
> please use Geert's if you prefer that.

thank Arnd for your answer, great link :-)
we take geert's patch.

Geert: I will acked your patch.

thanks everybody
> 
>          Arnd
> 

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


Thread

[PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code Arnd Bergmann <arnd@arndb.de> - 2017-09-14 13:10 +0200
  Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return  code Ludovic BARRE <ludovic.barre@st.com> - 2017-09-14 14:50 +0200
  Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-14 15:40 +0200
    Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return  code Ludovic BARRE <ludovic.barre@st.com> - 2017-09-14 17:20 +0200
      Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-14 17:30 +0200
        Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return  code Ludovic BARRE <ludovic.barre@st.com> - 2017-09-14 19:00 +0200
          Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code Arnd Bergmann <arnd@arndb.de> - 2017-09-14 23:40 +0200
            Re: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return  code Ludovic BARRE <ludovic.barre@st.com> - 2017-09-15 10:10 +0200

csiph-web