From nobody Wed May 8 23:38:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1635175947; cv=none; d=zohomail.com; s=zohoarc; b=Sllj5CgQTJ61TxdC+o4OakuwOYRtJU2bjp9qu1FUt0uomichapD0ErOpMMqKDN2eyN9Llbo9nbzAwGDG9DnS/Jk9zJPZWK7LZY40HgyHD3PcTwKQimLN4WHvJdpAIYx1QFAiWL2A1SbqxulXzEuOdXKTWiA7bRraRIK35Tj4UOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635175947; 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=xJNM9IG8c6vziovnXjB3Q9Lg+kMv1Vx0jM23cwsoJ8U=; b=Qgp8VoRVAX1MT7c2ohuEmLf5NXfiBaUiZZQDSMXVQuYVAihsF+0LWLjJTj4sy/oRdkvvw00Sap3NQ0fNgd+Pv7a4n0DnoNcVSfZZrjRUvBG3wUlnCOgZlJGOGAvPZqxrB8neF3Ejpfjn9tp1mAmBFA6mTT7widk1PQ5jzYxhVQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635175947021428.66948361307084; Mon, 25 Oct 2021 08:32:27 -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-49-pU7yLEuuMqmD8uSFDsog3Q-1; Mon, 25 Oct 2021 11:32:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1034B102C8D5; Mon, 25 Oct 2021 15:32:17 +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 C142C1816A; Mon, 25 Oct 2021 15:32: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 78A661801241; Mon, 25 Oct 2021 15:32:11 +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 19PFWA7R015424 for ; Mon, 25 Oct 2021 11:32:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C91B60C2E; Mon, 25 Oct 2021 15:32:10 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 044555DF21 for ; Mon, 25 Oct 2021 15:32:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8E4E724014E; Mon, 25 Oct 2021 17:32:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635175946; 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=xJNM9IG8c6vziovnXjB3Q9Lg+kMv1Vx0jM23cwsoJ8U=; b=BVUjEhMxibHn01P7dDd5rpPKiNjMYY5TTN7ryZdLezdgM8c8d1ufRZH8PoLAQjwWfpgtFv RWPVtnUBVOk20C0oxO1vySfTc5kTV95WYrH9T/tqvday0xGGj6m/k83iiJnRBvBI1hdDtO WPAOKznWCt4JAYgot5aWR3sEm+lJnRY= X-MC-Unique: pU7yLEuuMqmD8uSFDsog3Q-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH] util: Drop pointless NUL_TERMINATE macro Date: Mon, 25 Oct 2021 17:32:05 +0200 Message-Id: <7b32647502884412fdb7e99cf519e404e069eb3b.1635175925.git.jdenemar@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.14 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) X-ZM-MESSAGEID: 1635175949183100001 Content-Type: text/plain; charset="utf-8" It's only used once and open coding it is at least as clear as using the macro. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/internal.h | 2 -- src/util/virutil.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/internal.h b/src/internal.h index e1250a59fe..d3809bf057 100644 --- a/src/internal.h +++ b/src/internal.h @@ -91,8 +91,6 @@ #define STREQ_NULLABLE(a, b) (g_strcmp0(a, b) =3D=3D 0) #define STRNEQ_NULLABLE(a, b) (g_strcmp0(a, b) !=3D 0) =20 -#define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] =3D '\0'; } while (0) - #ifdef WIN32 # ifndef O_CLOEXEC # define O_CLOEXEC _O_NOINHERIT diff --git a/src/util/virutil.c b/src/util/virutil.c index c9de043c40..e04f1343d8 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -485,7 +485,7 @@ virGetHostnameImpl(bool quiet) "%s", _("failed to determine host name")); return NULL; } - NUL_TERMINATE(hostname); + hostname[sizeof(hostname) - 1] =3D '\0'; =20 if (STRPREFIX(hostname, "localhost") || strchr(hostname, '.')) { /* in this case, gethostname returned localhost (meaning we can't --=20 2.33.1