Skip to contentSkip to conversation

radio-si470x-common: -EINVAL overwritten in si470x_vidioc_s_tuner()

PATCH Applied Roel Kluin 3 participants 5 messages Feb 3, 2010 – Feb 24, 2010

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 radio-si470x-common: -EINVAL overwritten in si470x_vidioc_s_tuner()

The -EINVAL was overwritten by the si470x_disconnect_check().

---
Is this needed?

drivers/media/radio/si470x/radio-si470x-common.c +2 -1
index 4da0f15..65b4a92 100644
@@ -748,12 +748,13 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv,
 		struct v4l2_tuner *tuner)
 {
 	struct si470x_device *radio = video_drvdata(file);
-	int retval = -EINVAL;
+	int retval;
 
 	/* safety checks */
 	retval = si470x_disconnect_check(radio);
 	if (retval)
 		goto done;
+	retval = -EINVAL;
 
 	if (tuner->index != 0)
 		goto done;
#1 lore raw

Hello Roel,

no, the default value of retval makes no difference to the function.

Retval is set by si470x_disconnect_check and si470x_set_register. After each call, retval is checked.
There is no need to reset it passed.

The only reason, there is a default value is my static code checker, saying variables should have default values. Setting it to -EINVAL seems more reasonable to me than setting it 0.
In fact the patch would bring up the warning on setting default values again.

Bye,
Toby

Am Mittwoch 03 Februar 2010 20:48:05 schrieb Roel Kluin:

Quoted 26 lines

The -EINVAL was overwritten by the si470x_disconnect_check().

---
Is this needed?

drivers/media/radio/si470x/radio-si470x-common.c +2 -1
index 4da0f15..65b4a92 100644
@@ -748,12 +748,13 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv,
 		struct v4l2_tuner *tuner)
 {
 	struct si470x_device *radio = video_drvdata(file);
-	int retval = -EINVAL;
+	int retval;
 
 	/* safety checks */
 	retval = si470x_disconnect_check(radio);
 	if (retval)
 		goto done;
+	retval = -EINVAL;
 
 	if (tuner->index != 0)
 		goto done;
#2 lore raw
Quoted 11 lines · Tobias Lorenz

Hello Roel,

no, the default value of retval makes no difference to the function.

Retval is set by si470x_disconnect_check and si470x_set_register. After each call, retval is checked.
There is no need to reset it passed.

The only reason, there is a default value is my static code checker, saying variables should have default values. Setting it to -EINVAL seems more reasonable to me than setting it 0.
In fact the patch would bring up the warning on setting default values again.

Well, your static code checker is then broken ;)

Quoted 6 lines

drivers/media/radio/si470x/radio-si470x-common.c static int si470x_vidioc_s_tuner(struct file *file, void *priv, · line 754

Quoted 6 lines
drivers/media/radio/si470x/radio-si470x-common.c +1 -1
 	struct si470x_device *radio = video_drvdata(file);
-	int retval = -EINVAL;
+	int retval;
 
 	/* safety checks */
 	retval = si470x_disconnect_check(radio);

You may just do then:

	int retval = si470x_disconnect_check(radio);
Quoted 11 lines

drivers/media/radio/si470x/radio-si470x-common.c static int si470x_vidioc_s_tuner(struct file *file, void *priv, · line 760

Quoted 7 lines
drivers/media/radio/si470x/radio-si470x-common.c +1 -0
 	if (retval)
 		goto done;
+	retval = -EINVAL;
 
 	if (tuner->index != 0)
 		goto done;

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Cheers,
Mauro
#3 lore raw

Hello Mauro,

Quoted 9 lines
Quoted 5 lines

no, the default value of retval makes no difference to the function.

Retval is set by si470x_disconnect_check and si470x_set_register. After each call, retval is checked.
There is no need to reset it passed.

You may just do then:

	int retval = si470x_disconnect_check(radio);

In all other set/get functions of v4l2_ioctl_ops in the driver, I just set the default value of retval to 0. To be identical in si470x_vidioc_s_tuner, I modified the patch to the one below.
I already pushed this and another cosmetic patch into mercurial:

http://linuxtv.org/hg/~tlorenz/v4l-dvb/rev/72a2f38d5956
http://linuxtv.org/hg/~tlorenz/v4l-dvb/rev/3efd5d32a618

Mauro, can you pull them?

Bye,
Tobias

linux/drivers/media/radio/si470x/radio-si470x-common.c +1 -1
@@ -748,7 +748,7 @@
 		struct v4l2_tuner *tuner)
 {
 	struct si470x_device *radio = video_drvdata(file);
-	int retval = -EINVAL;
+	int retval = 0;
 
 	/* safety checks */
 	retval = si470x_disconnect_check(radio);
#4 lore raw
Quoted 10 lines · Tobias Lorenz

Hello Mauro,

Quoted 8 lines
Quoted 5 lines

no, the default value of retval makes no difference to the function.

Retval is set by si470x_disconnect_check and si470x_set_register. After each call, retval is checked.
There is no need to reset it passed.

You may just do then:

Quoted 7 lines
Quoted 1 line
	int retval = si470x_disconnect_check(radio);

In all other set/get functions of v4l2_ioctl_ops in the driver, I just set the default value of retval to 0. To be identical in si470x_vidioc_s_tuner, I modified the patch to the one below.
I already pushed this and another cosmetic patch into mercurial:

http://linuxtv.org/hg/~tlorenz/v4l-dvb/rev/72a2f38d5956

See comment bellow.

Quoted 1 line

http://linuxtv.org/hg/~tlorenz/v4l-dvb/rev/3efd5d32a618

Applied.

Quoted 2 lines

Mauro, can you pull them?

Tobias, next time or send one patch per email or send me a pull request.

Quoted 7 lines

Bye,
Tobias

linux/drivers/media/radio/si470x/radio-si470x-common.c line 754

Quoted 8 lines
linux/drivers/media/radio/si470x/radio-si470x-common.c +1 -1
@@ -748,7 +748,7 @@
 		struct v4l2_tuner *tuner)
 {
 	struct si470x_device *radio = video_drvdata(file);
-	int retval = -EINVAL;
+	int retval = 0;
 
 	/* safety checks */
 	retval = si470x_disconnect_check(radio);

This really doesn't make any sense. Just do:

	int retval = i470x_disconnect_check(radio);

or

	int retval;

	retval = i470x_disconnect_check(radio);
Signature · 2 lines
Cheers,
Mauro