From patchwork Thu Oct 14 06:18:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1540781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=XsysFE1K; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::838; helo=mail-qt1-x838.google.com; envelope-from=swupdate+bncbcwivbv7sugrbl4xt6fqmgqeo3wz2mi@googlegroups.com; receiver=) Received: from mail-qt1-x838.google.com (mail-qt1-x838.google.com [IPv6:2607:f8b0:4864:20::838]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HVK3B12k9z9sXS for ; Thu, 14 Oct 2021 17:18:28 +1100 (AEDT) Received: by mail-qt1-x838.google.com with SMTP id t15-20020ac8588f000000b002a777ee14d0sf3816687qta.14 for ; Wed, 13 Oct 2021 23:18:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634192303; cv=pass; d=google.com; s=arc-20160816; b=hgAtRRMT3V1Opg0XFAGPDlGMX737ZGqBuDnser6vK8VSJMeMgTHuJorUrr0HKscvAz BO1RHEDChx+wyk6NLrp/Q3GHJb0Azz4mF6Dkilc1M1iBv7QKsoJpdKA4QLh9vMJQ63/e KF2ZbdLbdEoxWpPSKAzZ+idK+5A5YiPSsVQevPcijAPjOQvBU9sArMToYaBNSEhxXjGy OAHkvStuZvpWduYLQmKecQiOSqxoE+LQl17MqZ4hBNL/tD/IYdZqaoxIOJ4aV5hm3TRz CsUqDaWQ6fQWZQ7qnRHH3cjlkrf/UMSJ4d7HxLULANPpRNcfOLNLNUWSILO5EuFRYXSG cgPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=oTJxJ2lMPIKkHVYKUwp+x7CRopvtdwrvNp7f9mhGPDI=; b=chybPZZhMVbpwb5y5xOvnCe3/kAZF40aGeuNri9L8JnCbMlb9wAxy6L6jgKCSAg4rB mmkxOM1E43cB9fHfKaZJ+TIxzxb+jhEGOySlU8LgyGDVj4n5dhLjAYi8A+9ciUbXJyDZ hXCKNC7n/Vy7ey0PjvvbkoNFro4f1M5WSvJ980MEsBx6JvSj4QpGcoz56g8w9AZZ0UdR Ui0o8aall4W7M8pDPxkVw4Yvs9ZdFfktzCRK3wHAQ220HVhW4sGIInDWxG14bZMZ3tm5 WdufleSua1HjQPIYl7Q9aj+lXexwmxGtknp+4yXigZPanBAtz5h0Eb1ZKLgY31gns8zM KTOA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=oTJxJ2lMPIKkHVYKUwp+x7CRopvtdwrvNp7f9mhGPDI=; b=XsysFE1Kf8DfzyadCe7qOV/s9FDsty5oYXFKPFdGLTSCAqqPPtO0IxmLgHxTJVtLw0 iUY9WAbMiYeR/5sPQtaPhkOLiqEWndCA8N6MvZcte9a6u1V3TwyWvspPgtcLduRyPmol GuzbHq7TVfYnpj84v2v14HzSzNgh0EnlhwrOMTGR7FLEN83c1wBNnrsA2hV8gdqYIxS8 ECSUCbdgirpXpm85LO+58A2+WvXzoJjViMe86Q/UAGAR7r4IEl08P/pQ/1wBvwIrxWVI +jBjSPAwe69I6X1c6lZbZjgJqLdVg4EbTpcomx0tjdU1lVG43Oaor7Mt32GuckFY6Ym1 qWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=oTJxJ2lMPIKkHVYKUwp+x7CRopvtdwrvNp7f9mhGPDI=; b=aXW2/U1aAO5a38WeqzH7Kvn4pM346p3Yy+xNi7Wt5K1JZeIHzJJlAdK2RzqrbqfUrQ Mo/QJBSJplgSxmikutgAKSXEZKsrygu2SXkRuxqsCRiytZOhThiLaNYhPkUxNXf/PmMH Ubsel44xbD9Q3hEFTYfwDH6j7SRupA1AmVTK5mV1auB7BPOL+ab0kc8jhyRmQizn0vOg mIOMClM6w4+ktwB+1ZlQEmwKBsEGx6CG27rD2HwkqkG9sNbbE9StEwPTjsGjhpLDngJX arcVcNmImXsqpe/MwvVOfaVRIbuF16grKIGUhOPDUu5b65EShmTyftRT+Qc2FRZVgcNe 0E6w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533Cchl5kjepOyCgDXFzTzMhZhfJNKzIoAapRQCH0ZJZ5KIfwwQr n3Lhv+W3mD9pnN7h7Af7rRs= X-Google-Smtp-Source: ABdhPJyNvk1CyFamGEwxvY3HXrIFi7sWxoO+5E7oLyOpDsNIrOF9s88yMwQXizyznLhkTV6qbgXGmQ== X-Received: by 2002:a37:a2c1:: with SMTP id l184mr3100143qke.71.1634192303307; Wed, 13 Oct 2021 23:18:23 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aed:27d8:: with SMTP id m24ls653408qtg.6.gmail; Wed, 13 Oct 2021 23:18:22 -0700 (PDT) X-Received: by 2002:a05:622a:13cc:: with SMTP id p12mr4390495qtk.255.1634192302742; Wed, 13 Oct 2021 23:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634192302; cv=none; d=google.com; s=arc-20160816; b=wlvKKRVIUavFAgn13x6JU8jducl5YrtFHDTwvA206fCAqsVKag5n7n1BlFSKyO2Y4w qRnkxrb0tA97oDf8om5dFYZLX/ezKSHeiHDUkPUhrHCIyQzb4on4z/Vutk2lA48reR1I f3GNLxZwSuEr9tYk7gYBJIuOy2U7gwlkylySzRkhu5lpxNer0CjdfZ7MN9ZOJ0R46SvH ogKJfMZydpONvJWdY8vauqR2txYqOOtbzkuxfjVDNvNVQxNhxclhnyuFoQE9F/+Kk3/H P5zF1qwOLuRxXe8xVgSh477GKD7dvOCoX7l2HTtbkaHzrWZIzQiq9KHn9E8x14Orj9rV tYZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=U011uOVGwznpxKOrtYRwlgT+Vj2T4sMXLuYEyK4l4mw=; b=mANWy9c7mryDnWC5LHyrwtReZs3FBR0iRKbPuq/MDfBKps0HAUMzAHM7zIVtcnoQ+k D8edKqD5k+F4JVTm/7H42tAGF6VSqUWXOmQlxGiWgFp7TrXYPW5xsMjwm8ZgB6jlPLnh LshkQ9Z7QWbPHkqPUH3rYJl+c2wLy3LXbQE/0V1TKuqd3h34FRH86xDgGTnbDhxtqDu1 qIkJdl78U6j2GCFNlfwsfSZ+ZFuf9sBg+tQ1O4TBOho+ANF0YtqegvgZmmIoFlxlfFBS KkEbOs0HnKXMf38zb8C5kAA2F7NMlHcZztDiV91f+UeEyBtHk3qOq7vu/1ThHiCWEPL9 0Z3g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id k16si175682qkg.7.2021.10.13.23.18.22 for ; Wed, 13 Oct 2021 23:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 6884520D3C for ; Thu, 14 Oct 2021 15:18:20 +0900 (JST) Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 53E1D20D3B for ; Thu, 14 Oct 2021 15:18:20 +0900 (JST) Received: by mail-pl1-f199.google.com with SMTP id p17-20020a170902ead100b0013f7d398f40so518490pld.18 for ; Wed, 13 Oct 2021 23:18:20 -0700 (PDT) X-Received: by 2002:a63:b34e:: with SMTP id x14mr2773296pgt.423.1634192299313; Wed, 13 Oct 2021 23:18:19 -0700 (PDT) X-Received: by 2002:a63:b34e:: with SMTP id x14mr2773288pgt.423.1634192298977; Wed, 13 Oct 2021 23:18:18 -0700 (PDT) Received: from pc-0115 (145.82.198.104.bc.googleusercontent.com. [104.198.82.145]) by smtp.gmail.com with ESMTPSA id c27sm1385182pgb.89.2021.10.13.23.18.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 23:18:18 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1mau4H-008QmX-AP; Thu, 14 Oct 2021 15:18:17 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH] core/artifacts_version: compare oldstyle versions directly Date: Thu, 14 Oct 2021 15:18:15 +0900 Message-Id: <20211014061815.2009528-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , version_to_number() has a number of issues: - versions with more than 4 elements had their trailing part ignored (e.g. '1.2.3.4', '1.2.3.4.5', '1.2.3.4.12' are all equal) - version token bigger than 65535 were truncated down to 0xffff (e.g. '1.65536' and '1.0' are equal. '65536' is smaller than '10') workaround the issue by not converting to an intermediate u64. This still fails to handle versions bigger than ULONG_MAX but at least prints a TRACE if that case happens. Signed-off-by: Dominique Martinet --- core/artifacts_versions.c | 73 ++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/core/artifacts_versions.c b/core/artifacts_versions.c index 433125862014..eb605bc403f1 100644 --- a/core/artifacts_versions.c +++ b/core/artifacts_versions.c @@ -161,39 +161,52 @@ static bool is_oldstyle_version(const char* version_string) } /* - * convert a version string into a number - * version string is in the format: + * compare version strings in the following format: * * major.minor.revision.buildinfo * - * but they do not need to have all fields. - * Also major.minor or major.minor.revision are allowed - * The conversion generates a 64 bit value that can be compared + * they do not need to have all fields. */ -static __u64 version_to_number(const char *version_string) +static int compare_oldstyle_version(const char *left_version, + const char *right_version) { - char **versions = NULL; - char **ver; - unsigned int count = 0; - __u64 version = 0; + char **left_versions = NULL, **right_versions = NULL; + size_t i; + int compare; - versions = string_split(version_string, '.'); - for (ver = versions; *ver != NULL; ver++, count ++) { - if (count < 4) { - unsigned long int fld = strtoul(*ver, NULL, 10); - /* check for return of strtoul, mandatory */ - if (fld != ULONG_MAX) { - fld &= 0xffff; - version = (version << 16) | fld; - } + left_versions = string_split(left_version, '.'); + right_versions = string_split(right_version, '.'); + for (i = 0; left_versions[i] != NULL && right_versions[i] != NULL; i++) { + unsigned long int left_ver = strtoul(left_versions[i], NULL, 10); + unsigned long int right_ver = strtoul(right_versions[i], NULL, 10); + if (left_ver == ULONG_MAX) + TRACE("version overflow: %s\n", left_versions[i]); + if (right_ver == ULONG_MAX) + TRACE("version overflow: %s\n", right_versions[i]); + + if (left_ver < right_ver) { + compare = -1; + goto out; + } else if (left_ver > right_ver) { + compare = 1; + goto out; } - free(*ver); } - if ((count < 4) && (count > 0)) - version <<= 16 * (4 - count); - free(versions); + if (left_versions[i] != NULL) + compare = 1; + else if (right_versions[i] != NULL) + compare = -1; + else + compare = 0; +out: + for (i = 0; left_versions[i] != NULL; i++) + free(left_versions[i]); + free(left_versions); + for (i = 0; right_versions[i] != NULL; i++) + free(right_versions[i]); + free(right_versions); - return version; + return compare; } /* @@ -211,18 +224,8 @@ int compare_versions(const char* left_version, const char* right_version) { if (is_oldstyle_version(left_version) && is_oldstyle_version(right_version)) { - __u64 left_u64 = version_to_number(left_version); - __u64 right_u64 = version_to_number(right_version); - DEBUG("Comparing old-style versions '%s' <-> '%s'", left_version, right_version); - TRACE("Parsed: '%llu' <-> '%llu'", left_u64, right_u64); - - if (left_u64 < right_u64) - return -1; - else if (left_u64 > right_u64) - return 1; - else - return 0; + return compare_oldstyle_version(left_version, right_version); } else { From patchwork Fri Oct 15 04:18:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1541290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=DQIuFJua; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::23d; helo=mail-oi1-x23d.google.com; envelope-from=swupdate+bncbcwivbv7sugrbm4cusfqmgqeiuh7mwa@googlegroups.com; receiver=) Received: from mail-oi1-x23d.google.com (mail-oi1-x23d.google.com [IPv6:2607:f8b0:4864:20::23d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HVtLx5tJmz9t0k for ; Fri, 15 Oct 2021 15:19:04 +1100 (AEDT) Received: by mail-oi1-x23d.google.com with SMTP id w26-20020a056808019a00b00298e7b4523csf3256419oic.9 for ; Thu, 14 Oct 2021 21:19:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634271539; cv=pass; d=google.com; s=arc-20160816; b=qkHx27VnsKxTDzs+uCksytM9XGJcFk171UBoiPA7LQhDbCujWWjD2IQIl6wbCuDGYw zw02I/MJ+ctqnA+DgyZwYLp7rrVG4gsbfBgr86JRMs043p0Cq3uMkJV1+Cb+kLykcwJu KvgBipU05WKWNc/mKGdKE2bzbrpJTewVR/C973iKoBuWl1p8yzs53rys08i0HEVk92Tl b87zBpEuOkJ3nSzHBX1tYhQRD28LK56zNDDSaw4mR0VpLfvjeUtNLpxC7VqodVmd6Saj 4oB4ZgZUAJnqpONf345RSqSkBwwOld3+8DuZiJOLhvXT0moxKLfybpLgt4SRaKCW5H1e EEQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=xn1cCGvddJgeJ62KkSLUoNz0rsr6z+fsga/vwA5eppg=; b=mJEzz0h3/lu+Ur0MK7MhC0Lp7iHmZY0Alj+9OaA0iFGj+yJXGSzI1bosN0dDvEaM3h Ss1cq64PmT8yuf2OKrxCiZZ/UGKONx0q7zfIyx/+6VvhWzT8xFMIX/4LK5AoNSz+kmBa sR+nWi5o76/Q5Pu2tdpu9idspkHTu6eOLRT0PO8UboUQt+1RkkYYvRh6fhPxuE2JP09e dcfxgkPj0o1CB8Ji7eraClUSSDyP+2wlgq1lZHcfmRnaT3HcNDjHscrrl7fS5Nr83VRN s6QKQyDiVWpWQ3MndehiyaGjdPw6dM8ISFTKLx8V081Sj2idHf5JCxqYieBBOOwVsF4N 3G0Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=xn1cCGvddJgeJ62KkSLUoNz0rsr6z+fsga/vwA5eppg=; b=DQIuFJua/Bo4AsuBz7TKf24Ty8Te3H+aveLoACahZk3QbJ699FnHzS5YpaoTOMjKUv akVRXAC5CVI+hzyyslnC5nikJv80AfLARO75WQISr4M3mwHuZDq+9S9pO5Fd6+UraF60 YE9eiJltLjDMmiik+QkhT7vyDZT/NR8Yf6PAYW3s9LIMwGj8XH9pqTLwTkceB+LLxB3x DXhH1lrZijkQxNxGSMFEOLPRlHCnnAiVUWuHuM+IR+1gP9D7TCJ7pusNHizzArbaVpRj HAFMkUffojHLHIbKxZmjKz6TzhJDd5l+tcLjirI7XamQP2q99vjslVvXdOFhe2pz8Cee AJBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=xn1cCGvddJgeJ62KkSLUoNz0rsr6z+fsga/vwA5eppg=; b=6j+yx9/+9OHf5F9cmVcaOU4HY0Lx9NzD325HzDCYva8cCfIG1ZqzwvmUjS/k1p21r8 1K17oHQcwLfdAfi9DGBf7xG27Y/guVt/WTYbm59A+lLsF/IVmkpIL+DP4fbKvmywOKBw aFSErf37s9NrmEFgOhdGdcN02r2J9eyHEO8dQejK09KLIZ52QQehU/3i761BBQ+vMk10 Fz5B2DM+/RW/VlrU18jOOc14R5x+b+ilC4TLMKAktisa0phmhR7CKQ+wYy/VsXxBAojQ x1NvaBZ9StBZMxbN4YqxZRi3r0ZEiM9O8ojxNOv2qZqIN6kVv/94lYp2Qf1FFw7b/4/G C07Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532enDGrfpjoRNazDsQHZiJa1fnXEkB0kM1PQxPQzOeg55co+ntY cnZykM/04Kg1tNQxbpID2pA= X-Google-Smtp-Source: ABdhPJxJYS4tptxXSF4lJ7uYpAcUJkrUMUB/qxAB11hKtXB9j9wTqlrYoU0R8HzhGJ3EeRoc1U93EQ== X-Received: by 2002:a9d:6088:: with SMTP id m8mr6236050otj.214.1634271539626; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aca:2812:: with SMTP id 18ls1163185oix.6.gmail; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) X-Received: by 2002:aca:ba41:: with SMTP id k62mr8769631oif.53.1634271539218; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634271539; cv=none; d=google.com; s=arc-20160816; b=m052oYbn56Yk1/XiQYhtI2iznJ6wroIVPe0IL2/bZN0MhJCW5Zg5W8mvYkYbT+JljP KGlXLjC8cRfCgyR32BWnaz0uy69iPOucsBEsW8uXd/8U2WXVkkR9yVUr93hkATAo2OzF gOLKwG7IPMx/6ztC4trMjph+TvF/CqSjAwjLfK1B295eYiQ+9HIc67BKWV7/O+NIDSVN UBzYjYqBP4gAKFxqdfP/bFAJ1DH/voE3QovSy4a/4JCmHUGVyCZKZ4+2B5NM54BdcKNQ St4YCdAnn4C6G194BM5myBw2oeuykdlDfRUUPCcS2UWWadLEYOZk9cdxxKm7nlkppt4k UFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=RYapcFfBFNOPjwnLs6aKUKfX40zQ2j1kZzxvzOL/9Ss=; b=oop8DWsA1NX08AAEI/PXOxiGDG+ij/LU0Kst2ZaR9s/M2ZAfVgT8KkZk6Tv5EN1DS7 c0CfyvYN9oZzMH/0Au4qxeBpJA9EPbyR+kENCDoXx6DJNPh5oYLB2R9e8ZPM+ZK+TQ5F dwQIMi6SG9XS/ea84P6jmpV1fhX363Evhh7yPKADjauVmxZTUfzC9XohFphQKvqM/Tld F/Yl3lWDxS/onZ4x/3DAt7FCK7ulCZ31fQoxN1Lf8lPPcJzWJtPomdNy0dCSmR0lqq6X wEZocT2x3297kXQU60KYdrv636/DhQU6+AwBjL1PHKbhTMDNrzXItNNc8QjuMWITrnBJ zEwQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id q20si314193oot.2.2021.10.14.21.18.58 for ; Thu, 14 Oct 2021 21:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 52FA220D3D for ; Fri, 15 Oct 2021 13:18:57 +0900 (JST) Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 319E620D3D for ; Fri, 15 Oct 2021 13:18:57 +0900 (JST) Received: by mail-pj1-f71.google.com with SMTP id pg13-20020a17090b1e0d00b001a094e26d51so4692477pjb.0 for ; Thu, 14 Oct 2021 21:18:57 -0700 (PDT) X-Received: by 2002:a63:5956:: with SMTP id j22mr7302015pgm.58.1634271536182; Thu, 14 Oct 2021 21:18:56 -0700 (PDT) X-Received: by 2002:a63:5956:: with SMTP id j22mr7302004pgm.58.1634271535984; Thu, 14 Oct 2021 21:18:55 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id u3sm3752071pfl.155.2021.10.14.21.18.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Oct 2021 21:18:55 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1mbEgI-008uI2-6l; Fri, 15 Oct 2021 13:18:54 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 2/3] compare_versions: remove useless else statement Date: Fri, 15 Oct 2021 13:18:50 +0900 Message-Id: <20211015041851.2122952-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211015041851.2122952-1-dominique.martinet@atmark-techno.com> References: <20211014061815.2009528-1-dominique.martinet@atmark-techno.com> <20211015041851.2122952-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The if branch would always return so else is useless. No code change apart from reindentation Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- core/artifacts_versions.c | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/core/artifacts_versions.c b/core/artifacts_versions.c index 14abdb420498..e8dac70c45e0 100644 --- a/core/artifacts_versions.c +++ b/core/artifacts_versions.c @@ -235,41 +235,39 @@ int compare_versions(const char* left_version, const char* right_version) else return 0; } - else - { - semver_t left_sem = {}; - semver_t right_sem = {}; - int comparison; - /* - * Check if semantic version is possible - */ - if (!semver_parse(left_version, &left_sem) && !semver_parse(right_version, &right_sem)) { - DEBUG("Comparing semantic versions '%s' <-> '%s'", left_version, right_version); - if (loglevel >= TRACELEVEL) - { - char left_rendered[SWUPDATE_GENERAL_STRING_SIZE]; - char right_rendered[SWUPDATE_GENERAL_STRING_SIZE]; + semver_t left_sem = {}; + semver_t right_sem = {}; + int comparison; - left_rendered[0] = right_rendered[0] = '\0'; + /* + * Check if semantic version is possible + */ + if (!semver_parse(left_version, &left_sem) && !semver_parse(right_version, &right_sem)) { + DEBUG("Comparing semantic versions '%s' <-> '%s'", left_version, right_version); + if (loglevel >= TRACELEVEL) + { + char left_rendered[SWUPDATE_GENERAL_STRING_SIZE]; + char right_rendered[SWUPDATE_GENERAL_STRING_SIZE]; - semver_render(&left_sem, left_rendered); - semver_render(&right_sem, right_rendered); - TRACE("Parsed: '%s' <-> '%s'", left_rendered, right_rendered); - } + left_rendered[0] = right_rendered[0] = '\0'; - comparison = semver_compare(left_sem, right_sem); - semver_free(&left_sem); - semver_free(&right_sem); - return comparison; + semver_render(&left_sem, left_rendered); + semver_render(&right_sem, right_rendered); + TRACE("Parsed: '%s' <-> '%s'", left_rendered, right_rendered); } + + comparison = semver_compare(left_sem, right_sem); semver_free(&left_sem); semver_free(&right_sem); - - /* - * Last attempt: just compare the two strings - */ - DEBUG("Comparing lexicographically '%s' <-> '%s'", left_version, right_version); - return strcmp(left_version, right_version); + return comparison; } + semver_free(&left_sem); + semver_free(&right_sem); + + /* + * Last attempt: just compare the two strings + */ + DEBUG("Comparing lexicographically '%s' <-> '%s'", left_version, right_version); + return strcmp(left_version, right_version); } From patchwork Fri Oct 15 04:18:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1541291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=MN8uSGcY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::338; helo=mail-ot1-x338.google.com; envelope-from=swupdate+bncbcwivbv7sugrbnecusfqmgqeuamrg7i@googlegroups.com; receiver=) Received: from mail-ot1-x338.google.com (mail-ot1-x338.google.com [IPv6:2607:f8b0:4864:20::338]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HVtLx4dyyz9t0T for ; Fri, 15 Oct 2021 15:19:04 +1100 (AEDT) Received: by mail-ot1-x338.google.com with SMTP id e34-20020a9d01a5000000b0054e38dba068sf4978713ote.1 for ; Thu, 14 Oct 2021 21:19:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634271540; cv=pass; d=google.com; s=arc-20160816; b=ZRLoJSLaVEJ6iIrwjQ/mdHlLqgH0J63zAVLF/kKr84dg7/eC8901Hd8kwumzTcU47R jSdGhfTcbZ25PQ3bPQ1tmBE12bogbSCByTgfo6B6H/a4jV6F2W8rAqN7xMMMPZapNBNM nI0gj4szvAhHxwzf+aHHZYluUXmuXgxn093eVuPL8AYtkiAfOYlf9M3z9LYuVJONW5MA ecP+UnLTMm1saDQ72c3WQO3Onflt7Xt5eMlOgL7qm5/RxnA0gu+Rj0e9BusZBDZ7H2X+ 9JBjwalkMGaVBvzXuT9WcG25gL9nkx4to104MGzd5wTbTJfdZ2EkaZr5Po6K6UAaPyo/ WEVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=/sgOZMf6KDw6cE5QzrXq+WWc3d0bx/T7pY6aWycC0AQ=; b=w8NAFJetcffmqgCtf66Y+3DaKzglCqu2s5MmdMV1ZVRXilzhwBYpBW8hefa1nJUvYs yQdrXu/saZT+y3SpC1PiznNWH09+ysBqNtM43KR4jcwesOanLpeLXTwhtaZZ17PIdta3 s79ppkk7CQPoMiUXA+ATYJMmM6YoATR41gP2Mtx+4pj0F9UbbGevUFEaO3BVNvyD/Ojc c2lNMFkjmGMJMtq1PpyHBjf0c0BPDsOlUGAIBsS8pn1/Ml2BCrowWynqHeuIgudeW4yS qf47ILk57lgZyVBizJanaQ8Dbt6/QC0g5sVXa+n3WaotvTXhATCm/yjnf2dn35pdZ/1t GJjQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=/sgOZMf6KDw6cE5QzrXq+WWc3d0bx/T7pY6aWycC0AQ=; b=MN8uSGcY7F5tRVbED6R68dfeVSUNBqkE0e4PkUK8zfJB6LZCNiSBt7NwfyhtH3ry// zIcJ5/Em4VBj7uhcsKu1+pbCKagiDiYjXWbRgtjyJe00zFjxuL11eluv2xvSzXozlGkX h2JPa5I1Hrn29nFHdSS6FCv88YCTnlhOAkMqy1H+2I5oxhur4LS7g5Yg0Wa2ipNgWkgB KlkchKWIII787VOmBO60VxqO9/AtwkUddcAEjosBCCJPQTCNk/oU58f4yflQZvCaL/kH dRb6K5nyDhZws8CxDnAq3bl1StZitKLOrzUSRjlla3vnPTqSfZHAM48/V2gDPRC3u4Pz dkww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=/sgOZMf6KDw6cE5QzrXq+WWc3d0bx/T7pY6aWycC0AQ=; b=s2DcoYBgQCE00ywUab1KeVWyAJ8WIXDPSqG0j9XP+JzFW0+FzGgGpXEo37Tww1IM6o ZdgxC/zwccQBFEdSHFUhP9mKgmIM35uWl02XPf+Yjh4/Rp8uPKWmZ/5TZH+p43aMOCvn cOksIfNZPK6M55YX6TpgWe1RQl3PVeHZEwGzuIjCRxGMSN7PmcpiTOLe9SkL2OfmTsQn Rp9rf/1lWPpm50yKwfuCFw/Q3ggGar4DqQNNc3DSXbOaAkKCAwhVKr+e28Tl/KnUiJFZ nmga0V9OYU1oRcKirkM5OD3bbMth0glO8BamZNIdOVZ41WX90NefQ8vI0bpuAn6JM9tV AGrw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530bzija+k7E9NsxkYfx1/vyL7tC2XZh6nzJIhOfjE03Ebr0X15M W/4xoOOJNBh9iBvTilK1GWo= X-Google-Smtp-Source: ABdhPJw5Ei7/oXmh1Gh+05SmqbkzeM8n85hvSdQZu7J3/88zNbUUqcCFB4DLw5sV34MK6gxMKNbkqA== X-Received: by 2002:a05:6830:1514:: with SMTP id k20mr5953559otp.44.1634271540135; Thu, 14 Oct 2021 21:19:00 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a4a:d183:: with SMTP id j3ls566718oor.0.gmail; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) X-Received: by 2002:a4a:4ac5:: with SMTP id k188mr3697617oob.23.1634271539710; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634271539; cv=none; d=google.com; s=arc-20160816; b=RDbv7z4SFcrlcR8bmar4mbX3Zvyju49cErMGwSxboVjuvzRRR6lM4fNte9Wq12ZHrl T1uUhfA6+y0Ry91LEOqGjtb2UJF0xM9gjt1tT5yp/o+UcZOmRBczMH27eBsbJpWrD4U3 /3hojt9OPBcZEy5A33aA8WGHXjCUtb3C0OlLjDuKmAr4MJ7NmOq7Pc333GCYNurpmRo+ OkQDieyrlLHRLwlkDp79X+jlmcUlGfNNzfbcAsewY0Y86aq+EDzS/r5C2C6uKIidHaJ4 JesJDwJTV6XZMKpb6bo093Zl1YWjM4t7YASv32dQMtIp4Op9q2jKn0A9cmMDWzb5K7WC +62w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=RTFBt8xYrnRhU62IX16sPiCq/v1v2M242VycPwZ2s9Q=; b=vhTJHjIY+u7NGNk0k5r+FEuv7TL28oNc8HRIkqkOsAXD4V84tCmQigtQxmaiI8P0vY d7sIFxeXx2EtQ0sN6Nnx4zGS9TOG87N9hJqguHme9quNE8C5TmAm6RidxnGYBC5fgaUb B7giX/tlmeNgIgDhPC4g20QXFFhohBpQxWlI6UQxth5S++lesLHgS4C9duhomNIPHUaI TrgcC6WrX/OzV/OuPAZHWdcaF8NmY11Q5wsZbFUy6Z+ZDAklF+O3Xc7xT0KyvJEc/LzD nfDAKvAMc1Ckm0JLsxu8G6odm4ia5gfCzxnablh1bRWZHv3/eyNm+rZKfNBRkm7opK9b QwKw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id bi42si542548oib.4.2021.10.14.21.18.59 for ; Thu, 14 Oct 2021 21:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id C68F420D3B for ; Fri, 15 Oct 2021 13:18:57 +0900 (JST) Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by gw2.atmark-techno.com (Postfix) with ESMTPS id A464220D3F for ; Fri, 15 Oct 2021 13:18:57 +0900 (JST) Received: by mail-pf1-f200.google.com with SMTP id q10-20020a056a00084a00b0044c729ea8f2so4641072pfk.3 for ; Thu, 14 Oct 2021 21:18:57 -0700 (PDT) X-Received: by 2002:a17:903:246:b0:13f:75bb:cabd with SMTP id j6-20020a170903024600b0013f75bbcabdmr8961669plh.30.1634271536716; Thu, 14 Oct 2021 21:18:56 -0700 (PDT) X-Received: by 2002:a17:903:246:b0:13f:75bb:cabd with SMTP id j6-20020a170903024600b0013f75bbcabdmr8961656plh.30.1634271536487; Thu, 14 Oct 2021 21:18:56 -0700 (PDT) Received: from pc-0115 (126.88.200.35.bc.googleusercontent.com. [35.200.88.126]) by smtp.gmail.com with ESMTPSA id w17sm841966pge.84.2021.10.14.21.18.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Oct 2021 21:18:56 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1mbEgI-008uI5-QB; Fri, 15 Oct 2021 13:18:54 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 3/3] doc: specify valid version range in sw-description.rst Date: Fri, 15 Oct 2021 13:18:51 +0900 Message-Id: <20211015041851.2122952-3-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211015041851.2122952-1-dominique.martinet@atmark-techno.com> References: <20211014061815.2009528-1-dominique.martinet@atmark-techno.com> <20211015041851.2122952-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Dominique Martinet --- doc/source/sw-description.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index fd8bd11bdedd..6d6abc11f494 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -1089,7 +1089,8 @@ If it's false, the new software isn't installed. The goal is to avoid installing an older version of software. In this case, version can be any of 2 formats. Either the version consists -of *up to* 4 numbers separated by a dot, e.g. `...`, +of *up to* 4 numbers in the range 0..65535 separated by a dot, +e.g. `...`, or it is a `semantic version `_. ::