From: Marcel Siegert <mws@linuxtv.org>
To: Manu Abraham <abraham.manu@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
video4linux-list@redhat.com, Jiri Slaby <jirislaby@gmail.com>,
daniel@qanu.de, linux-kernel@vger.kernel.org, holger@qanu.de,
Alan Cox <alan@redhat.com>,
v4l-dvb maintainer list <v4l-dvb-maintainer@linuxtv.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [v4l-dvb-maintainer] [PATCH 3/3] V4L: cinergyT2, remove bad usage of ERESTARTSYS
Date: Wed, 10 Oct 2007 18:53:07 +0200 [thread overview]
Message-ID: <470D0373.1030308@linuxtv.org> (raw)
In-Reply-To: <470D0087.3050606@gmail.com>
Manu Abraham schrieb:
> Mauro Carvalho Chehab wrote:
>> Em Qua, 2007-10-10 Ã s 11:59 -0400, Alan Cox escreveu:
>>> On Wed, Oct 10, 2007 at 12:35:41PM -0300, Mauro Carvalho Chehab wrote:
>>>> Em Qua, 2007-10-10 Ã s 00:18 -0400, Michael Krufky escreveu:
>>>>> Is this illegal as per kernel codingstyle?
>>>> Yes, it is. CodingStyle states:
>>> <rant>
>>> No.. "Illegal" means prohibited by law. Its merely wrong 8)
>>> </rant>
>> LOL
>>
>>>> The proper fix is just to replace the offended code by this:
>>>>
>>>> err=foo();
>>>> if (error)
>>>> goto error;
>>> Lots of code uses
>>>
>>> if ((err = foo()) < 0)
>>>
>>> so I would'y worry too much. The split one however clearer and also
>>> safer.
>> Yes, this is not a severe CodingStyle violation. Still, the above code
>> is better than the used one.
>>
>> Since, on your example, it is clear that the programmer wanted to test
>> if the value is less than zero.
>>
>> The code:
>>
>> if ( (err=foo()) )
>>
>> should also indicate an operator mistake of using =, instead of ==.
>>
>> Probably, source code analyzers like Coverity will complain about the
>> above.
>>
>> If not violating CodingStyle, I would rather prefer to code this as:
>> if ( !(err=foo() )
>> or, even better, using:
>> if ( (err=foo()) != 0)
>>
>> clearly indicating that it is tested if the value is not zero.
>>
>> Even being a quite simple issue, I would prefer if Jiri can fix it.
>>
>
>
> When you have only some few lines of code you can write
>
> err = foo()
> if (err) {
> do whatever
> }
>
> doesn't matter ..
>
> But when you have hell a lot of code, checking error's what you
> mention is insane.
>
> ie,
>
> if ((err = foo()) expr ) is better.
>
> http://lkml.org/lkml/2007/2/4/56
>
> Manu
>
hi manu,
it's not worth discussing this in a way like
"i know something from the past and that was a different solution".
if you look to other parts in that thread like
http://lkml.org/lkml/2007/2/3/150
you will see that they came also to a kind of different solution,
NOT to use the 1-liner for assignment statements.
it's more like a religious/personal discussion how to
struct/indent/format code.
and, to state my position for clear,
if kernel coding style document isnt updated to allow the constructions
of code that caused this discussion, we dont have to discuss but follow
the rules.
anything else on this topic (coding style and it's sense) is to be
discussed on kernel ml.
my 2ct
marcel
> _______________________________________________
> v4l-dvb-maintainer mailing list
> v4l-dvb-maintainer@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/v4l-dvb-maintainer
next prev parent reply other threads:[~2007-10-10 17:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-08 12:33 [PATCH 1/3] V4L: w9968cf, remove bad usage of ERESTARTSYS Jiri Slaby
2007-10-08 12:34 ` [PATCH 2/3] V4L: zc0301, " Jiri Slaby
2007-10-10 0:18 ` Luca Risolia
2007-10-08 12:34 ` [PATCH 3/3] V4L: cinergyT2, " Jiri Slaby
2007-10-10 1:21 ` Mauro Carvalho Chehab
2007-10-10 4:18 ` [v4l-dvb-maintainer] " Michael Krufky
2007-10-10 15:35 ` Mauro Carvalho Chehab
2007-10-10 15:59 ` Alan Cox
2007-10-10 16:17 ` Mauro Carvalho Chehab
2007-10-10 16:40 ` Manu Abraham
2007-10-10 16:53 ` Marcel Siegert [this message]
2007-10-10 17:05 ` Manu Abraham
2007-10-10 18:04 ` Marcel Siegert
2007-10-12 4:29 ` Randy Dunlap
2007-10-10 0:18 ` [PATCH 1/3] V4L: w9968cf, " Luca Risolia
2007-10-14 14:28 ` [PATCH 1/1 try 2] V4L: cinergyT2, " Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=470D0373.1030308@linuxtv.org \
--to=mws@linuxtv.org \
--cc=abraham.manu@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@redhat.com \
--cc=daniel@qanu.de \
--cc=holger@qanu.de \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=v4l-dvb-maintainer@linuxtv.org \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox