diff mbox series

kvm-unit-tests: unlock before calling return

Message ID 1537285878-27148-1-git-send-email-penghao122@sina.com.cn (mailing list archive)
State New, archived
Headers show
Series kvm-unit-tests: unlock before calling return | expand

Commit Message

Peng Hao Sept. 18, 2018, 3:51 p.m. UTC
From: Peng Hao <peng.hao2@zte.com.cn>

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 lib/report.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Krish Sadhukhan Sept. 18, 2018, 9:03 p.m. UTC | #1
On 09/18/2018 08:51 AM, Peng Hao wrote:
> From: Peng Hao <peng.hao2@zte.com.cn>
>
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>   lib/report.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/lib/report.c b/lib/report.c
> index 5da27ab..ca9b4fd 100644
> --- a/lib/report.c
> +++ b/lib/report.c
> @@ -66,8 +66,10 @@ void report_prefix_pop(void)
>   
>   	spin_lock(&lock);
>   
> -	if (!*prefixes)
> +	if (!*prefixes) {
> +		spin_unlock(&lock);
>   		return;
> +	}
>   
>   	for (p = prefixes, q = strstr(p, PREFIX_DELIMITER) + 2;
>   			*q;
> @@ -142,6 +144,7 @@ void report_info(const char *msg_fmt, ...)
>   
>   int report_summary(void)
>   {
> +	int ret;
>   	spin_lock(&lock);
>   
>   	printf("SUMMARY: %d tests", tests);
> @@ -153,14 +156,16 @@ int report_summary(void)
>   		printf(", %d skipped", skipped);
>   	printf("\n");
>   
> -	if (tests == skipped)
> +	if (tests == skipped) {
> +		spin_unlock(&lock);
>   		/* Blame AUTOTOOLS for using 77 for skipped test and QEMU for
>   		 * mangling error codes in a way that gets 77 if we ... */
>   		return 77 >> 1;
> +	}
>   
> -	return failures > 0 ? 1 : 0;
> -
> +	ret = failures > 0 ? 1 : 0;
>   	spin_unlock(&lock);
> +	return ret;
>   }
>   
>   void report_abort(const char *msg_fmt, ...)
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Paolo Bonzini Sept. 19, 2018, 10:43 p.m. UTC | #2
On 18/09/2018 23:03, Krish Sadhukhan wrote:
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/lib/report.c b/lib/report.c
index 5da27ab..ca9b4fd 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -66,8 +66,10 @@  void report_prefix_pop(void)
 
 	spin_lock(&lock);
 
-	if (!*prefixes)
+	if (!*prefixes) {
+		spin_unlock(&lock);
 		return;
+	}
 
 	for (p = prefixes, q = strstr(p, PREFIX_DELIMITER) + 2;
 			*q;
@@ -142,6 +144,7 @@  void report_info(const char *msg_fmt, ...)
 
 int report_summary(void)
 {
+	int ret;
 	spin_lock(&lock);
 
 	printf("SUMMARY: %d tests", tests);
@@ -153,14 +156,16 @@  int report_summary(void)
 		printf(", %d skipped", skipped);
 	printf("\n");
 
-	if (tests == skipped)
+	if (tests == skipped) {
+		spin_unlock(&lock);
 		/* Blame AUTOTOOLS for using 77 for skipped test and QEMU for
 		 * mangling error codes in a way that gets 77 if we ... */
 		return 77 >> 1;
+	}
 
-	return failures > 0 ? 1 : 0;
-
+	ret = failures > 0 ? 1 : 0;
 	spin_unlock(&lock);
+	return ret;
 }
 
 void report_abort(const char *msg_fmt, ...)