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


Groups > linux.kernel > #1462293 > unrolled thread

Re: [PATCH] CodingStyle: Clarify and complete chapter 7

Started byJonathan Corbet <corbet@lwn.net>
First post2016-08-14 20:40 +0200
Last post2016-08-15 17:40 +0200
Articles 4 — 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.


Contents

  Re: [PATCH] CodingStyle: Clarify and complete chapter 7 Jonathan Corbet <corbet@lwn.net> - 2016-08-14 20:40 +0200
    Re: [PATCH] CodingStyle: Clarify and complete chapter 7 Mark D Rustad <mrustad@gmail.com> - 2016-08-14 22:20 +0200
      Re: [PATCH] CodingStyle: Clarify and complete chapter 7 Jonathan Corbet <corbet@lwn.net> - 2016-08-14 22:50 +0200
      Re: CodingStyle: Clarify and complete chapter 7 SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-15 17:40 +0200

#1462293 — Re: [PATCH] CodingStyle: Clarify and complete chapter 7

FromJonathan Corbet <corbet@lwn.net>
Date2016-08-14 20:40 +0200
SubjectRe: [PATCH] CodingStyle: Clarify and complete chapter 7
Message-ID<s68ue-3cX-17@gated-at.bofh.it>
On Mon, 25 Jul 2016 14:29:06 +0200
Jean Delvare <jdelvare@suse.de> wrote:

> Chapter 7 (Centralized exiting of functions) of the coding style
> documentation is unclear at times, and lacks some information (such
> as the possibility to indent labels with a single space.) Clarify and
> complete it.

OK, I've applied this (finally) to the docs tree, sorry for sitting on it
for so long.  One question, though...

>  A common type of bug to be aware of is "one err bugs" which look like this:
>  
> -	err:
> +	 err:
>  		kfree(foo->bar);
>  		kfree(foo);
>  		return ret;
>  
>  The bug in this code is that on some exit paths "foo" is NULL.  Normally the

...except that kfree() can handle null pointers just fine, so this isn't
actually a bug, right?  Someday when somebody has time it would be good to
come up with a better example.

Thanks,

jon

[toc] | [next] | [standalone]


#1462334

FromMark D Rustad <mrustad@gmail.com>
Date2016-08-14 22:20 +0200
Message-ID<s6a2Z-4oa-13@gated-at.bofh.it>
In reply to#1462293

[Multipart message — attachments visible in raw view] — view raw

Jonathan Corbet <corbet@lwn.net> wrote:

> On Mon, 25 Jul 2016 14:29:06 +0200
> Jean Delvare <jdelvare@suse.de> wrote:
>
>> Chapter 7 (Centralized exiting of functions) of the coding style
>> documentation is unclear at times, and lacks some information (such
>> as the possibility to indent labels with a single space.) Clarify and
>> complete it.
>
> OK, I've applied this (finally) to the docs tree, sorry for sitting on it
> for so long.  One question, though...
>
>> A common type of bug to be aware of is "one err bugs" which look like  
>> this:
>>
>> -	err:
>> +	 err:
>>  		kfree(foo->bar);
>>  		kfree(foo);
>>  		return ret;
>>
>>  The bug in this code is that on some exit paths "foo" is NULL.  Normally the
>
> ...except that kfree() can handle null pointers just fine, so this isn't
> actually a bug, right?  Someday when somebody has time it would be good to
> come up with a better example.

But if foo is NULL, foo->bar is not NULL and so kfree will have a problem  
with it. So this is a bug.

--
Mark Rustad, MRustad@gmail.com

[toc] | [prev] | [next] | [standalone]


#1462397

FromJonathan Corbet <corbet@lwn.net>
Date2016-08-14 22:50 +0200
Message-ID<s6aw1-4AX-1@gated-at.bofh.it>
In reply to#1462334
On Sun, 14 Aug 2016 13:12:33 -0700
Mark D Rustad <mrustad@gmail.com> wrote:

> >> +	 err:
> >>  		kfree(foo->bar);
> >>  		kfree(foo);
> >>  		return ret;
> >>
> >>  The bug in this code is that on some exit paths "foo" is NULL.  Normally the  
> >
> > ...except that kfree() can handle null pointers just fine, so this isn't
> > actually a bug, right?  Someday when somebody has time it would be good to
> > come up with a better example.  
> 
> But if foo is NULL, foo->bar is not NULL and so kfree will have a problem  
> with it. So this is a bug.

Oops, sigh, duh.  OK, ignore me. (Though technically kfree will not have a
problem with it, since things won't get that far.. :)

jon

[toc] | [prev] | [next] | [standalone]


#1462927 — Re: CodingStyle: Clarify and complete chapter 7

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-15 17:40 +0200
SubjectRe: CodingStyle: Clarify and complete chapter 7
Message-ID<s6s9z-7m4-13@gated-at.bofh.it>
In reply to#1462334
>>> A common type of bug to be aware of is "one err bugs" which look like this:
>>>
>>> -    err:
>>> +     err:
>>>          kfree(foo->bar);
>>>          kfree(foo);
>>>          return ret;
>>>
>>>  The bug in this code is that on some exit paths "foo" is NULL.  Normally the
>>
>> ...except that kfree() can handle null pointers just fine, so this isn't
>> actually a bug, right?  Someday when somebody has time it would be good to
>> come up with a better example.
> 
> But if foo is NULL,

An important condition …


> foo->bar is not NULL

I wonder about this information. Which run-time environment will provide
this behaviour?


> and so kfree will have a problem with it.

I find that the parameter evaluation will result in side effects
(because of a null pointer access) which are usually unwanted.
So the execution of this function call will eventually not start.


> So this is a bug.

How do you think about further software development possibilities to improve
corresponding exception handling?

How much can the selection of jump labels influence the software design?

Regards,
Markus

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web