Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libpthread Avoid using an uninitialized mutex.



details:   https://anonhg.NetBSD.org/src/rev/8c30e4e7743e
branches:  trunk
changeset: 822513:8c30e4e7743e
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 23 08:31:00 2017 +0000

description:
Avoid using an uninitialized mutex.

diffstat:

 tests/lib/libpthread/t_mutex.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (51 lines):

diff -r 6acd3f308617 -r 8c30e4e7743e tests/lib/libpthread/t_mutex.c
--- a/tests/lib/libpthread/t_mutex.c    Thu Mar 23 08:18:17 2017 +0000
+++ b/tests/lib/libpthread/t_mutex.c    Thu Mar 23 08:31:00 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mutex.c,v 1.16 2017/03/05 16:08:23 chs Exp $ */
+/* $NetBSD: t_mutex.c,v 1.17 2017/03/23 08:31:00 martin Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mutex.c,v 1.16 2017/03/05 16:08:23 chs Exp $");
+__RCSID("$NetBSD: t_mutex.c,v 1.17 2017/03/23 08:31:00 martin Exp $");
 
 #include <sys/time.h> /* For timespecadd */
 #include <inttypes.h> /* For UINT16_MAX */
@@ -371,7 +371,6 @@
        PTHREAD_REQUIRE(pthread_join(child, NULL));
 }
 
-static pthread_mutex_t mutex6;
 static int start = 0;
 static uintmax_t high_cnt = 0, low_cnt = 0, MAX_LOOP = 100000000;
 
@@ -399,9 +398,9 @@
                high_cnt = 0;
                sleep(1);
        }
-       PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy));
+       PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
        if (start == 0) start = 2;
-       PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6));
+       PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
 
        return 0;
 }
@@ -431,10 +430,10 @@
                low_cnt = 0;
                sleep(1);
        }
-       PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy));
+       PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
        if (start == 0)
                start = 1;
-       PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6));
+       PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index