linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] minor coding style fix
@ 2017-03-27 14:34 sfaragnaus
  2017-03-29  7:18 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: sfaragnaus @ 2017-03-27 14:34 UTC (permalink / raw)
  To: Arnaud Patard, Greg Kroah-Hartman, devel, linux-kernel

This patch fix a minor coding style issue.

Signed-off-by: sfaragnaus <sfaragnaus@gmail.com>
---
 drivers/staging/xgifb/XGI_main_26.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index d938da3..b450c74 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -879,6 +879,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
 
 			if ((filter >= 0) && (filter <= 7)) {
 				const u8 *f = XGI_TV_filter[filter_tb].filter[filter];
+
 				pr_debug("FilterTable[%d]-%d: %*ph\n",
 					 filter_tb, filter, 4, f);
 				xgifb_reg_set(XGIPART2, 0x35, f[0]);
-- 
2.4.10

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] minor coding style fix
  2017-03-27 14:34 [PATCH] minor coding style fix sfaragnaus
@ 2017-03-29  7:18 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-29  7:18 UTC (permalink / raw)
  To: sfaragnaus; +Cc: Arnaud Patard, devel, linux-kernel

On Mon, Mar 27, 2017 at 03:34:47PM +0100, sfaragnaus wrote:
> This patch fix a minor coding style issue.

You need to be a lot more specific here, and in your subject line.

> Signed-off-by: sfaragnaus <sfaragnaus@gmail.com>

I also need a "real name" here and in the from: line please.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Minor coding style fix
  2006-10-08 17:18   ` Aneesh Kumar K.V
@ 2006-10-09 14:39     ` Stefan Richter
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Richter @ 2006-10-09 14:39 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: linux-kernel, Jesper Juhl, Jan Engelhardt

Aneesh Kumar K.V wrote:
> As per Documentation/CodingStyle 
> 
> "Functions can return values of many different kinds, and one of the
> most common is a value indicating whether the function succeeded or
> failed.  Such a value can be represented as an error-code integer
> (-Exxx = failure, 0 = success) or a "succeeded" boolean (0 = failure,
> non-zero = success)."
> 
> That means if the function need to indicate success it should be made
> to return 0.

The wording is 'can', not 'should' or 'shall'. The current agreement is
however that do_something()-named functions indeed 'should' return <0
for "failure" and 0 for "success" while is_something()-named functions
'should' return non-0 for "yes" and 0 for "no". But there is no rule
without exceptions: Some functions like copy_to_user() return >0 in
situations which can be considered a "failure" because this positive
value has further meaning.

But back to your patch: I am not aware of an agreement on how to write a
check for zero or a check for nonzero.

> I don't see any other value being returned from init_srcu_struct.

True.

> Also having a consistent style of if() check make code reading easier.

Also true. However (a) there is no kernel-wide consistency about this
and (b) the style used in the file which you are patching is
	if (do_something_returning_negative_errors() < 0)
E.g.
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L1070

And here <0 and !0 are actually different:
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L852

However, kernel/sys.c is not entirely consequent:
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L1336
and the other calls to copy_{from,to}_user would have to be
	if (copy_to_user(a, b, s) != 0)
or > 0 to follow the style of the above mentioned ifs to 100%. But
that's nitpicking. :-)
-- 
Stefan Richter
-=====-=-==- =-=- -=---
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Minor coding style fix
  2006-10-08 15:29 ` Jesper Juhl
  2006-10-08 15:42   ` Jan Engelhardt
@ 2006-10-08 17:18   ` Aneesh Kumar K.V
  2006-10-09 14:39     ` Stefan Richter
  1 sibling, 1 reply; 7+ messages in thread
From: Aneesh Kumar K.V @ 2006-10-08 17:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-kernel

Jesper Juhl wrote:
> On 08/10/06, Aneesh Kumar K.V <aneesh.kumar@gmail.com> wrote:
>> Kernel generally follow the style
>>
>> if (func()) {
>> /* failed case */
>> } else {
>> /* success */
>> }
>>
>>
> 
> Please submit patches inline, having to copy them from attachments to
> be able to reply is a pain.
> 
>>
>> diff --git a/kernel/sys.c b/kernel/sys.c
>> index 98489d8..55cb77c 100644
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_cha
>>  void srcu_init_notifier_head(struct srcu_notifier_head *nh)
>>  {
>>      mutex_init(&nh->mutex);
>> -    if (init_srcu_struct(&nh->srcu) < 0)
>> +    if (init_srcu_struct(&nh->srcu))
>>          BUG();
>>      nh->head = NULL;
>>  }
> 
> I really liked the old code better. If in the future
> init_srcu_struct() is changed to also return >0 for some conditions,
> then that would not previously have triggered BUG(), but after your
> changes it will. The code, as it were, perfectly expressed what it
> wanted to happen - if it returns less than zero it's a BUG().
> I say leave it alone.
> 
> 


