From nobody Mon Feb 9 04:14:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531825822582720.0548049323278; Tue, 17 Jul 2018 04:10:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49FF9307D867; Tue, 17 Jul 2018 11:10:21 +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 0CCA21949A; Tue, 17 Jul 2018 11:10:21 +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 A153E18037EF; Tue, 17 Jul 2018 11:10:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6HBA4wr029118 for ; Tue, 17 Jul 2018 07:10:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC6457C33; Tue, 17 Jul 2018 11:10:04 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D9CF7C4D for ; Tue, 17 Jul 2018 11:10:04 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 17 Jul 2018 13:09:57 +0200 Message-Id: <20180717110957.12036-4-abologna@redhat.com> In-Reply-To: <20180717110957.12036-1-abologna@redhat.com> References: <20180717110957.12036-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] m4: Work around MinGW detection of strncpy() usage 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 17 Jul 2018 11:10:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With the recent update in Fedora Rawhide, MinGW has started freaking out about our use of strncpy(): In function 'virStrncpy', inlined from 'virStrcpy' at ../../src/util/virstring.c:811:12: ../../src/util/virstring.c:789:11: error: 'strncpy' output truncated befo= re terminating nul copying as many bytes from a string as its length [-Werr= or=3Dstringop-truncation] ret =3D strncpy(dest, src, n); ^~~~~~~~~~~~~~~~~~~~~ ../../src/util/virstring.c: In function 'virStrcpy': ../../src/util/virstring.c:811:12: note: length computed here return virStrncpy(dest, src, strlen(src), destbytes); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What the compiler is not detecting is that we perform proper bound checking right before calling the function, which makes our use of it perfectly safe. Signed-off-by: Andrea Bolognani --- Kind of a big hammer, so if you have a better approach in mind please don't hesitate to step forward. cfg.mk | 2 +- m4/virt-compile-warnings.m4 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 609ae869c2..d059f803eb 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1240,7 +1240,7 @@ exclude_file_name_regexp--sc_prohibit_setuid =3D ^src= /util/virutil\.c$$ exclude_file_name_regexp--sc_prohibit_sprintf =3D \ ^(cfg\.mk|docs/hacking\.html\.in|.*\.stp|.*\.pl)$$ =20 -exclude_file_name_regexp--sc_prohibit_strncpy =3D ^src/util/virstring\.c$$ +exclude_file_name_regexp--sc_prohibit_strncpy =3D ^(src/util/virstring\.c|= m4/virt-compile-warnings\.m4)$$ =20 exclude_file_name_regexp--sc_prohibit_strtol =3D ^examples/.*$$ =20 diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index fc185aef38..7d71cf2504 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -243,6 +243,11 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ wantwarn=3D"$wantwarn -Wno-suggest-attribute=3Dpure" wantwarn=3D"$wantwarn -Wno-suggest-attribute=3Dconst" =20 + # MinGW freaks out about our use of strncpy(), but we perform proper + # bound checking in our wrappers and prevent the underlying POSIX + # functions from being used directly through syntax-check + wantwarn=3D"$wantwarn -Wno-stringop-truncation -Wno-stringop-overflow" + if test "$enable_werror" =3D "yes" then wantwarn=3D"$wantwarn -Werror" --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list