From nobody Tue Feb 10 05:10:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1622425740; cv=none; d=zohomail.com; s=zohoarc; b=I/DdwqGOYwzCcbbk1BJQtP9BIGsp7906W7wI2MPbQlzQBPkfmE68l4j4nsTdzXIDk3T1hgMSV+qhYF6S8Lqv8qF5izNZIGHvYqIZr25YHr/nr4umQexX8lXtkSXjDOwvES0YON9sCRrwjKTEUYXEqKmiejh4vEiopz/j2hHBLe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622425740; 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=LoEX4OCcmLeZHruUwj2C+d//tcSZ/1rTW5qoX+WLMxU=; b=k/e35kpzHTioPmEu36QDYgW5UGMRdqUIVsrRWR7DB36efcGw5XRouwwBhDU8UnV5BJvt2ALvuz9z0b6+UkydYsrv2dNLGN0ZECYWp3Cts+l69QlBb92Y5+NNIN4cYzIeKQfRkYRkaBWGxOxFzFfWUIoTuVNBntyhakwoskYmIHY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622425740684844.5775356956883; Sun, 30 May 2021 18:49:00 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-7WM1wgeQPve8KuP2eCKGqA-1; Sun, 30 May 2021 21:48:57 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C762D107ACE3; Mon, 31 May 2021 01:48:52 +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 7D7A15DEAD; Mon, 31 May 2021 01:48:52 +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 38BB6180B465; Mon, 31 May 2021 01:48:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14V1moaV007384 for ; Sun, 30 May 2021 21:48:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id A64CD1111A4E; Mon, 31 May 2021 01:48:50 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FDC7100296D for ; Mon, 31 May 2021 01:48:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6D05101D221 for ; Mon, 31 May 2021 01:48:45 +0000 (UTC) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-XSE-We0-Mxa2XiByZXb4mw-1; Sun, 30 May 2021 21:48:43 -0400 Received: by mail-pl1-f181.google.com with SMTP id q16so4422120pls.6 for ; Sun, 30 May 2021 18:48:43 -0700 (PDT) Received: from localhost ([103.138.53.238]) by smtp.gmail.com with ESMTPSA id s19sm9297689pfm.212.2021.05.30.18.48.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 18:48:41 -0700 (PDT) X-MC-Unique: 7WM1wgeQPve8KuP2eCKGqA-1 X-MC-Unique: XSE-We0-Mxa2XiByZXb4mw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LoEX4OCcmLeZHruUwj2C+d//tcSZ/1rTW5qoX+WLMxU=; b=ErPk3rFCsLcaHPWrsKDWszaCOqb5kiwdVQm8CWcA5ZRbynV0SpLMEvyPlPeejJlH5Y AhxxF/D2gISjmELseq0BfhGhJjINRJpuLW2rC9QhtXrBOfxwpPbDCzOx9OrAuduMeuCu MsW01zek6aGFxO0ecHBFFEPQbG8ABcqopJbEUPjGkQoWFn7cc2IbmOWsS4x78gD0B06J oz2y8UxE4cwEhiXotkIvBF5K2c4R7QcQ5+2GZicAu9P8jQHE4YvzY0Fu9/4+ExrJZJPu o5brBh0EirX9fXEG2cdHMJ4pX1EeJcyIKzvXgVJNMYaHMx4RJb/CGHio1mbJ487kaTvY T6Ug== X-Gm-Message-State: AOAM532KJlefyA+G1qILfUFtFdZU3vSzfHIKCTvvehdxRUg0FUMxAjuW AytUv7PjrByzuVkRjie7A5jlfEnDtDZ3/i5qtrc= X-Google-Smtp-Source: ABdhPJxKL1RJcTBeiwo+m5yauQnovv2Z/LDp1XADj5S7Mz6wPzRypF2flT20mVe4B979XiN0ILgkNQ== X-Received: by 2002:a17:90a:560b:: with SMTP id r11mr16454361pjf.224.1622425722020; Sun, 30 May 2021 18:48:42 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 3/3] virfile: Use g_canonicalize_file() to simplify virFileAbsPath() Date: Mon, 31 May 2021 09:48:24 +0800 Message-Id: <20210531014824.923662-4-lukedyue@gmail.com> In-Reply-To: <20210531014824.923662-1-lukedyue@gmail.com> References: <20210531014824.923662-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Though the comment says that the function may return -1 on error, but it seems that now it will never return -1 now. So just use g_canonicalize_file= () to simplify the implementation. Signed-off-by: Luke Yue --- src/util/virfile.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 0d1c2ba518..bfff471194 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3126,13 +3126,7 @@ virFileOpenTty(int *ttyprimary G_GNUC_UNUSED, int virFileAbsPath(const char *path, char **abspath) { - if (g_path_is_absolute(path)) { - *abspath =3D g_strdup(path); - } else { - g_autofree char *buf =3D g_get_current_dir(); - - *abspath =3D g_build_filename(buf, path, NULL); - } + *abspath =3D g_canonicalize_filename(path, NULL); =20 return 0; } --=20 2.31.1