Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2017 Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Validate various C11 threads routines. Specifically we want to cover:
  18  *
  19  *    o threads
  20  *    o mutexes
  21  *    o condition variables
  22  */
  23 
  24 #include <threads.h>
  25 #include <sys/debug.h>
  26 #include <stdlib.h>
  27 #include <unistd.h>
  28 
  29 #define STRESS_NTHREADS 128
  30 #define STRESS_COUNT    1000
  31 
  32 static mtx_t stress_mtx;
  33 static int stress_count;


 155 static void
 156 cthr_test_detach_err(void)
 157 {
 158         thrd_t self, other;
 159 
 160         self = thrd_current();
 161 
 162         VERIFY3S(thrd_equal(self, self), !=, 0);
 163         VERIFY3S(thrd_create(&other, cthr_test_sleep_thr, NULL), ==,
 164             thrd_success);
 165         VERIFY3S(thrd_detach(other), ==, thrd_success);
 166 
 167         VERIFY3S(thrd_join(self, NULL), ==, thrd_error);
 168         VERIFY3S(thrd_join(other, NULL), ==, thrd_error);
 169 }
 170 
 171 static int
 172 cthr_test_detach_thr0(void *arg)
 173 {
 174         thrd_exit(23);
 175         abort();
 176 }
 177 
 178 static int
 179 cthr_test_detach_thr1(void *arg)
 180 {
 181         return (42);
 182 }
 183 
 184 static void
 185 cthr_test_detach(void)
 186 {
 187         int status;
 188         thrd_t thrd;
 189 
 190         VERIFY3S(thrd_create(&thrd, cthr_test_detach_thr0, NULL), ==,
 191             thrd_success);
 192         VERIFY3S(thrd_join(thrd, &status), ==, thrd_success);
 193         VERIFY3S(status, ==, 23);
 194 
 195         VERIFY3S(thrd_create(&thrd, cthr_test_detach_thr1, NULL), ==,


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019 Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Validate various C11 threads routines. Specifically we want to cover:
  18  *
  19  *    o threads
  20  *    o mutexes
  21  *    o condition variables
  22  */
  23 
  24 #include <threads.h>
  25 #include <sys/debug.h>
  26 #include <stdlib.h>
  27 #include <unistd.h>
  28 
  29 #define STRESS_NTHREADS 128
  30 #define STRESS_COUNT    1000
  31 
  32 static mtx_t stress_mtx;
  33 static int stress_count;


 155 static void
 156 cthr_test_detach_err(void)
 157 {
 158         thrd_t self, other;
 159 
 160         self = thrd_current();
 161 
 162         VERIFY3S(thrd_equal(self, self), !=, 0);
 163         VERIFY3S(thrd_create(&other, cthr_test_sleep_thr, NULL), ==,
 164             thrd_success);
 165         VERIFY3S(thrd_detach(other), ==, thrd_success);
 166 
 167         VERIFY3S(thrd_join(self, NULL), ==, thrd_error);
 168         VERIFY3S(thrd_join(other, NULL), ==, thrd_error);
 169 }
 170 
 171 static int
 172 cthr_test_detach_thr0(void *arg)
 173 {
 174         thrd_exit(23);

 175 }
 176 
 177 static int
 178 cthr_test_detach_thr1(void *arg)
 179 {
 180         return (42);
 181 }
 182 
 183 static void
 184 cthr_test_detach(void)
 185 {
 186         int status;
 187         thrd_t thrd;
 188 
 189         VERIFY3S(thrd_create(&thrd, cthr_test_detach_thr0, NULL), ==,
 190             thrd_success);
 191         VERIFY3S(thrd_join(thrd, &status), ==, thrd_success);
 192         VERIFY3S(status, ==, 23);
 193 
 194         VERIFY3S(thrd_create(&thrd, cthr_test_detach_thr1, NULL), ==,