Skip to contentSkip to conversation

fix coding style in fscpos.c

PATCH In review Darren Jenkins\ 5 participants 7 messages Feb 22, 2006 – Feb 23, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix coding style in fscpos.c

G'day list,

Here is a simple one I noticed.

The CodingStyle document says
"Don't put multiple statements on a single line unless you have something to hide:"

The patch below is a very simple change to convert to requisite coding style.

drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
@@ -229,8 +229,10 @@ static ssize_t set_pwm(struct i2c_client
 	unsigned long v = simple_strtoul(buf, NULL, 10);
 
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0) 
+		v = 0;
+	if (v > 255) 
+		v = 255;
 
 	down(&data->update_lock);
 	data->pwm[nr - 1] = v;

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

Hi Darren,

Quoted 16 lines

Here is a simple one I noticed.

The CodingStyle document says
"Don't put multiple statements on a single line unless you have something to hide:"

The patch below is a very simple change to convert to requisite coding style.

drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +0 -0
@@ -229,8 +229,10 @@ static ssize_t set_pwm(struct i2c_client
 	unsigned long v = simple_strtoul(buf, NULL, 10);
 

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 238

Quoted 10 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0) 
+		v = 0;
+	if (v > 255) 
+		v = 255;
 
 	down(&data->update_lock);
 	data->pwm[nr - 1] = v;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

Signature · 1 line
Jean Delvare

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Darren Jenkins\
Quoted 25 lines · Jean Delvare

Hi Darren,

Quoted 23 lines

Here is a simple one I noticed.

The CodingStyle document says
"Don't put multiple statements on a single line unless you have something to hide:"

The patch below is a very simple change to convert to requisite coding style.

drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
@@ -229,8 +229,10 @@ static ssize_t set_pwm(struct i2c_client
 	unsigned long v = simple_strtoul(buf, NULL, 10);
 
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0) 
+		v = 0;
+	if (v > 255) 
+		v = 255;
 
Quoted 6 lines

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 238

Quoted 3 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +0 -0
 	down(&data->update_lock);
 	data->pwm[nr - 1] = v;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

It's against the kernel coding style.

There many several cases with several ways to express something pretty readable (opening braces being an religious example), but the goal is to stick with one way to express something throughout the whole kernel.

Quoted 1 line

Jean Delvare

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw
In reply to Darren Jenkins\

Hi Adrian,

Quoted 11 lines · Adrian Bunk
Quoted 10 lines

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 235

Quoted 7 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0)
+		v = 0;
+	if (v > 255)
+		v = 255;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

Quoted 5 lines

It's against the kernel coding style.

There many several cases with several ways to express something pretty readable (opening braces being an religious example), but the goal is to stick with one way to express something throughout the whole kernel.

I didn't mean to say otherwise. I request submitters of new drivers and patches to comply with CodingStyle and even with the kernel guide to space. I'm quite picky about it actually, just ask these submitters and they'll tell you. I also wholeheartedly accept a cleanup patch, including coding style, as the first patch of a patchset improving any given driver, as it makes the next patches easier to work on and review.

However, I don't see much benefit in patches randomly fixing one coding style mistake in a random driver, unless that mistake was making the code especially unclear or error prone. The overhead to my workload and in the driver history is simply not worth the gain. This was the meaning of my reply.

--
Jean Delvare

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to Darren Jenkins\
Quoted 28 lines · Jean Delvare

Hi Adrian,

Quoted 11 lines · Adrian Bunk
Quoted 10 lines

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 235

Quoted 7 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0)
+		v = 0;
+	if (v > 255)
+		v = 255;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

Quoted 5 lines

It's against the kernel coding style.

There many several cases with several ways to express something pretty readable (opening braces being an religious example), but the goal is to stick with one way to express something throughout the whole kernel.

I didn't mean to say otherwise. I request submitters of new drivers and patches to comply with CodingStyle and even with the kernel guide to space. I'm quite picky about it actually, just ask these submitters and they'll tell you. I also wholeheartedly accept a cleanup patch, including coding style, as the first patch of a patchset improving any given driver, as it makes the next patches easier to work on and review.

