From nobody Thu Jun 30 17:35:33 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0A70B872041; Thu, 30 Jun 2022 17:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LYlps6rGhz4Ttt; Thu, 30 Jun 2022 17:35:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656610534; h=from:from: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; bh=CNckMHeEoxOIuMMBIK/D2GJfLkLBo+aqx2t0Q48P1vM=; b=ctWOMTgiapOBJxIfCTP4gWU6bldhM5CGdKsFp+C0FKulje+//0Y6rm3UaUo3fE+DWAguyL +6HwEw7kwOrxeS/JVzkRQdIF8CROD/u/FRL7OOObbKNhXA1Yc1pGEXCmONJIrVa2ZCRh24 N+n6XhJJ3Ywf+yZBSgjRmMAGEiwSCK0yq0E5JSJ1F3KzbXTj2mfc1bqaXAzonj4ChGiH4N P4PEV3paTD4ZXuJRk96q/1wSTdgXjZX326fnTMM9rGHNOihpFsyhJpMq+zuXdwY3Fs2IQy eP0ILGr9nU/adfGJrRNO1ZZbzSLv9WJgjBofmSlUzYENGY4wR4D6NR2Xn4yjCg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CAEEF2A57; Thu, 30 Jun 2022 17:35:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25UHZXks024112; Thu, 30 Jun 2022 17:35:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25UHZXA2024111; Thu, 30 Jun 2022 17:35:33 GMT (envelope-from git) Date: Thu, 30 Jun 2022 17:35:33 GMT Message-Id: <202206301735.25UHZXA2024111@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 91b30f7ad226 - main - rb_tree: silence coverity List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91b30f7ad22642979b56a56b211843cbd9d35984 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656610534; h=from:from: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; bh=CNckMHeEoxOIuMMBIK/D2GJfLkLBo+aqx2t0Q48P1vM=; b=ODy9QO3unSUnsUANapGvf7OivqfUcoaDYkA2atKyuqpFNS025zwPWvDlxKSITc9w3lzwxq v8i87a7nXsKufPjmMDiGvDE+GovaFwG+F33Dssyz9q0+8gFmlmxuTvetfXsdIJF4X77D1K EdZ0gfKurqRPH01JvVufn+YihDFGvKRBBhbenZ9tbi7zYHFpwFPlFjCHZRVTHRe1Bf5vVJ 6bNk4rns0Sj7ZdfIxDVuC/GKw3w278AhlIu3oZ+iIcJHIm6TLf6JAhNOmXIy+5ED+am9gX KGTN9LznjVC6tpAVUkpzep3Jg+iV2iA1L7sImDEr5AYkQp9Mykac1BtjkDAlcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656610534; a=rsa-sha256; cv=none; b=Px5PIpvVX9HGA/C91c8hOxRMrPpbBCRfIqgyhoBYkh99ts01cIfbt2HEGLLjNMTF7GY6N/ Lt8IJMNRmDuSd/9wOVwfCuk2P0mG2Dp+0qNNCLxfAHPg1zX4F61gCjD419rtcB1bumLWgX 4xhInsXOjjcIipbdx6YdasNVOSA91XZMVZmk+zubvakhgbkWhMZ9/pTQxTL+jqh2QLjIhw +jNZMAFOSm0Apl7QhlYRMChuK9IDebAoUzB0KSuMkfTRfzcn/VMan73ASYiO+znYvcWlfZ 2VWfJC6f03QdtS7jJBcDs13OYtYf8sl4MFLsF1zg1g1MYs621TPxjVEX0tfGjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=91b30f7ad22642979b56a56b211843cbd9d35984 commit 91b30f7ad22642979b56a56b211843cbd9d35984 Author: Doug Moore AuthorDate: 2022-06-30 17:27:33 +0000 Commit: Doug Moore CommitDate: 2022-06-30 17:35:05 +0000 rb_tree: silence coverity Add comments to RB_INSERT_COLOR to silence coverity warnings about the use of an uninitialized variable. Since other static analyzers will complain too, add a comment to explain why the complaints are unwarranted. Reviewed by: markj MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D35671 --- sys/sys/tree.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/sys/tree.h b/sys/sys/tree.h index fb0136a0c69a..553d84e57cc8 100644 --- a/sys/sys/tree.h +++ b/sys/sys/tree.h @@ -462,6 +462,17 @@ struct { \ attr void \ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ { \ + /* \ + * Initially, elm is a leaf. Either its parent was previously \ + * a leaf, with two black null children, or an interior node \ + * with a black non-null child and a red null child. The \ + * balance criterion "the rank of any leaf is 1" precludes the \ + * possibility of two red null children for the initial parent. \ + * So the first loop iteration cannot lead to accessing an \ + * uninitialized 'child', and a later iteration can only happen \ + * when a value has been assigned to 'child' in the previous \ + * one. \ + */ \ struct type *child, *parent; \ while ((parent = RB_PARENT(elm, field)) != NULL) { \ if (RB_LEFT(parent, field) == elm) { \ @@ -477,6 +488,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ } \ if (!RB_RED_RIGHT(elm, field)) { \ RB_FLIP_LEFT(elm, field); \ + /* coverity[uninit_use] */ \ RB_ROTATE_LEFT(head, elm, child, field);\ if (RB_RED_LEFT(child, field)) \ RB_FLIP_RIGHT(elm, field); \ @@ -498,6 +510,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ } \ if (!RB_RED_LEFT(elm, field)) { \ RB_FLIP_RIGHT(elm, field); \ + /* coverity[uninit_use] */ \ RB_ROTATE_RIGHT(head, elm, child, field);\ if (RB_RED_RIGHT(child, field)) \ RB_FLIP_LEFT(elm, field); \