linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] android/haltest: Close file in case of error
@ 2014-02-05 15:44 Andrei Emeltchenko
  2014-02-06 14:13 ` Andrei Emeltchenko
  2014-02-06 14:22 ` [PATCHv2 1/2] " Andrei Emeltchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-02-05 15:44 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/client/if-audio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 66f8364..bb8f51b 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -258,6 +258,7 @@ static void play_p(int argc, const char **argv)
 
 	if (buffer_size == 0) {
 		haltest_error("Invalid buffer size. Was stream_out opened?\n");
+		fclose(in);
 		return;
 	}
 
@@ -265,12 +266,15 @@ static void play_p(int argc, const char **argv)
 	if (current_state != STATE_STOPPED) {
 		haltest_error("Already playing or stream suspended!\n");
 		pthread_mutex_unlock(&state_mutex);
+		fclose(in);
 		return;
 	}
 	pthread_mutex_unlock(&state_mutex);
 
-	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0)
+	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0) {
 		haltest_error("Cannot create playback thread!\n");
+		fclose(in);
+	}
 }
 
 static void stop_p(int argc, const char **argv)
-- 
1.8.3.2


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

* Re: [PATCH] android/haltest: Close file in case of error
  2014-02-05 15:44 [PATCH] android/haltest: Close file in case of error Andrei Emeltchenko
@ 2014-02-06 14:13 ` Andrei Emeltchenko
  2014-02-06 14:22 ` [PATCHv2 1/2] " Andrei Emeltchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-02-06 14:13 UTC (permalink / raw)
  To: linux-bluetooth

On Wed, Feb 05, 2014 at 05:44:02PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ---
>  android/client/if-audio.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/android/client/if-audio.c b/android/client/if-audio.c
> index 66f8364..bb8f51b 100644
> --- a/android/client/if-audio.c
> +++ b/android/client/if-audio.c
> @@ -258,6 +258,7 @@ static void play_p(int argc, const char **argv)
>  
>  	if (buffer_size == 0) {
>  		haltest_error("Invalid buffer size. Was stream_out opened?\n");
> +		fclose(in);

sorry, need to check for NULL here and below.

Best regards 
Andrei Emeltchenko 

>  		return;
>  	}
>  
> @@ -265,12 +266,15 @@ static void play_p(int argc, const char **argv)
>  	if (current_state != STATE_STOPPED) {
>  		haltest_error("Already playing or stream suspended!\n");
>  		pthread_mutex_unlock(&state_mutex);
> +		fclose(in);
>  		return;
>  	}
>  	pthread_mutex_unlock(&state_mutex);
>  
> -	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0)
> +	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0) {
>  		haltest_error("Cannot create playback thread!\n");
> +		fclose(in);
> +	}
>  }
>  
>  static void stop_p(int argc, const char **argv)
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCHv2 1/2] android/haltest: Close file in case of error
  2014-02-05 15:44 [PATCH] android/haltest: Close file in case of error Andrei Emeltchenko
  2014-02-06 14:13 ` Andrei Emeltchenko
@ 2014-02-06 14:22 ` Andrei Emeltchenko
  2014-02-06 14:22   ` [PATCHv2 2/2] android/haltest: Remove unneeded assignment Andrei Emeltchenko
  2014-02-07 10:05   ` [PATCHv2 1/2] android/haltest: Close file in case of error Szymon Janc
  1 sibling, 2 replies; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-02-06 14:22 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/client/if-audio.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 66f8364..3b34c95 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -258,19 +258,26 @@ static void play_p(int argc, const char **argv)
 
 	if (buffer_size == 0) {
 		haltest_error("Invalid buffer size. Was stream_out opened?\n");
-		return;
+		goto fail;
 	}
 
 	pthread_mutex_lock(&state_mutex);
 	if (current_state != STATE_STOPPED) {
 		haltest_error("Already playing or stream suspended!\n");
 		pthread_mutex_unlock(&state_mutex);
-		return;
+		goto fail;
 	}
 	pthread_mutex_unlock(&state_mutex);
 
-	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0)
+	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0) {
 		haltest_error("Cannot create playback thread!\n");
+		goto fail;
+	}
+
+	return;
+fail:
+	if (in)
+		fclose(in);
 }
 
 static void stop_p(int argc, const char **argv)
-- 
1.8.3.2


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

* [PATCHv2 2/2] android/haltest: Remove unneeded assignment
  2014-02-06 14:22 ` [PATCHv2 1/2] " Andrei Emeltchenko
@ 2014-02-06 14:22   ` Andrei Emeltchenko
  2014-02-07 10:05   ` [PATCHv2 1/2] android/haltest: Close file in case of error Szymon Janc
  1 sibling, 0 replies; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-02-06 14:22 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/client/if-audio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 3b34c95..f449b49 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -225,10 +225,8 @@ static void *playback_thread(void *data)
 		pthread_mutex_unlock(&outstream_mutex);
 	} while (len && w_len);
 
-	if (in) {
+	if (in)
 		fclose(in);
-		in = NULL;
-	}
 
 	pthread_cleanup_pop(1);
 	return NULL;
-- 
1.8.3.2


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

* Re: [PATCHv2 1/2] android/haltest: Close file in case of error
  2014-02-06 14:22 ` [PATCHv2 1/2] " Andrei Emeltchenko
  2014-02-06 14:22   ` [PATCHv2 2/2] android/haltest: Remove unneeded assignment Andrei Emeltchenko
@ 2014-02-07 10:05   ` Szymon Janc
  1 sibling, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2014-02-07 10:05 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Thursday 06 of February 2014 16:22:42 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ---
>  android/client/if-audio.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/android/client/if-audio.c b/android/client/if-audio.c
> index 66f8364..3b34c95 100644
> --- a/android/client/if-audio.c
> +++ b/android/client/if-audio.c
> @@ -258,19 +258,26 @@ static void play_p(int argc, const char **argv)
>  
>  	if (buffer_size == 0) {
>  		haltest_error("Invalid buffer size. Was stream_out opened?\n");
> -		return;
> +		goto fail;
>  	}
>  
>  	pthread_mutex_lock(&state_mutex);
>  	if (current_state != STATE_STOPPED) {
>  		haltest_error("Already playing or stream suspended!\n");
>  		pthread_mutex_unlock(&state_mutex);
> -		return;
> +		goto fail;
>  	}
>  	pthread_mutex_unlock(&state_mutex);
>  
> -	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0)
> +	if (pthread_create(&play_thread, NULL, playback_thread, in) != 0) {
>  		haltest_error("Cannot create playback thread!\n");
> +		goto fail;
> +	}
> +
> +	return;
> +fail:
> +	if (in)
> +		fclose(in);
>  }
>  
>  static void stop_p(int argc, const char **argv)
> 

This patch is now upstream, thanks.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-02-07 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 15:44 [PATCH] android/haltest: Close file in case of error Andrei Emeltchenko
2014-02-06 14:13 ` Andrei Emeltchenko
2014-02-06 14:22 ` [PATCHv2 1/2] " Andrei Emeltchenko
2014-02-06 14:22   ` [PATCHv2 2/2] android/haltest: Remove unneeded assignment Andrei Emeltchenko
2014-02-07 10:05   ` [PATCHv2 1/2] android/haltest: Close file in case of error Szymon Janc

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).