From nobody Tue Apr 23 17:28:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605289367; cv=none; d=zohomail.com; s=zohoarc; b=hZBDlpTGyayAyYHGzzI3fM7siT1lNIhMweEn+0j5ERojr2aNEckRwXOARuuRVlfzHOgAFFrH8nQ0l6JUNBRWiW/bMDlJtHKSfkgLDL/JKjQNGWUT0t6mmAC8uM7FhXexe+Fb33l//iBSM7Glt7wbNsFJnM4GDsS3y4SG/fvCCNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605289367; 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=rgrZ/xjbWtGSE0ogGTBXb7HwCn7wDunMoR7ukAxc+5s=; b=JS2E3+ig8W7byiZ38EH0n+jaCyrZ9jbLyAwby/Kim8ZzC/7QEBKztrx8Ti+IEL4GBgQD3gu1jVUzIky3yImddDWBHf4+wH9pS7WJozcD5Wbz6zLRE/L+4cvW/hcBXz6kr7Rv1nLPfKWJCUxyIBs5AT39yP3w7/2qVMMvmyR+zPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605289367203495.5751523408054; Fri, 13 Nov 2020 09:42:47 -0800 (PST) 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-149-55boPP2gM9CvNj2mPMo2pA-1; Fri, 13 Nov 2020 12:42:43 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BA13803648; Fri, 13 Nov 2020 17:42:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E700C1002C0D; Fri, 13 Nov 2020 17:42:35 +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 6CAB358100; Fri, 13 Nov 2020 17:42:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ADHgXNW003527 for ; Fri, 13 Nov 2020 12:42:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 58BBF1002D49; Fri, 13 Nov 2020 17:42:33 +0000 (UTC) Received: from vhost2.laine.org (ovpn-114-178.phx2.redhat.com [10.3.114.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 193AF1002D46 for ; Fri, 13 Nov 2020 17:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605289366; 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=rgrZ/xjbWtGSE0ogGTBXb7HwCn7wDunMoR7ukAxc+5s=; b=YaZc1a/9ZByN5tzmVs0zKSUKP/ZrRJrmtDPIcSx8zQM2bxBhznu7ZCOgU9kB1rC+oLEwzl 2I1gAJ1oY68pw1ctBDeojDVc2357XgM7z8Wpizr25CNwvQ8H4thowCe54uPK8Tezqhav5G BYN2JrzwXbRyHD9RsR3f/FMwL1EeEQ0= X-MC-Unique: 55boPP2gM9CvNj2mPMo2pA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH] util: remove ATTRIBUTE_NONNULL from virDirClose declaration Date: Fri, 13 Nov 2020 12:42:27 -0500 Message-Id: <20201113174227.2544422-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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" Before commit 24d8968c, virDirClose took a DIR**, and that was never NULL, so its declaration included ATTRIBUTE_NONNULL(1). Since that commit, virDirClose takes a DIR*, and it may be NULL (e.g. if the DIR* is initialized to NULL and was never closed). Even though virDirClose() is currently only called implicitly (as the cleanup for a g_autoptr(DIR)), and (as I've just newly learned) the autocleanup function g_autoptr will only be called if the pointer in question is non-null (see the definition of _GLIB_AUTOPTR_CLEAR_FUNC_NAME in /usr/include/glib-2.0/glib/gmacros.h), it does still cause Coverity to complain that it *could* be called with a NULL, and it's also possible that in the future someone might add code that explicitly calls virDirClose. To eliminate the Coverity complaints, and protect against the hypothetical future where someone both explicitly calls virDirClose() with a potentially NULL value, *and* re-enables the nonnull directive when not building with Coverity (disabled by commit eefb881) this patch removes the ATTRIBUTE_NONNULL(1) from the declaration of virDirClose(). Fixes: 24d8968cd0a718af4badbbc858b1b449fea7205a Details-Research-by: Dan Berrange Signed-off-by: Laine Stump --- src/util/virfile.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virfile.h b/src/util/virfile.h index ba31a78e58..32505826ee 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -269,8 +269,7 @@ int virDirOpenQuiet(DIR **dirp, const char *dirname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; int virDirRead(DIR *dirp, struct dirent **ent, const char *dirname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; -void virDirClose(DIR *dirp) - ATTRIBUTE_NONNULL(1); +void virDirClose(DIR *dirp); G_DEFINE_AUTOPTR_CLEANUP_FUNC(DIR, virDirClose); =20 int virFileMakePath(const char *path) G_GNUC_WARN_UNUSED_RESULT; --=20 2.28.0