From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9E9BC3DA6E for ; Wed, 20 Dec 2023 14:57:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFy05-0004DD-4P; Wed, 20 Dec 2023 09:56:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFxzz-0004CA-Cy for qemu-devel@nongnu.org; Wed, 20 Dec 2023 09:56:40 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFxzw-0003wD-3f for qemu-devel@nongnu.org; Wed, 20 Dec 2023 09:56:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703084196; x=1734620196; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=PKc1ISqFtxu2kS1upPQhC9NPSsW4VFR9ZQIe0KkdXMc=; b=LeTZKUjpFIMpVStNZpzGq3aokUs5/7TGktb32xjUpzYiICpPOVHkFOP9 1UGNZvkILRZNU4Y2H1tSWgcnzq5rrKRGwUsfCp0WnOyeI60uXiCP6d5AI rcXlmLR+Wj3el7HV/zBp4wzIT25WfS7nFYk7ZdOlu6oFZi/rymCFyC/3Z /OVwc4mCPWfNZpB/AfSazVlQZHWuxOuIx5DO1FJYnUm9OfbBiwWRqrKTb GSb80tvp++qCwIZhh8RJOPbk+x4A63tT8e6QfFvMC5yvLgi/uerhkEjND XxIXCNvHQI/RqZdk0CHF1iX0h3/md1NV9mGWs8ULsFr9WA5JlJHsuKXxy w==; X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="2652997" X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="2652997" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 06:56:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="24597805" Received: from liuzhao-optiplex-7080.sh.intel.com (HELO localhost) ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 20 Dec 2023 06:56:28 -0800 Date: Wed, 20 Dec 2023 23:09:12 +0800 From: Zhao Liu To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: qemu-devel@nongnu.org, Eric Auger , Zhenzhong Duan , Alex Williamson , Khem Raj Subject: Re: [PATCH] vfio/container: Replace basename with g_path_get_basename Message-ID: References: <20231220135302.932039-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231220135302.932039-1-clg@redhat.com> Received-SPF: pass client-ip=192.198.163.11; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hi Cédric, On Wed, Dec 20, 2023 at 02:53:02PM +0100, Cédric Le Goater wrote: > Date: Wed, 20 Dec 2023 14:53:02 +0100 > From: Cédric Le Goater > Subject: [PATCH] vfio/container: Replace basename with g_path_get_basename > X-Mailer: git-send-email 2.43.0 > > g_path_get_basename() is a portable utility function that has the > advantage of not modifing the string argument. It also fixes a compile > breakage with the Musl C library reported in [1]. > > [1] https://lore.kernel.org/all/20231212010228.2701544-1-raj.khem@gmail.com/ > > Reported-by: Khem Raj > Signed-off-by: Cédric Le Goater > --- Reviewed-by: Zhao Liu Just one additional question, I understand that QEMU should replace all basename() with g_path_get_basename(), right? I find hw/s390x/s390-ccw.c also uses basename(). Maybe I can clean it up to avoid potentially similar issue. Thanks, Zhao > hw/vfio/container.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/hw/vfio/container.c b/hw/vfio/container.c > index 688cf23bab88f85246378bc5a7da3c51ea6b79d9..8d334f52f2438d05f632502e07ffd4dc2ec76cb5 100644 > --- a/hw/vfio/container.c > +++ b/hw/vfio/container.c > @@ -869,7 +869,8 @@ static void vfio_put_base_device(VFIODevice *vbasedev) > > static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp) > { > - char *tmp, group_path[PATH_MAX], *group_name; > + char *tmp, group_path[PATH_MAX]; > + g_autofree char *group_name = NULL; > int ret, groupid; > ssize_t len; > > @@ -885,7 +886,7 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp) > > group_path[len] = 0; > > - group_name = basename(group_path); > + group_name = g_path_get_basename(group_path); > if (sscanf(group_name, "%d", &groupid) != 1) { > error_setg_errno(errp, errno, "failed to read %s", group_path); > return -errno; > -- > 2.43.0 > >