From nobody Wed May 14 23:47:28 2025 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 1525344981538496.727438214989; Thu, 3 May 2018 03:56:21 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CA26E806B5; Thu, 3 May 2018 10:56:19 +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 E65CD60BE2; Thu, 3 May 2018 10:56:18 +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 9A6084CAAA; Thu, 3 May 2018 10:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w43AsVXT018694 for ; Thu, 3 May 2018 06:54:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BF3D2023459; Thu, 3 May 2018 10:54:31 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 204E42023456 for ; Thu, 3 May 2018 10:54:31 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:20 +0200 Message-Id: <20180503105423.24837-7-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 6/9] tests: Fix mode_t usage with va_arg() 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 03 May 2018 10:56:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Clang complains about it: error: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Werror,-Wvarargs] mode =3D va_arg(ap, mode_t); ^~~~~~ Work around the issue by passing int to va_arg() and casting its return value to mode_t afterwards. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/nssmock.c | 2 +- tests/vircgroupmock.c | 2 +- tests/virpcimock.c | 2 +- tests/virtestmock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/nssmock.c b/tests/nssmock.c index 7929c3061c..fc8e6b22f0 100644 --- a/tests/nssmock.c +++ b/tests/nssmock.c @@ -87,7 +87,7 @@ open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, int); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 56337c2f3e..51861be38e 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -731,7 +731,7 @@ int open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 79352175de..7e4ac191d0 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -983,7 +983,7 @@ open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 4e679f35c0..c3b0aa2d9c 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -181,7 +181,7 @@ int open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(path, flags, mode); } else { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list