As per Documentation/CodingStyle 

"Functions can return values of many different kinds, and one of the
most common is a value indicating whether the function succeeded or
failed.  Such a value can be represented as an error-code integer
(-Exxx = failure, 0 = success) or a "succeeded" boolean (0 = failure,
non-zero = success)."

That means if the function need to indicate success it should be made to return 0. 
I don't see any other value being returned from init_srcu_struct. Also having a consistent
style of if() check make code reading easier.

-aneesh 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Minor coding style fix
  2006-10-08 15:29 ` Jesper Juhl
@ 2006-10-08 15:42   ` Jan Engelhardt
  2006-10-08 17:18   ` Aneesh Kumar K.V
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Engelhardt @ 2006-10-08 15:42 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Aneesh Kumar K.V, linux-kernel

>> Kernel generally follow the style
>> 
>> if (func()) {
>> /* failed case */
>> } else {
>> /* success */
>> }

Here's my: NAK.
(At best it should be if(foo != 0) rather than if(foo), but that's just me.)

> I really liked the old code better. If in the future
> init_srcu_struct() is changed to also return >0 for some conditions,
> then that would not previously have triggered BUG(), but after your
> changes it will. The code, as it were, perfectly expressed what it
> wanted to happen - if it returns less than zero it's a BUG().
> I say leave it alone.

I agree here.


	-`J'
-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Minor coding style fix
  2006-10-08 15:06 [PATCH] Minor " Aneesh Kumar K.V
@ 2006-10-08 15:29 ` Jesper Juhl
  2006-10-08 15:42   ` Jan Engelhardt
  2006-10-08 17:18   ` Aneesh Kumar K.V
  0 siblings, 2 replies; 7+ messages in thread
From: Jesper Juhl @ 2006-10-08 15:29 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: linux-kernel

On 08/10/06, Aneesh Kumar K.V <aneesh.kumar@gmail.com> wrote:
> Kernel generally follow the style
>
> if (func()) {
> /* failed case */
> } else {
> /* success */
> }
>
>

Please submit patches inline, having to copy them from attachments to
be able to reply is a pain.

>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index 98489d8..55cb77c 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_cha
>  void srcu_init_notifier_head(struct srcu_notifier_head *nh)
>  {
>  	mutex_init(&nh->mutex);
> -	if (init_srcu_struct(&nh->srcu) < 0)
> +	if (init_srcu_struct(&nh->srcu))
>  		BUG();
>  	nh->head = NULL;
>  }

I really liked the old code better. If in the future
init_srcu_struct() is changed to also return >0 for some conditions,
then that would not previously have triggered BUG(), but after your
changes it will. The code, as it were, perfectly expressed what it
wanted to happen - if it returns less than zero it's a BUG().
I say leave it alone.


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Minor coding style fix
@ 2006-10-08 15:06 Aneesh Kumar K.V
  2006-10-08 15:29 ` Jesper Juhl
  0 siblings, 1 reply; 7+ messages in thread
From: Aneesh Kumar K.V @ 2006-10-08 15:06 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 103 bytes --]

Kernel generally follow the style 

if (func()) {
/* failed case */
} else {
/* success */
}


-aneesh

[-- Attachment #2: sys.c.diff --]
[-- Type: text/x-patch, Size: 366 bytes --]

diff --git a/kernel/sys.c b/kernel/sys.c
index 98489d8..55cb77c 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_cha
 void srcu_init_notifier_head(struct srcu_notifier_head *nh)
 {
 	mutex_init(&nh->mutex);
-	if (init_srcu_struct(&nh->srcu) < 0)
+	if (init_srcu_struct(&nh->srcu))
 		BUG();
 	nh->head = NULL;
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-29  7:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 14:34 [PATCH] minor coding style fix sfaragnaus
2017-03-29  7:18 ` Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2006-10-08 15:06 [PATCH] Minor " Aneesh Kumar K.V
2006-10-08 15:29 ` Jesper Juhl
2006-10-08 15:42   ` Jan Engelhardt
2006-10-08 17:18   ` Aneesh Kumar K.V
2006-10-09 14:39     ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).