From nobody Wed Nov 27 00:35:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1703178727; cv=none; d=zohomail.com; s=zohoarc; b=iRfG8eBgFcvq5xJvVlIzoNaheDfg3R7m4CDiINrZ6UGvTco/NiiNClh8m9HHgCi420DwAR1jevIJJwGOOqJFTR2gqBxZR+ctxbwZpq83oaSkYq7Im/KbWpU1ASXE3K2/CINtsKhfwsQ4i1s/QuCSEDTZjoE0DZ05xRpvmedvBtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703178727; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lkMzkaH9fyhu655YU71cWdujlDMWU+Gx8olJNID8MaU=; b=Pk6/qQY007jk1z8scF8I4J4m/HCznkLP/NARMuiChWk6+obQVNmZDphOOyr17Mw7bNrhacROwfnAUTTzkBJznuPSkBzx5IdRHl0BCjoWeJQAmQGZ7GjoTivDQ7WFxOkB57VetyKZ8ObZBZZUYftO6Ysm8cgdmjXbr4uKTE6x70c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703178727743459.00367217870723; Thu, 21 Dec 2023 09:12:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGMa6-0004Bz-G0; Thu, 21 Dec 2023 12:11:34 -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 1rGMa4-0004Ba-Ic; Thu, 21 Dec 2023 12:11:32 -0500 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGMa1-0002Ye-WC; Thu, 21 Dec 2023 12:11:32 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2023 09:06:55 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga003.jf.intel.com with ESMTP; 21 Dec 2023 09:06:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703178690; x=1734714690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f+D2TgM3xmuW9/oGq31Ico4D2XznPPyfCUDyYI4vs5s=; b=iLLbnLUTCWmXj6RkonT05v9yArKE/rCDl1I8gAptiAwdQ2EKJmlK/6DB TpMhvJX9+u6MGOwpLIaVtTd4Z3nzuly2hPttAaHjPwl8bLRCxvvSrNXZV /Z0EvbkBM96VXEOKgcfwa4IhbPZ+CF/HRjnvh6YD7qld32R6sVeLqzGAH A2TI1KCCINuzNYPNuO/JXTSSJ/HyJWXITx0YqkwIuSKFMlZbyvtyPigUg z8MqyGissBDaRgOuxBKCeCuzqb2cF5wFPuClUgZb1sa5AZpiv4Hk1QxO9 mI9sTUMNThzDsWgMZLvJzTi37g/IQxa+uFQKP3LnqfsWHimxxnDVaVrTx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="393170635" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="393170635" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="726488834" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="726488834" From: Zhao Liu To: Eric Farman , Matthew Rosato , Thomas Huth , Halil Pasic , Christian Borntraeger , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Zhao Liu Subject: [PATCH 2/2] hw/s390x/ccw: Replace dirname() with g_path_get_dirname() Date: Fri, 22 Dec 2023 01:19:21 +0800 Message-Id: <20231221171921.57784-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221171921.57784-1-zhao1.liu@linux.intel.com> References: <20231221171921.57784-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: none client-ip=192.55.52.93; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.061, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1703178729161100005 From: Zhao Liu As commit 3e015d815b3f ("use g_path_get_basename instead of basename") said, g_path_get_dirname() should be preferred over dirname() since the former is a portable utility function that has the advantage of not modifing the string argument. Replace dirname() with g_path_get_dirname(). Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhao Liu Reviewed-by: C=C3=A9dric Le Goater --- Suggested by credit: C=C3=A9dric: Referred his words for g_path_get_basename() and g_path_get_dirname() has the same advantage. --- hw/s390x/s390-ccw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index ab7022a3abe8..5261e66724f1 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -77,6 +77,7 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, { unsigned int cssid, ssid, devid; char dev_path[PATH_MAX] =3D {0}; + g_autofree char *tmp_dir =3D NULL; g_autofree char *tmp =3D NULL; =20 if (!sysfsdev) { @@ -93,7 +94,8 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, =20 cdev->mdevid =3D g_path_get_basename(dev_path); =20 - tmp =3D g_path_get_basename(dirname(dev_path)); + tmp_dir =3D g_path_get_dirname(dev_path); + tmp =3D g_path_get_basename(tmp_dir); if (sscanf(tmp, "%2x.%1x.%4x", &cssid, &ssid, &devid) !=3D 3) { error_setg_errno(errp, errno, "Failed to read %s", tmp); return; --=20 2.34.1