Skip to contentSkip to conversation

ALSA: oxfw: fix a condition in start_stream()

PATCH In review Dan Carpenter 3 participants 4 messages Feb 26, 2015 – Feb 27, 2015

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

PATCH 1/1 ALSA: oxfw: fix a condition in start_stream()

Static checkers complain that this function doesn't return negative error codes. The comments for amdtp_stream_wait_callback() say that we should stop the stream if it returns false.

Fixes f3699e2c7745 ('ALSA: oxfw: Change the way to start stream')
sound/firewire/oxfw/oxfw-stream.c +1 -1
index 29ccb36..ee67581 100644
@@ -172,7 +172,7 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
 
 	/* Wait first packet */
 	err = amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT);
-	if (err < 0)
+	if (err == 0)
 		stop_stream(oxfw, stream);
 end:
 	return err;
maintainer
#1 lore raw

Hi Dan,

Quoted 6 lines · Dan Carpenter

Static checkers complain that this function doesn't return negative error codes. The comments for amdtp_stream_wait_callback() say that we should stop the stream if it returns false.

Fixes f3699e2c7745 ('ALSA: oxfw: Change the way to start stream')

Thanks for this patch, while the error code should be assigned to -ETIMEDOUT, as the other drivers do.

I post an alternative patch to fix them.

Thanks

Takashi Sakamoto

Quoted 13 lines
sound/firewire/oxfw/oxfw-stream.c +1 -1
index 29ccb36..ee67581 100644
@@ -172,7 +172,7 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
 
 	/* Wait first packet */
 	err = amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT);
-	if (err < 0)
+	if (err = 0)
 		stop_stream(oxfw, stream);
 end:
 	return err;
maintainer
#2 lore raw

PATCH 1/1 ALSA: oxfw: fix a condition and return code in start_stream()

In reply to Dan Carpenter

The amdtp_stream_wait_callback() doesn't return minus value and the return code is not for error code.

This commit fixes with a propper condition and an error code.

Fixes f3699e2c7745 ('ALSA: oxfw: Change the way to start stream')
---
 sound/firewire/oxfw/oxfw-stream.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
sound/firewire/oxfw/oxfw-stream.c +3 -2
index 29ccb36..e6757cd 100644
@@ -171,9 +171,10 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
 	}
 
 	/* Wait first packet */
-	err = amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT);
-	if (err < 0)
+	if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) {
 		stop_stream(oxfw, stream);
+		err = -ETIMEDOUT;
+	}
 end:
 	return err;
 }
Signature · 1 line
2.1.0
Applied
#3 lore raw

Re: [PATCH] ALSA: oxfw: fix a condition and return code in start_stream()

At Fri, 27 Feb 2015 09:39:32 +0900,

Quoted 9 lines · Takashi Sakamoto

The amdtp_stream_wait_callback() doesn't return minus value and the return code is not for error code.

This commit fixes with a propper condition and an error code.

Fixes f3699e2c7745 ('ALSA: oxfw: Change the way to start stream')

Applied, thanks.

Takashi

Quoted 24 lines
---
 sound/firewire/oxfw/oxfw-stream.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
sound/firewire/oxfw/oxfw-stream.c +3 -2
index 29ccb36..e6757cd 100644
@@ -171,9 +171,10 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
 	}
 
 	/* Wait first packet */
-	err = amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT);
-	if (err < 0)
+	if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) {
 		stop_stream(oxfw, stream);
+		err = -ETIMEDOUT;
+	}
 end:
 	return err;
 }
Signature · 1 line
2.1.0