Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread Drop error path from C11 call_once



details:   https://anonhg.NetBSD.org/src/rev/f66c30ccfa44
branches:  trunk
changeset: 450758:f66c30ccfa44
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Apr 24 21:41:15 2019 +0000

description:
Drop error path from C11 call_once

The original implementation of C11 threads(3) contained check for error
paths, but it was stripped in the calls that are documented to return
no status from an operation. Do the same in call_once(3).

diffstat:

 lib/libpthread/call_once.c |  14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diffs (36 lines):

diff -r 63870ee6c618 -r f66c30ccfa44 lib/libpthread/call_once.c
--- a/lib/libpthread/call_once.c        Wed Apr 24 20:53:10 2019 +0000
+++ b/lib/libpthread/call_once.c        Wed Apr 24 21:41:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: call_once.c,v 1.1 2019/04/24 11:43:19 kamil Exp $      */
+/*     $NetBSD: call_once.c,v 1.2 2019/04/24 21:41:15 kamil Exp $      */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,12 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: call_once.c,v 1.1 2019/04/24 11:43:19 kamil Exp $");
+__RCSID("$NetBSD: call_once.c,v 1.2 2019/04/24 21:41:15 kamil Exp $");
 
 #include <assert.h>
-#include <err.h>
 #include <pthread.h>
-#include <stdlib.h>
 #include <threads.h>
 
 void
@@ -45,8 +43,8 @@
        _DIAGASSERT(flag != NULL);
        _DIAGASSERT(func != NULL);
 
-       /* The call_once(3) function returns no value, this forces this code to
-        * break as there is nothing better available. */
-       if (pthread_once(flag, func) != 0)
-               errx(EXIT_FAILURE, "pthread_once failed");
+       /*
+        * The call_once(3) function that conforms to C11 returns no value.
+        */
+       (void)pthread_once(flag, func);
 }



Home | Main Index | Thread Index | Old Index