From nobody Tue Apr 16 06:25:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620121722; cv=none; d=zohomail.com; s=zohoarc; b=Z1mesY3BGnGGUtX87Sq2DY9Zt3rptuzKzdAYpFASHCWAqEhheYwRVkqY76vtmpZXf1NH2hfizCICKYcWf22AkOPvAu9LyrkA13KFOvU0LEMaYGosoh9/cvcxCpN53TfgpHPIs6mBL7B6FHwRRC44tqdPOgh9N7wuD2Vaw4dWg+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620121722; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=EAlpfJqY3ppb4368UHhFec7hJ1e3AvL4M+0f56YCQIc=; b=UBDhv67Ys30nenm25fIo2EUpN4G8TeLYoend1xJuEBy93gVPS0mDHmdiqlBEtGVJN8ByaAmHqBlCJJCOv+51K+zGhtGV/EkVJZZdOtuGE7EpO7gJUMwA2Qb1qrXoafu7fRg4LgrhuKwBHF8K+os4ByYnMyfXpLLIWy61X/z2rZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620121722064929.2133688473895; Tue, 4 May 2021 02:48:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-FwT6AiI3MFqFQcy7ODpOmg-1; Tue, 04 May 2021 05:48:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAB60101C0D9; Tue, 4 May 2021 09:48:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE9FE60CEF; Tue, 4 May 2021 09:48:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 196181800BBE; Tue, 4 May 2021 09:48:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1449mCSk024042 for ; Tue, 4 May 2021 05:48:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id CC2DF5D9D5; Tue, 4 May 2021 09:48:12 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BBDA5D9C0 for ; Tue, 4 May 2021 09:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620121721; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EAlpfJqY3ppb4368UHhFec7hJ1e3AvL4M+0f56YCQIc=; b=Mu3awP6Yha0jnmQGgDUOsAata+7vY1M+fJYxChfAzSHFapgIw0NWKFjQpHs1FyDrQqznxt peFjjdu9PVoiVpOvDseF0a/osy9PCN6JP2dJ3GL29pp/6GURNO64a3Fpsu2PdKfd6Ahj6V YpmrjbQovoI1V8/RBJm2E7ogyUXx5Lg= X-MC-Unique: FwT6AiI3MFqFQcy7ODpOmg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virthread: Make sure virOnce() returns -1 on error Date: Tue, 4 May 2021 11:48:07 +0200 Message-Id: <648df8a45b81c0234bbf1e67be330543e1f2e1d1.1620121687.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since its introduction in v0.9.1~65 the virOnce() was expected to follow the usual retval logic (0 for success, a negative number for failure). However, that was never the case. On the other hand, looking into glibc and musl the pthread_once() never returns anything other than zero (uclibc-ng seems to not implement pthread_once()), therefore we never really hit any problem. But for code cleanliness (and to match POSIX documentation), let's change to code so that our retval logic is honoured. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virthread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/virthread.c b/src/util/virthread.c index 5ddbf7c49a..e89c1a09fb 100644 --- a/src/util/virthread.c +++ b/src/util/virthread.c @@ -39,7 +39,15 @@ =20 int virOnce(virOnceControl *once, virOnceFunc init) { - return pthread_once(&once->once, init); + int ret; + + ret =3D pthread_once(&once->once, init); + if (ret !=3D 0) { + errno =3D ret; + return -1; + } + + return 0; } =20 =20 --=20 2.26.3