From nobody Sat May 4 18:13:57 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1571386625; cv=none; d=zoho.com; s=zohoarc; b=AMlDQ8xrz/GAiU9GyLwzVL1NL15KAHK2CVlJdOxPWr/LPVhLzTR9PYkMSGf0a7HHAQOOxsJrrKnsP7Epk08tKUxR10Y85Q8FRYpTDFmDVmffr/eCxzC/zughigu+8q8RM58FPKveQbSP7cBaiK3bmZwDKYaSzy1t8XfKKNW7UBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571386625; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FMJbIWmM8PBUlOQrSF8TRnPrHWQ5ldT6h4QZiCwwgnM=; b=grKNBurmdIKxqee8eKjfZMuFHsQU4zKGC4VJiYBZhD/lisrokJLn6Orf+VqdpqJ9HnFNFHzQxGffP4a+35tt3nKGkcA0VKJTMnewWtZ6PZ99sqL7CDkamDz8EpymCAkZdMhI5/Ezx9XwMdEHShHYZYTHDvBCdBEQPjH92vDjINc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571386625146411.37680736009816; Fri, 18 Oct 2019 01:17:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32EC318C8906; Fri, 18 Oct 2019 08:17:03 +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 0D0855C1B5; Fri, 18 Oct 2019 08:17:02 +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 55FCA4E58A; Fri, 18 Oct 2019 08:16:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9I8GvUr011229 for ; Fri, 18 Oct 2019 04:16:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id A25FE19D70; Fri, 18 Oct 2019 08:16:57 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A5F619C77 for ; Fri, 18 Oct 2019 08:16:57 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 10:16:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] virstring: Reimplement g_strdup_printf() and g_strdup_vprintf() 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 18 Oct 2019 08:17:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" These functions don't really abort() on OOM. The fix was merged upstream, but not in the minimal version we require. Provide our own implementation which can be removed once we bump the minimal version. Signed-off-by: Michal Privoznik --- Dan claims this is fixed upstream, but I'm failing to see any abort() in current master: https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gprintf.c#L320 There is g_new() called, but it's done so only in one case out of three. On my system, HAVE_VASPRINTF is defined meaning the function still won't abort(). src/libvirt_private.syms | 2 ++ src/util/virstring.c | 29 +++++++++++++++++++++++++++++ src/util/virstring.h | 11 +++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0da02bb8bd..9eac489a32 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3060,6 +3060,8 @@ virStorageFileBackendRegister; =20 =20 # util/virstring.h +vir_g_strdup_printf; +vir_g_strdup_vprintf; virAsprintfInternal; virSkipSpaces; virSkipSpacesAndBackslash; diff --git a/src/util/virstring.c b/src/util/virstring.c index 6453a23ada..fa7b15d0b7 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -768,6 +768,35 @@ virAsprintfInternal(char **strp, return ret; } =20 + +/* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf() + * abort on OOM. It's fixed in glib's upstream. Provide our own + * implementation until the fix get's distributed. */ +char * +vir_g_strdup_printf(const char *msg, ...) +{ + va_list args; + char *ret; + va_start(args, msg); + ret =3D g_strdup_vprintf(msg, args); + if (!ret) + abort(); + va_end(args); + return ret; +} + + +char * +vir_g_strdup_vprintf(const char *msg, va_list args) +{ + char *ret; + ret =3D g_strdup_vprintf(msg, args); + if (!ret) + abort(); + return ret; +} + + /** * virStrncpy: * diff --git a/src/util/virstring.h b/src/util/virstring.h index f5e2302b8b..b3a85b9ac2 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -253,6 +253,17 @@ size_t virStringListLength(const char * const *strings= ); =20 #define virAsprintfQuiet(strp, ...) virAsprintf(strp, __VA_ARGS__) =20 +char *vir_g_strdup_printf(const char *msg, ...) + G_GNUC_PRINTF(1, 2); +char *vir_g_strdup_vprintf(const char *msg, va_list args) + G_GNUC_PRINTF(1, 0); + +#if !GLIB_CHECK_VERSION(2, 64, 0) +# define g_strdup_printf vir_g_strdup_printf +# define g_strdup_vprintf vir_g_strdup_vprintf +#endif + + int virStringSortCompare(const void *a, const void *b); int virStringSortRevCompare(const void *a, const void *b); int virStringToUpper(char **dst, const char *src); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 18:13:57 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1571386825; cv=none; d=zoho.com; s=zohoarc; b=h0Wl0LyXvWmLHqPfweXD8CNBMsF93s7s0rdJxdY4gG+hNFdlfyA1fNhI227EQdQZ7qcamWGEK8VpjSTO8qK9vZ8xy5BKlp5E/JdNO5o0hZO2RbcExQDDwGtMjPWC2GttTu8Swdgsb6sxuo2vLm/kiIq6duwVQpMHii1lTPpxrNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571386825; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sFd46e4EiOEzZIMoMkFA9tdm57VboXn3dRKICbWR4Ow=; b=kEavI1YfmNGqCs9wDzSGoe4mI6GEAEba9seayPragw3Sn/D6OrOE3GmVWdT2/A5m2wCHbfx9lDRKZzfP28RkxjHMeIq2l1bprk9Sdll1frv/1o89x2MFssuWS40MK4LHib3rzBzq5PzwUbR6NN0u3Y+udxoHef1g01U68pdLgQM= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571386825013234.21376508605567; Fri, 18 Oct 2019 01:20:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 23BEB308A9E0; Fri, 18 Oct 2019 08:20:23 +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 ED3565D9CC; Fri, 18 Oct 2019 08:20:22 +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 92BFF180085A; Fri, 18 Oct 2019 08:20:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9I8Gw6m011236 for ; Fri, 18 Oct 2019 04:16:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7240319D70; Fri, 18 Oct 2019 08:16:58 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF7A019C77 for ; Fri, 18 Oct 2019 08:16:57 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 10:16:50 +0200 Message-Id: <0ecf9e80dea664a69ceab50407dd14fab500f259.1571386383.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] m4: Don't suggest attribute malloc 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 18 Oct 2019 08:20:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With glib inclusion, some of its functions have __attribute__((__malloc__)) which make compiler realize we want to use the same attribute for some trivial functions of ours. For instance qemuDomainManagedSavePath(). I don't see any real benefit into using the attribute, so disable that suggestion. In fact, wrong use of the attribute may lead to mysterious bugs: https://gitlab.gnome.org/GNOME/glib/issues/1465 Signed-off-by: Michal Privoznik --- m4/virt-compile-warnings.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 7c86fdd3c6..1318ca59b9 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -126,6 +126,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ dontwarn=3D"$dontwarn -Wunused-macros" dontwarn=3D"$dontwarn -Woverlength-strings" dontwarn=3D"$dontwarn -Wstack-protector" + dontwarn=3D"$dontwarn -Wsuggest-attribute=3Dmalloc" =20 # Get all possible GCC warnings gl_MANYWARN_ALL_GCC([maybewarn]) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list