From patchwork Tue May 15 06:31:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olaf Hering X-Patchwork-Id: 10400019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 747196019C for ; Tue, 15 May 2018 06:33:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C28826242 for ; Tue, 15 May 2018 06:33:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 304D927DA4; Tue, 15 May 2018 06:33:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35ADD26242 for ; Tue, 15 May 2018 06:33:12 +0000 (UTC) Received: from localhost ([::1]:45695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fITWJ-0001p2-I5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 May 2018 02:33:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fITV2-00011D-BD for qemu-devel@nongnu.org; Tue, 15 May 2018 02:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fITV1-0002Ei-FK for qemu-devel@nongnu.org; Tue, 15 May 2018 02:31:52 -0400 Received: from mo6-p01-ob.smtp.rzone.de ([2a01:238:20a:202:5301::11]:24815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fITUw-0002CX-JQ; Tue, 15 May 2018 02:31:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1526365905; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=AuQwEfYVBoxLZic6+3CfPIRTJb887AgR8zPqlKjVwLc=; b=SwwXRTcH6ZPqMJ1ettqRFcXSAF3xDmKmz/odHpJtvEd6Nfq7EW05VIuUuIrFF+8rwN OoJa41Vun76sT57ShuhcW58JgfzzGB1OKk3WwsPjMdS0xq8E438DX0idOCezkH9c0bSU JV44Y649NqaUaxjAOZTwG0Bd2rsEB+be1RvEs+9zkdTE/OuLpfclbKfawLHcU5PFdF3E 2dTCz2tcUbITP/V4zpuLfWOj2bG2eHz5RX+c0YxZWqhLMVJ0A++Ii9G6DWALVp30D7rh +KO8enfVPLJitE9LBIKW5gbqIg2/FDMt6W/DMwDkYWep/Qrr6hMApaiBK5T9pxDd6vX1 Brug== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgc09VbzR8stxx+XNVGnx9ZX3co74kFtJGu5gyLH" X-RZG-CLASS-ID: mo00 Received: from sender by smtp.strato.de (RZmta 43.8 AUTH) with ESMTPSA id h032f7u4F6VU2YI (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Tue, 15 May 2018 08:31:30 +0200 (CEST) From: Olaf Hering To: qemu-trivial@nongnu.org Date: Tue, 15 May 2018 08:31:28 +0200 Message-Id: <20180515063128.7040-1-olaf@aepfle.de> X-Mailer: git-send-email 2.16.3 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 2a01:238:20a:202:5301::11 Subject: [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Olaf Hering , Fam Zheng , "open list:All patches CC here" , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the minimal supported version of glib is 2.22. Since testing is done with a glib that claims to be 2.22, but in fact has APIs from newer version of glib, this bug was not caught during submit of the patch referenced below. Replace g_realloc_n, which is available only since 2.24, with g_renew. Fixes commit 418026ca43 ("util: Introduce vfio helpers") Signed-off-by: Olaf Hering Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck --- This must go into stable-2.12. util/vfio-helpers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 006674c916..1d9272efa4 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s, assert(index >= 0); s->nr_mappings++; - s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]), - s->nr_mappings); + s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings); insert = &s->mappings[index]; shift = s->nr_mappings - index - 1; if (shift) { @@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping, memmove(mapping, &s->mappings[index + 1], sizeof(s->mappings[0]) * (s->nr_mappings - index - 1)); s->nr_mappings--; - s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]), - s->nr_mappings); + s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings); } /* Check if the mapping list is (ascending) ordered. */