Quoted 5 lines

However, I don't see much benefit in patches randomly fixing one coding style mistake in a random driver, unless that mistake was making the code especially unclear or error prone. The overhead to my workload and in the driver history is simply not worth the gain. This was the meaning of my reply.

That's exactly the point of the janitor project, to make changes like this in places where needed.

Here, this is needed :)

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw
In reply to Darren Jenkins\
Quoted 35 lines · Greg KH
Quoted 28 lines · Jean Delvare

Hi Adrian,

Quoted 11 lines · Adrian Bunk
Quoted 10 lines

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 235

Quoted 7 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0)
+		v = 0;
+	if (v > 255)
+		v = 255;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

Quoted 5 lines

It's against the kernel coding style.

There many several cases with several ways to express something pretty readable (opening braces being an religious example), but the goal is to stick with one way to express something throughout the whole kernel.

I didn't mean to say otherwise. I request submitters of new drivers and patches to comply with CodingStyle and even with the kernel guide to space. I'm quite picky about it actually, just ask these submitters and they'll tell you. I also wholeheartedly accept a cleanup patch, including coding style, as the first patch of a patchset improving any given driver, as it makes the next patches easier to work on and review.

Quoted 5 lines

However, I don't see much benefit in patches randomly fixing one coding style mistake in a random driver, unless that mistake was making the code especially unclear or error prone. The overhead to my workload and in the driver history is simply not worth the gain. This was the meaning of my reply.

Quoted 4 lines

That's exactly the point of the janitor project, to make changes like this in places where needed.

Here, this is needed :)

I think "needed" is too strong of a word there. Like when my son says that he "needs" to go snowboarding or to a movie.

It's OK to accept this patch, but not needed.
And CodingStyle is not a bible, it's more like a company's policies and procedures manual, which (in good companies) are just guidelines, not hard & fast rules.

and the KJ project is meant to train people to make useful patches IMHO, not just to do busy work.

Signature · 1 line
~Randy

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#6 lore raw
In reply to Darren Jenkins\
Quoted 37 lines · Randy.Dunlap
Quoted 35 lines · Greg KH
Quoted 33 lines · Jean Delvare

Hi Adrian,

Quoted 11 lines · Adrian Bunk
Quoted 10 lines

drivers/hwmon/fscpos.c static ssize_t set_pwm(struct i2c_client · line 235

Quoted 7 lines
drivers/hwmon/fscpos.c renamed from drivers/hwmon/fscpos.c.orig +4 -2
 	/* Range: 0..255 */
-	if (v < 0) v = 0;
-	if (v > 255) v = 255;
+	if (v < 0)
+		v = 0;
+	if (v > 255)
+		v = 255;

Not worth the effort IMHO. The original code is pretty readable as it is so I wouldn't change it.

Quoted 5 lines

It's against the kernel coding style.

There many several cases with several ways to express something pretty readable (opening braces being an religious example), but the goal is to stick with one way to express something throughout the whole kernel.

I didn't mean to say otherwise. I request submitters of new drivers and patches to comply with CodingStyle and even with the kernel guide to space. I'm quite picky about it actually, just ask these submitters and they'll tell you. I also wholeheartedly accept a cleanup patch, including coding style, as the first patch of a patchset improving any given driver, as it makes the next patches easier to work on and review.

However, I don't see much benefit in patches randomly fixing one coding style mistake in a random driver, unless that mistake was making the code especially unclear or error prone. The overhead to my workload and in the driver history is simply not worth the gain. This was the meaning of my reply.

Quoted 8 lines
Quoted 4 lines

That's exactly the point of the janitor project, to make changes like this in places where needed.

Here, this is needed :)

I think "needed" is too strong of a word there. Like when my son says that he "needs" to go snowboarding or to a movie.

Heh, good point :)

Quoted 4 lines

It's OK to accept this patch, but not needed.
And CodingStyle is not a bible, it's more like a company's policies and procedures manual, which (in good companies) are just guidelines, not hard & fast rules.

Agreed.

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors