From patchwork Wed Nov 14 16:02:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 997807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::438; helo=mail-wr1-x438.google.com; envelope-from=swupdate+bncbcxploxj6ikrbfeowhpqkgqesst3h4i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="QXAMTAaj"; dkim-atps=neutral Received: from mail-wr1-x438.google.com (mail-wr1-x438.google.com [IPv6:2a00:1450:4864:20::438]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42w8Qc4CGJz9s3C for ; Thu, 15 Nov 2018 03:02:31 +1100 (AEDT) Received: by mail-wr1-x438.google.com with SMTP id w16sf2985211wrk.10 for ; Wed, 14 Nov 2018 08:02:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1542211349; cv=pass; d=google.com; s=arc-20160816; b=HFVaydWAktypcbUvNk5CJB2pQnWgZ5hoXndAVwHV/MM18bKVi9gQdZi3YbUfASMa1a yC4+94bSuPr5kF7FP43IKxpnGAkQg+kWyoa1fWnJPDv/zfd2tWoC8L84qupTJBD6afFj wRn80/QZHPRXmlrS/pHG5xYRjmYTGo/kYb0GZFB5arUj0C7XBOKMcj8ii5qm7G1QsmUw kkJR/V9QUV1DVzN9q1AB2l++oDhvQzd848LT4dlrLopkPy01Wy/qF1m1ot75tfNR9gf9 Tyf1NxJsXR3+xJ5XY2tlqDNyM8ilw5jn5U0Y93A6FUVdz+xa3HHqKqY4nzamrBZtzqmi 5m7g== 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:references:in-reply-to:message-id :date:subject:cc:to:from:mime-version:sender:dkim-signature; bh=vHKls4XSrQQfAgwmRoV7iCP69dpVMvulgJnXwhPhlHU=; b=SumrkCtPAwheZdRKPfeQA6RZO9ihu6XMaVEWh0MCBVVVzqwV1YaJpB6j4g9lIcvs68 24gBbar/QwtyJ0eONwR/TY4o8ukzdJzluFICbM3OaSwR1SATG3R3uHq5jcOrM6DL/ZxR s1eNkZOHG37QJUCcmpT+3O6WMInyYGJ+6+POriCGAHH7l6UFumjwtBDjhUe7lQnrauyx dUdmt8NS205eBQkjtmjZwZhImfafTfQ4C8+juUpitxrojZWsAssboUxuZByLO/OXKVOj Jykewbcn/aEmI+jXcN2KMJuJ9C3Jn1jjD2srVl3ZF/peHi3Sv/yl+1qarVMEmR07wMqZ Kzgw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=vHKls4XSrQQfAgwmRoV7iCP69dpVMvulgJnXwhPhlHU=; b=QXAMTAajO5yYv8/G32BX0DnrArXA1nPZMDKYrqOX/3fOdtOWucOE8uQ4Z3UnBtH+9o qXR8v+q2woMEnjc5HrPQyt5x/8FdUb6mT+FO+9si3axgfGhE9hcnTuOh5zvVbVJXSP3E EaPwHRj0sCy1Kiu6FPFS+Tn0Q3sqbj4J5ZluPG3IpFUW/6gJju+0Udmq1/GKksfJyMZ2 bg9MW9U2rFId7+YbcK6j3K9yryz6HIf7Ias5hoRFndLwQIpXHxhm30l4yw7kNo+lXwLb aSjvgdkRGD2ur/pumybUBHcviG0qgJaO5mXR80UuhoIH3sXZKdkesdOqUXMWZ8nPvzR1 Cpug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references: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=vHKls4XSrQQfAgwmRoV7iCP69dpVMvulgJnXwhPhlHU=; b=CIJzbowGX/NRbbSmDbSGG2/GFz0NKxcbSfmrayRXnNvwZLaaWCZIKV5Ijzy+h0NEgo 7XRDCKA/EPsF3tOFQkhOVzYRNoQ3B5zMtkBH7QSTm7yd6DQH1vPIjeLyQyrardXFtl3a 86KBaBWtZYIrJebcpDtNXhs2cDEnvMEA5Fsz2D0d/y33twjTSTBfDZUh1Rc69GfWEk/D O/9lgxeIQs8tetqHgslmfttZlk7Y1shwqtoOZHXpgSdvGZ1tND+pQMCx7K5/mrhHfwhY vxXaN6A+znDmIeR8IYW+Vue00FgW6atVSnxTgnQ6WfGeriEPcDCtWKwAbJVYJ1T80/qM OGXA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AGRZ1gJarvybu9G2TWHRvbiIa4K4j0YOhbXf7vOaTp98Pfwixt52Q/BP wwITNEO/G5wb8PC/9FN3B9k= X-Google-Smtp-Source: AJdET5ct45qYk+U2hIe/Jxr+yHDveJjFsNVZT8pEbaTAwjEyCuuKlT0bkhjqE4iZtK3ZmK3IF3l6iw== X-Received: by 2002:a1c:5d8c:: with SMTP id r134-v6mr14001wmb.3.1542211348979; Wed, 14 Nov 2018 08:02:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:5d43:: with SMTP id r64-v6ls76434wmb.26.gmail; Wed, 14 Nov 2018 08:02:28 -0800 (PST) X-Received: by 2002:a1c:85c7:: with SMTP id h190mr357044wmd.13.1542211348458; Wed, 14 Nov 2018 08:02:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542211348; cv=none; d=google.com; s=arc-20160816; b=blbniRQIUChHWN5sZS3Z45U6Aw8VTu2OkmwkSyZ4FqAEabK6cFePJj9JbQpOmt8dIv mGfZHMJ0r82nj5B6zQAAcAIDLqi0qT1eQIvzUiZoRVXbUeiJ/WPTCh59NVBEutZoh31R Xy9SOByUdfTG5oUmIkxHq6qER1SgoYb/4ct1XzHaQyXSyypBJUcYHndhm2F53BjTpib8 ukmpuVbFPfW1iQlPMxHNpooUMvEpYHVPlEuLagRjvUChqgoPABMOOaM+M/QVu8RvocgY TnhCsmskuJNeDJHGZgk9oNBhRf0GEhdCdlrzKOuLMcR5rb5sfyBgwN49+Ejkpu5FXIkc MSow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=AsIn1uIrykUWWQxyjhp3dLOiKdz+wYPn5OGcALSBHeI=; b=lnq9kRgA6DXzi65l9mfmtcqMrG88yWjrlXhNKzgv0D/D/40juoFlPD0LY+/F24mZAW liQCrMlOHXKdZJ3/aJi6Mr+lWBP8SaMvX+fpOaS55/JcBvoScdHLM9SHUszWdT3J3rq9 ccCG3aYcf2wQvuCBOuOu2KqD1WRCw31+dgdWz9HqKI+YfYM2qtMcfrY+F4g+9LgQnF5p PrNUrDe2Ccwx0idDSNDOvdNXxQ61ZXvbTDJk6sAy6yEbVa1X2Vorb9/bc547A8OKr4nA pfNOb5FTdMqv6gJG15lOaEF/WZx9yC0xOIVHTxEqV3rGAGHEJEj3YtyAtM+X6OcmyUMD fd0A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id p15si249640wrm.5.2018.11.14.08.02.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 08:02:28 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42w8QX1rp1z1r01b; Wed, 14 Nov 2018 17:02:28 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42w8QX1fphz1qsJM; Wed, 14 Nov 2018 17:02:28 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ZFdB5B_TQ_30; Wed, 14 Nov 2018 17:02:27 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Wed, 14 Nov 2018 17:02:27 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 2B0F74540038; Wed, 14 Nov 2018 17:02:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FbhZRTozwNlU; Wed, 14 Nov 2018 17:02:23 +0100 (CET) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id A42214540471; Wed, 14 Nov 2018 17:02:23 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH v2 1/5] Factorize function to count elements in array of strings Date: Wed, 14 Nov 2018 17:02:17 +0100 Message-Id: <20181114160221.18242-2-sbabic@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114160221.18242-1-sbabic@denx.de> References: <20181114160221.18242-1-sbabic@denx.de> X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: Stefano Babic --- Changes in v2: - Use "ref" attribute to set a link - Use separators to identify part of link - Explicitely set links instead of implicitely set via strings. - Allow to link any attribute in sw-description not just the root node. - Several cleanup - Note: this is quite a complete new version, most code from V1 was rewritten core/util.c | 16 ++++++++++++++++ include/util.h | 1 + 2 files changed, 17 insertions(+) diff --git a/core/util.c b/core/util.c index 15d38b7..a357ea3 100644 --- a/core/util.c +++ b/core/util.c @@ -481,6 +481,22 @@ char** string_split(const char* in, const char d) return result; } +/* + * Count number of elements in an array of strings + * Last item must have a NULL terminator + */ +unsigned int count_string_array(const char **nodes) +{ + const char **iter = nodes; + int count = 0; + + while (*iter != NULL) { + iter++; + count++; + } + return count; +} + unsigned long long ustrtoull(const char *cp, unsigned int base) { errno = 0; diff --git a/include/util.h b/include/util.h index 06f4a83..0a95967 100644 --- a/include/util.h +++ b/include/util.h @@ -179,6 +179,7 @@ void get_sw_versions(char *cfgfname, struct swupdate_cfg *sw); __u64 version_to_number(const char *version_string); int check_hw_compatibility(struct swupdate_cfg *cfg); int count_elem_list(struct imglist *list); +unsigned int count_string_array(const char **nodes); /* Decryption key functions */ int load_decryption_key(char *fname);