Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1530783 > unrolled thread
| Started by | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| First post | 2016-11-26 22:50 +0100 |
| Last post | 2016-11-29 18:00 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] of: Fix issue where code would fall through to error case. Frank Rowand <frowand.list@gmail.com> - 2016-11-26 22:50 +0100
Re: [PATCH] of: Fix issue where code would fall through to error case. Frank Rowand <frowand.list@gmail.com> - 2016-11-28 16:40 +0100
Re: [PATCH] of: Fix issue where code would fall through to error case. Rob Herring <robh+dt@kernel.org> - 2016-11-29 16:10 +0100
Re: [PATCH] of: Fix issue where code would fall through to error case. Moritz Fischer <moritz.fischer@ettus.com> - 2016-11-29 17:00 +0100
Re: [PATCH] of: Fix issue where code would fall through to error case. Frank Rowand <frowand.list@gmail.com> - 2016-11-29 18:00 +0100
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-11-26 22:50 +0100 |
| Subject | Re: [PATCH] of: Fix issue where code would fall through to error case. |
| Message-ID | <sHT17-3AO-5@gated-at.bofh.it> |
On 11/23/16 13:58, Rob Herring wrote:
> On Thu, Nov 17, 2016 at 6:10 PM, Moritz Fischer
> <moritz.fischer.private@gmail.com> wrote:
>> On Thu, Nov 17, 2016 at 4:02 PM, Frank Rowand <frowand.list@gmail.com> wrote:
>>> On 11/17/16 15:40, Frank Rowand wrote:
>>>> On 11/17/16 15:25, Moritz Fischer wrote:
>>>>> No longer fall through into the error case that prints out
>>>>> an error if no error (err = 0) occurred.
>>>>>
>>>>> Fixes d9181b20a83(of: Add back an error message, restructured)
>>>>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>>>>> ---
>>>>> drivers/of/resolver.c | 6 +++++-
>>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
>>>>> index 783bd09..785076d 100644
>>>>> --- a/drivers/of/resolver.c
>>>>> +++ b/drivers/of/resolver.c
>>>>> @@ -358,9 +358,13 @@ int of_resolve_phandles(struct device_node *overlay)
>>>>>
>>>>> err = update_usages_of_a_phandle_reference(overlay, prop, phandle);
>>>>> if (err)
>>>>> - break;
>>>>> + goto err_out;
>>>>> }
>>>>>
>>>>> + of_node_put(tree_symbols);
>>>>> +
>>>>> + return 0;
>>>>> +
>>>>> err_out:
>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>> out:
>>>>
>>>> Thanks for catching that.
>>>>
>>>> Rob, please apply.
>>>>
>>>> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
>>>>
>>>> -Frank
>>>
>>> On second thought, isn't the common pattern when clean up is needed for
>>> both the no-error path and the error path something like:
>>>
>>>
>>> out:
>>> of_node_put(tree_symbols);
>>> return err;
>>>
>>> err_out:
>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>> goto out;
>>> }
>>>
>>>
>>> I don't have a strong opinion, whatever Rob wants to take is fine with me.
>>
>> Same here. I tried to avoid the jumping back part, but if that's the
>> common pattern,
>> I can submit a v2 doing that instead.
>
> Both are ugly. Just do:
>
> if (err)
> pr_err(...);
>
> Rob
Agreed. Thanks for the touch of sanity Rob.
-Frank
[toc] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-11-28 16:40 +0100 |
| Message-ID | <sIwc9-3Rx-9@gated-at.bofh.it> |
| In reply to | #1530783 |
On 11/26/16 13:39, Frank Rowand wrote:
> On 11/23/16 13:58, Rob Herring wrote:
>> On Thu, Nov 17, 2016 at 6:10 PM, Moritz Fischer
>> <moritz.fischer.private@gmail.com> wrote:
>>> On Thu, Nov 17, 2016 at 4:02 PM, Frank Rowand <frowand.list@gmail.com> wrote:
>>>> On 11/17/16 15:40, Frank Rowand wrote:
>>>>> On 11/17/16 15:25, Moritz Fischer wrote:
>>>>>> No longer fall through into the error case that prints out
>>>>>> an error if no error (err = 0) occurred.
>>>>>>
>>>>>> Fixes d9181b20a83(of: Add back an error message, restructured)
>>>>>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>>>>>> ---
>>>>>> drivers/of/resolver.c | 6 +++++-
>>>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
>>>>>> index 783bd09..785076d 100644
>>>>>> --- a/drivers/of/resolver.c
>>>>>> +++ b/drivers/of/resolver.c
>>>>>> @@ -358,9 +358,13 @@ int of_resolve_phandles(struct device_node *overlay)
>>>>>>
>>>>>> err = update_usages_of_a_phandle_reference(overlay, prop, phandle);
>>>>>> if (err)
>>>>>> - break;
>>>>>> + goto err_out;
>>>>>> }
>>>>>>
>>>>>> + of_node_put(tree_symbols);
>>>>>> +
>>>>>> + return 0;
>>>>>> +
>>>>>> err_out:
>>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>>> out:
>>>>>
>>>>> Thanks for catching that.
>>>>>
>>>>> Rob, please apply.
>>>>>
>>>>> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
>>>>>
>>>>> -Frank
>>>>
>>>> On second thought, isn't the common pattern when clean up is needed for
>>>> both the no-error path and the error path something like:
>>>>
>>>>
>>>> out:
>>>> of_node_put(tree_symbols);
>>>> return err;
>>>>
>>>> err_out:
>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>> goto out;
>>>> }
>>>>
>>>>
>>>> I don't have a strong opinion, whatever Rob wants to take is fine with me.
>>>
>>> Same here. I tried to avoid the jumping back part, but if that's the
>>> common pattern,
>>> I can submit a v2 doing that instead.
>>
>> Both are ugly. Just do:
>>
>> if (err)
>> pr_err(...);
>>
>> Rob
>
> Agreed. Thanks for the touch of sanity Rob.
>
> -Frank
I succumbed to looking only at the few lines of code above and not the
fuller context of the file that the patch applies to.
The proposed patch was fixing the problem that a normal completion
of the for loop was falling through into the err_out label. So what
looks cleaner ("if (err) pr_err(...)") is actually not correct.
-Frank
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh+dt@kernel.org> |
|---|---|
| Date | 2016-11-29 16:10 +0100 |
| Subject | Re: [PATCH] of: Fix issue where code would fall through to error case. |
| Message-ID | <sIScG-1DN-21@gated-at.bofh.it> |
| In reply to | #1531398 |
On Mon, Nov 28, 2016 at 9:30 AM, Frank Rowand <frowand.list@gmail.com> wrote:
> On 11/26/16 13:39, Frank Rowand wrote:
>> On 11/23/16 13:58, Rob Herring wrote:
>>> On Thu, Nov 17, 2016 at 6:10 PM, Moritz Fischer
>>> <moritz.fischer.private@gmail.com> wrote:
>>>> On Thu, Nov 17, 2016 at 4:02 PM, Frank Rowand <frowand.list@gmail.com> wrote:
>>>>> On 11/17/16 15:40, Frank Rowand wrote:
>>>>>> On 11/17/16 15:25, Moritz Fischer wrote:
>>>>>>> No longer fall through into the error case that prints out
>>>>>>> an error if no error (err = 0) occurred.
>>>>>>>
>>>>>>> Fixes d9181b20a83(of: Add back an error message, restructured)
>>>>>>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>>>>>>> ---
>>>>>>> drivers/of/resolver.c | 6 +++++-
>>>>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
>>>>>>> index 783bd09..785076d 100644
>>>>>>> --- a/drivers/of/resolver.c
>>>>>>> +++ b/drivers/of/resolver.c
>>>>>>> @@ -358,9 +358,13 @@ int of_resolve_phandles(struct device_node *overlay)
>>>>>>>
>>>>>>> err = update_usages_of_a_phandle_reference(overlay, prop, phandle);
>>>>>>> if (err)
>>>>>>> - break;
>>>>>>> + goto err_out;
>>>>>>> }
>>>>>>>
>>>>>>> + of_node_put(tree_symbols);
>>>>>>> +
>>>>>>> + return 0;
>>>>>>> +
>>>>>>> err_out:
>>>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>>>> out:
>>>>>>
>>>>>> Thanks for catching that.
>>>>>>
>>>>>> Rob, please apply.
>>>>>>
>>>>>> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
>>>>>>
>>>>>> -Frank
>>>>>
>>>>> On second thought, isn't the common pattern when clean up is needed for
>>>>> both the no-error path and the error path something like:
>>>>>
>>>>>
>>>>> out:
>>>>> of_node_put(tree_symbols);
>>>>> return err;
>>>>>
>>>>> err_out:
>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>> goto out;
>>>>> }
>>>>>
>>>>>
>>>>> I don't have a strong opinion, whatever Rob wants to take is fine with me.
>>>>
>>>> Same here. I tried to avoid the jumping back part, but if that's the
>>>> common pattern,
>>>> I can submit a v2 doing that instead.
>>>
>>> Both are ugly. Just do:
>>>
>>> if (err)
>>> pr_err(...);
>>>
>>> Rob
>>
>> Agreed. Thanks for the touch of sanity Rob.
>>
>> -Frank
>
> I succumbed to looking only at the few lines of code above and not the
> fuller context of the file that the patch applies to.
>
> The proposed patch was fixing the problem that a normal completion
> of the for loop was falling through into the err_out label. So what
> looks cleaner ("if (err) pr_err(...)") is actually not correct.
What!? The *only* problem was printing the error message in the err=0
case. All that needs to be fixed is not doing that. If we do that,
then we really only need 1 goto label.
Rob
[toc] | [prev] | [next] | [standalone]
| From | Moritz Fischer <moritz.fischer@ettus.com> |
|---|---|
| Date | 2016-11-29 17:00 +0100 |
| Message-ID | <sISZ4-1UF-7@gated-at.bofh.it> |
| In reply to | #1532383 |
Hi Rob,
On Tue, Nov 29, 2016 at 09:06:08AM -0600, Rob Herring wrote:
> On Mon, Nov 28, 2016 at 9:30 AM, Frank Rowand <frowand.list@gmail.com> wrote:
> > On 11/26/16 13:39, Frank Rowand wrote:
> >> On 11/23/16 13:58, Rob Herring wrote:
> >>> On Thu, Nov 17, 2016 at 6:10 PM, Moritz Fischer
> >>> <moritz.fischer.private@gmail.com> wrote:
> >>>> On Thu, Nov 17, 2016 at 4:02 PM, Frank Rowand <frowand.list@gmail.com> wrote:
> >>>>> On 11/17/16 15:40, Frank Rowand wrote:
> >>>>>> On 11/17/16 15:25, Moritz Fischer wrote:
> >>>>>>> No longer fall through into the error case that prints out
> >>>>>>> an error if no error (err = 0) occurred.
> >>>>>>>
> >>>>>>> Fixes d9181b20a83(of: Add back an error message, restructured)
> >>>>>>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> >>>>>>> ---
> >>>>>>> drivers/of/resolver.c | 6 +++++-
> >>>>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>>>>>>
> >>>>>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
> >>>>>>> index 783bd09..785076d 100644
> >>>>>>> --- a/drivers/of/resolver.c
> >>>>>>> +++ b/drivers/of/resolver.c
> >>>>>>> @@ -358,9 +358,13 @@ int of_resolve_phandles(struct device_node *overlay)
> >>>>>>>
> >>>>>>> err = update_usages_of_a_phandle_reference(overlay, prop, phandle);
> >>>>>>> if (err)
> >>>>>>> - break;
> >>>>>>> + goto err_out;
> >>>>>>> }
> >>>>>>>
> >>>>>>> + of_node_put(tree_symbols);
> >>>>>>> +
> >>>>>>> + return 0;
> >>>>>>> +
> >>>>>>> err_out:
> >>>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
> >>>>>>> out:
> >>>>>>
> >>>>>> Thanks for catching that.
> >>>>>>
> >>>>>> Rob, please apply.
> >>>>>>
> >>>>>> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
> >>>>>>
> >>>>>> -Frank
> >>>>>
> >>>>> On second thought, isn't the common pattern when clean up is needed for
> >>>>> both the no-error path and the error path something like:
> >>>>>
> >>>>>
> >>>>> out:
> >>>>> of_node_put(tree_symbols);
> >>>>> return err;
> >>>>>
> >>>>> err_out:
> >>>>> pr_err("overlay phandle fixup failed: %d\n", err);
> >>>>> goto out;
> >>>>> }
> >>>>>
> >>>>>
> >>>>> I don't have a strong opinion, whatever Rob wants to take is fine with me.
> >>>>
> >>>> Same here. I tried to avoid the jumping back part, but if that's the
> >>>> common pattern,
> >>>> I can submit a v2 doing that instead.
> >>>
> >>> Both are ugly. Just do:
> >>>
> >>> if (err)
> >>> pr_err(...);
> >>>
> >>> Rob
> >>
> >> Agreed. Thanks for the touch of sanity Rob.
> >>
> >> -Frank
> >
> > I succumbed to looking only at the few lines of code above and not the
> > fuller context of the file that the patch applies to.
> >
> > The proposed patch was fixing the problem that a normal completion
> > of the for loop was falling through into the err_out label. So what
> > looks cleaner ("if (err) pr_err(...)") is actually not correct.
>
> What!? The *only* problem was printing the error message in the err=0
> case. All that needs to be fixed is not doing that. If we do that,
> then we really only need 1 goto label.
I think you're right. Can you look at my v3 that I sent. I also tried to
fix cases where we can just do
return 0;
vs.
err = 0;
goto err
...
err:
of_node_put(NULL /*tree_symbols is NULL*/);
return err;
Thanks,
Moritz
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-11-29 18:00 +0100 |
| Message-ID | <sITV8-2B3-31@gated-at.bofh.it> |
| In reply to | #1532383 |
On 11/29/16 07:06, Rob Herring wrote:
> On Mon, Nov 28, 2016 at 9:30 AM, Frank Rowand <frowand.list@gmail.com> wrote:
>> On 11/26/16 13:39, Frank Rowand wrote:
>>> On 11/23/16 13:58, Rob Herring wrote:
>>>> On Thu, Nov 17, 2016 at 6:10 PM, Moritz Fischer
>>>> <moritz.fischer.private@gmail.com> wrote:
>>>>> On Thu, Nov 17, 2016 at 4:02 PM, Frank Rowand <frowand.list@gmail.com> wrote:
>>>>>> On 11/17/16 15:40, Frank Rowand wrote:
>>>>>>> On 11/17/16 15:25, Moritz Fischer wrote:
>>>>>>>> No longer fall through into the error case that prints out
>>>>>>>> an error if no error (err = 0) occurred.
>>>>>>>>
>>>>>>>> Fixes d9181b20a83(of: Add back an error message, restructured)
>>>>>>>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>>>>>>>> ---
>>>>>>>> drivers/of/resolver.c | 6 +++++-
>>>>>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
>>>>>>>> index 783bd09..785076d 100644
>>>>>>>> --- a/drivers/of/resolver.c
>>>>>>>> +++ b/drivers/of/resolver.c
>>>>>>>> @@ -358,9 +358,13 @@ int of_resolve_phandles(struct device_node *overlay)
>>>>>>>>
>>>>>>>> err = update_usages_of_a_phandle_reference(overlay, prop, phandle);
>>>>>>>> if (err)
>>>>>>>> - break;
>>>>>>>> + goto err_out;
>>>>>>>> }
>>>>>>>>
>>>>>>>> + of_node_put(tree_symbols);
>>>>>>>> +
>>>>>>>> + return 0;
>>>>>>>> +
>>>>>>>> err_out:
>>>>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>>>>> out:
>>>>>>>
>>>>>>> Thanks for catching that.
>>>>>>>
>>>>>>> Rob, please apply.
>>>>>>>
>>>>>>> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
>>>>>>>
>>>>>>> -Frank
>>>>>>
>>>>>> On second thought, isn't the common pattern when clean up is needed for
>>>>>> both the no-error path and the error path something like:
>>>>>>
>>>>>>
>>>>>> out:
>>>>>> of_node_put(tree_symbols);
>>>>>> return err;
>>>>>>
>>>>>> err_out:
>>>>>> pr_err("overlay phandle fixup failed: %d\n", err);
>>>>>> goto out;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I don't have a strong opinion, whatever Rob wants to take is fine with me.
>>>>>
>>>>> Same here. I tried to avoid the jumping back part, but if that's the
>>>>> common pattern,
>>>>> I can submit a v2 doing that instead.
>>>>
>>>> Both are ugly. Just do:
>>>>
>>>> if (err)
>>>> pr_err(...);
>>>>
>>>> Rob
>>>
>>> Agreed. Thanks for the touch of sanity Rob.
>>>
>>> -Frank
>>
>> I succumbed to looking only at the few lines of code above and not the
>> fuller context of the file that the patch applies to.
>>
>> The proposed patch was fixing the problem that a normal completion
>> of the for loop was falling through into the err_out label. So what
>> looks cleaner ("if (err) pr_err(...)") is actually not correct.
>
> What!? The *only* problem was printing the error message in the err=0
> case. All that needs to be fixed is not doing that. If we do that,
> then we really only need 1 goto label.
>
> Rob
I misread your original suggestion to mean to put the "if (err) pr_err(...)"
inside the for loop, where Moritz had made his changes.
Now I understand what you really meant, to put the "if (err) pr_err(...)"
after the for loop.
Yes, that is a good way to do it.
Sorry for the extra noise....
-Frank
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web