From nobody Wed Nov 19 15:18:10 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1616161221; cv=none; d=zohomail.com; s=zohoarc; b=dBuis6X+5oBKJGcL+Ti7AakqpYNwFYUeqR53YqAItL7jToAhJ/qBjtUUaUVyNkjQqruH7KsrGJKmDNYdk4ub75QRyPxb4aAYZ5EGAOKSSCFn/nPReCp3TEdORdZ6MNufFibnZxkgvLh7FUQeVd1XnG4SNGXLouKtsTwhjp2VZnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616161221; h=Content-Transfer-Encoding:Cc: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=Z2u3q3r6w6+qN78egFiLHd6jOUJq1Ybg2sCdGyDUnAM=; b=lbz0RzY6btyA3BavRr3SynBsNoqdbPqcLhYoKF0foBeUOJ2aT13gD0PNja4SMUQi2+URFGqXD4HXO2GOt7jvTKH+VhuervUkBVfBiS+VD9pLN3qLEqTMV/8I5zuyoWkIPmrAXZI7WDwAX36c0Hl4AJiOvmxdFsybiJ87Tqj89mg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616161221008777.8658653275031; Fri, 19 Mar 2021 06:40:21 -0700 (PDT) Received: from localhost ([::1]:42608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNFMR-0001k5-Eb for importer@patchew.org; Fri, 19 Mar 2021 09:40:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNF9E-0001KV-AR for qemu-devel@nongnu.org; Fri, 19 Mar 2021 09:26:40 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:43710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNF9B-0004E3-FE for qemu-devel@nongnu.org; Fri, 19 Mar 2021 09:26:40 -0400 Received: by mail-wm1-x32f.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so5239476wmj.2 for ; Fri, 19 Mar 2021 06:26:36 -0700 (PDT) Received: from localhost.localdomain ([102.47.92.134]) by smtp.googlemail.com with ESMTPSA id v13sm8889584wrt.45.2021.03.19.06.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 06:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z2u3q3r6w6+qN78egFiLHd6jOUJq1Ybg2sCdGyDUnAM=; b=jQO5AkXBiHKNB+Am/VXnapVwjYC2AMFUqmbnPoYi7GlrLBKtHCc3dA1Yns9zDBt7XK CBUsn5ZEpM9wbqy6HDH35PZHbvmqxTGKHYLX9j+hINcs+APhhDpJoMGh2d2JHpGKsaKS nLNK5X1mjsNYqrQvubTRKRITaL0YNTHf9BNzBWsqKfo7d7xqfhPhy9mcxQCoxOaLA+YI gRYbjLHvyOhg0fCwrI07HHcBaAwKTRfBBwDqo6s3v2Ey8WqE+61Ia/g3jNzY+nWA+zwd 71EEjOjGJ6gCLj/NhW3RI5RwF3gipDed6kg6GAaKuHKFWLWY+X1xX+JfeseWDQ0Tq2Lt CCLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2u3q3r6w6+qN78egFiLHd6jOUJq1Ybg2sCdGyDUnAM=; b=bD66HMjigX26HMtvquN4K0Kx77GIB3V6JZSRanp7AhFNf5vJiIVUh3xw3SJr53tjID R34dOAwiBpGc+w6fom1PaRy8PMmnZ2Utll+F6zlUJKG/tlJOp7cSJrt1brwZdIS4sNGG XM+044nvtVKcPP/PUxML4lb5E662xsdcBHTraJBMGjvMFR3uIPhokck7k39ST10PTDkx wJm0gSgvqvrYpJZ8p38q/IJ24J9xntsSG8s8iwLQZhLbsC/S7KiXNSekYHTtpoNEqCjx ing4LM3HMJLh5dWBIkxVr1IxAXg4/9cDMxLqLoERHmt+vQUvlTdq0h/1usqk4Ykr5L5B JR9Q== X-Gm-Message-State: AOAM531pNBfuIGNhp8tM4r5Vrfw7dQmP646azMgcX5WxsDCgho8qoE5x 9YlUtNzeVrMP1A/MIxje97IFwcCkAAE= X-Google-Smtp-Source: ABdhPJxj7rOYhwZjq6QDiEtVp+fXMUMqw1ejkJHJJjgBzFUBHZNqSf3jlPZc4U+Cl395dkl+GZFbtQ== X-Received: by 2002:a1c:b4c6:: with SMTP id d189mr3718417wmf.72.1616160395842; Fri, 19 Mar 2021 06:26:35 -0700 (PDT) From: Mahmoud Mandour To: qemu-devel@nongnu.org Subject: [PATCH 8/8] virtiofsd/fuse_virtio.c: Changed allocations of locals to GLib Date: Fri, 19 Mar 2021 15:25:27 +0200 Message-Id: <20210319132527.3118-9-ma.mandourr@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319132527.3118-1-ma.mandourr@gmail.com> References: <20210319132527.3118-1-ma.mandourr@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=ma.mandourr@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahmoud Mandour Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" Replaced the allocation of local variables from malloc() to GLib allocation functions. In one instance, dropped the usage to an assert after a malloc() call and used g_malloc() instead. Signed-off-by: Mahmoud Mandour Reviewed-by: Stefan Hajnoczi --- tools/virtiofsd/fuse_virtio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 5828b9a76f..587403b026 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -472,8 +472,7 @@ static void fv_queue_worker(gpointer data, gpointer use= r_data) * They're spread over multiple descriptors in a scatter/gather set * and we can't trust the guest to keep them still; so copy in/out. */ - fbuf.mem =3D malloc(se->bufsize); - assert(fbuf.mem); + fbuf.mem =3D g_malloc(se->bufsize); =20 fuse_mutex_init(&req->ch.lock); req->ch.fd =3D -1; @@ -524,7 +523,7 @@ static void fv_queue_worker(gpointer data, gpointer use= r_data) fbuf.size =3D out_sg[0].iov_len + out_sg[1].iov_len; =20 /* Allocate the bufv, with space for the rest of the iov */ - pbufv =3D malloc(sizeof(struct fuse_bufvec) + + pbufv =3D g_try_malloc(sizeof(struct fuse_bufvec) + sizeof(struct fuse_buf) * (out_num - 2)); if (!pbufv) { fuse_log(FUSE_LOG_ERR, "%s: pbufv malloc failed\n", @@ -569,7 +568,7 @@ static void fv_queue_worker(gpointer data, gpointer use= r_data) =20 out: if (allocated_bufv) { - free(pbufv); + g_free(pbufv); } =20 /* If the request has no reply, still recycle the virtqueue element */ @@ -588,7 +587,7 @@ out: } =20 pthread_mutex_destroy(&req->ch.lock); - free(fbuf.mem); + g_free(fbuf.mem); free(req); } =20 --=20 2.25.1