From patchwork Fri Jan 12 14:58:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 859992 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:400c:c0c::23e; helo=mail-wr0-x23e.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbj434pjakgqezepku7q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="fbUyrS6M"; dkim-atps=neutral Received: from mail-wr0-x23e.google.com (mail-wr0-x23e.google.com [IPv6:2a00:1450:400c:c0c::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zJ5Xp35bYz9sNw for ; Sat, 13 Jan 2018 02:00:58 +1100 (AEDT) Received: by mail-wr0-x23e.google.com with SMTP id y18sf392411wrh.12 for ; Fri, 12 Jan 2018 07:00:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1515769255; cv=pass; d=google.com; s=arc-20160816; b=bBFoeKik7yLa5Ei9EsfXuJPgQ98RNt9aBH6J0WXAJx25QXwNWhNJtbBiaxJ9dCZ0CP Gvn1ZvTBeZkA4insFj0axCVcAgmO+eiVvgf9G98lqcwHqmqnkMGR+BjjCOvnjsVoP37j El2GFqbhwEnFGQlxY0m7z9jghAXsKRaxroSA5epw26ZiggdHZre2k3YEqHPE1/TXPLJz nm8w4yGIzHO1qNTbjKqIfom6USp/5tgn7i7415iywUP9DrKmQw11KCRzAa6+cSTsjydC z0IMhX1qLX6LSmnY1sIirMIywUjI8BL8B5sBiYYCmkJoI/iaE3Iy5emN9Ajhi6jYmM/c jJ2Q== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=SR8FuTfHyqU1WYLv8sPP9c+UoBE++MPjM2+w47Ie5KM=; b=EY3TyfUPnN4CeDLT8jbejK2E+wJmUgNSCZOcBOhA4P5UVpV1jm9dN/Rssd7kYh4+dR jLE9KA0NsS5wNlmafDZEKZOpy5VNMzVWBPW1AHRACkUzXlskUoVnyQghkSUEP/ZZniw+ lHvDtGw/kOo8nAh8xjU0SQdplYU5+P4i0ZvCN9b7LLPYKLdc6r4BJCvBP5Q4PEbJNUDA ZLiv5V+YRTJnuTejtU1D+7paQRBRgrDkpDcPtvmS3NsaMZdYbx+xmeCLPsVJMD8zjICI WGnU6HcrwksXBk+L+AH6mKKoFTrzeW9pKDqOm86YhrxP9NmCX8rkIdMqb4RtwIHSy1/D PJNw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net 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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=SR8FuTfHyqU1WYLv8sPP9c+UoBE++MPjM2+w47Ie5KM=; b=fbUyrS6MGz8L2NjGHF9xV6pFjFlpEvNqzH+IULrfAHh0yjf5pm8sW5GzfpKHWSx4vE Tt7OXRGHFxhFUEeUlRA45FsvEhIilSbgBJ9QZ3dul+OtQ/iatTJvJfySJo63bu0vUhbQ e6z4NMuT3JcQwa85t4Z5GrWIvYQLgGHYey2p0W9mF+O9wnin9T66Nt96/qyd+qXZT6Lx HRNmh5KSeurZYOhJVshCxAcFvs4EmBOSvwY3nx7xgFnT0NHytiqZE2MxakGA4zKS2qwQ oHBiI28BpTIqHxoKlJkMf4uvTd+JN6s3k6/tnramIGrwozQejK2jRQxml4X3WtYqtoOY qDpw== 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: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=SR8FuTfHyqU1WYLv8sPP9c+UoBE++MPjM2+w47Ie5KM=; b=DN70MUPQewF6AvwrqRTVyC5sOWQdZp9iMqRrHbcVe9dPY54dHAaT/VvH8CjZKH7WRa dh4MulCuvORs4g03UcK2FNV3l6trpvVLQa3Sm9Qd8Yx/2SvjiITCg+bv2zkk7j/XUjdb LLDRE7yMk+t+Z5dnMnnMuK7Xw7Ix/t3zhTc5vLfDpDKODSKx3GJCEWhAnVb7SIlezUSq +m5pW8+gxt0eaAQGxZAHEq5tGrMvPHwk5xjjJcUOHsREcIBIkpybEs6QGgyQQFsyzsEF gob42KSOCt3OlHVz8OT+n2a3tTb4RCRyfMHz6VY/EZwXIQEVvDz0rTHuWqvkAB9FUHz6 CPcA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytcUyARRtkkx4KZ1ALS1TA/VrfebB/Hb/2aNfmqC2eT01efx2JkW glS/V1ZiTtgLJILCWkwYpls= X-Google-Smtp-Source: ACJfBovHlZybt09cE4gD+yAUI6caUv6MlklVaaEqIVwLTl1sNC3MgEgST5ronmIVkSCSQPQTk88XhA== X-Received: by 10.28.111.219 with SMTP id c88mr54378wmi.3.1515769255343; Fri, 12 Jan 2018 07:00:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.130.75 with SMTP id 69ls1137040wrb.8.gmail; Fri, 12 Jan 2018 07:00:54 -0800 (PST) X-Received: by 10.28.202.26 with SMTP id a26mr322023wmg.1.1515769254772; Fri, 12 Jan 2018 07:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515769254; cv=none; d=google.com; s=arc-20160816; b=ya+xLodlc0sb0nPCNccDxCN2TFJSBfAiC7iwkIoyIasdHJ5bHnEaEhbGV8UC8rjP5T 6HBfumOwt1Q0yU718P1CNNWTAmCV1X2oYS8W8VZw+bFLDGF98wsei0TOVkSkm8ch1FZm UroQ1hLzFmC4EffyKebt1hvOg2j5ZBMevhr8/q190IViaMh8ebH9/nt2gWLlV4CZdvHT pdEngsiL0vVj+zSm+dlNIeBh3q4i2oizdOfgFh6v3blzXxGJtCHLjBc0eCspMB1N3o5e Ybu8rQUgMS+iLpz7WP/ldMoJW2JUN1JPq4bFs024AAfjMHrp85MdDztHHe6KqEr5baDf lF8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=AyqifRD9BsibCiZ3jDP9xz8aHN1trWQoKONSTIyHuz8=; b=Dzo5b0lYHbnMsZG10v1/UujNWKxya81sehD/ejCQbxXPQZAv9ngiP9cPaUCYyt98MH 7NPM7ZMl2O1MfNwScqOjr+aq0lxaAmPhE7PU8ZCe9a0GQvXFEu7Hk4p/wK5MNTrFAxQ9 b42Itf85CjBYD8795lZTG12fZuHxEs0gK5ZzZoN6/NuSoQSUT2bsFzVbJm3wpDAG+DMw 5J6tihrZXsznEnZgjCh6ev28ILHs/6hkT4k0yCBH31K+EV8xrg/rbBSwEOiIbrQ8Tlqu u8NZXdcjUqT6X3VaVxR4gxLI6nTChC2DLH9UEHJkqVFcRFs/Gtrf7j43SS1v1D/Tqc8L x6LQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net Received: from dd41138.kasserver.com (dd41138.kasserver.com. [85.13.157.12]) by gmr-mx.google.com with ESMTPS id b4si877639wrf.4.2018.01.12.07.00.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 07:00:54 -0800 (PST) Received-SPF: neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) client-ip=85.13.157.12; Received: from WS08941.weidmueller.com (unknown [217.244.7.16]) by dd41138.kasserver.com (Postfix) with ESMTPSA id EB2E411A033E; Fri, 12 Jan 2018 16:00:53 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH v2 1/5] dict: Rename dictionary struct and its key to distinguish it from simple lists Date: Fri, 12 Jan 2018 15:58:44 +0100 Message-Id: <1515769128-29657-1-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 X-Original-Sender: stefan@herbrechtsmeier.net X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net 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: , From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Stefano Babic --- Changes in v2: None bootloader/grub.c | 12 ++++++------ bootloader/grub.h | 2 +- corelib/installer.c | 4 ++-- corelib/swupdate_dict.c | 18 +++++++++--------- handlers/swuforward_handler.c | 2 +- include/swupdate.h | 4 ++-- include/swupdate_dict.h | 14 +++++++------- suricatta/server_hawkbit.c | 6 +++--- suricatta/server_hawkbit.h | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bootloader/grub.c b/bootloader/grub.c index 70bfef2..93682f0 100644 --- a/bootloader/grub.c +++ b/bootloader/grub.c @@ -125,7 +125,7 @@ static int grubenv_parse_script(struct grubenv_t *grubenv, const char *script) goto cleanup; } - /* load varname-value pairs from script into grubenv dictlist */ + /* load key-value pairs from script into grubenv dictionary */ /* Note that variables with no value assigned are skipped now. * We should consider whether we want to replicate U-Boot behavior * (unset if no value given). GRUB env tool distinguishes unsetting @@ -165,7 +165,7 @@ static inline void grubenv_update_size(struct grubenv_t *grubenv) /* lengths of strings + '=' and '\n' characters */ LIST_FOREACH(grubvar, &grubenv->vars, next) { - size = size + strlen(grubvar->varname) + + size = size + strlen(grubvar->key) + strlen(grubvar->value) + 2; } size += strlen(GRUBENV_HEADER); @@ -206,9 +206,9 @@ static int grubenv_write(struct grubenv_t *grubenv) strncpy(buf, GRUBENV_HEADER, strlen(GRUBENV_HEADER) + 1); LIST_FOREACH(grubvar, &grubenv->vars, next) { - llen = strlen(grubvar->varname) + strlen(grubvar->value) + 2; + llen = strlen(grubvar->key) + strlen(grubvar->value) + 2; /* +1 for null termination */ - snprintf(line, llen + 1, "%s=%s\n", grubvar->varname, + snprintf(line, llen + 1, "%s=%s\n", grubvar->key, grubvar->value); strncat(buf, line, llen); } @@ -252,7 +252,7 @@ static inline void grubenv_close(struct grubenv_t *grubenv) struct dict_entry *grubvar; LIST_FOREACH(grubvar, &grubenv->vars, next) { - dict_remove(&grubenv->vars, grubvar->varname); + dict_remove(&grubenv->vars, grubvar->key); } } @@ -332,7 +332,7 @@ int bootloader_apply_list(const char *script) if ((ret = grubenv_open(&grubenv))) goto cleanup; - /* add variables from sw-description into dict list */ + /* add variables from sw-description into dictionary list */ if ((ret = grubenv_parse_script(&grubenv, script))) goto cleanup; diff --git a/bootloader/grub.h b/bootloader/grub.h index d7b2195..6fde318 100644 --- a/bootloader/grub.h +++ b/bootloader/grub.h @@ -41,7 +41,7 @@ #define GRUBENV_PATH_NEW GRUBENV_PATH ".new" struct grubenv_t { - struct dictlist vars; + struct dict vars; size_t size; }; diff --git a/corelib/installer.c b/corelib/installer.c index fc3011e..e25c30c 100644 --- a/corelib/installer.c +++ b/corelib/installer.c @@ -218,10 +218,10 @@ static int prepare_boot_script(struct swupdate_cfg *cfg, const char *script) return -1; LIST_FOREACH(bootvar, &cfg->bootloader, next) { - if (!bootvar->varname || !bootvar->value) + if (!bootvar->key || !bootvar->value) continue; snprintf(buf, sizeof(buf), "%s %s\n", - bootvar->varname, + bootvar->key, bootvar->value); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) { TRACE("Error saving temporary file"); diff --git a/corelib/swupdate_dict.c b/corelib/swupdate_dict.c index 4c8fb44..352c13a 100644 --- a/corelib/swupdate_dict.c +++ b/corelib/swupdate_dict.c @@ -31,19 +31,19 @@ #include "util.h" #include "swupdate_dict.h" -static struct dict_entry *get_entry(struct dictlist *dictionary, char *key) +static struct dict_entry *get_entry(struct dict *dictionary, char *key) { struct dict_entry *entry; LIST_FOREACH(entry, dictionary, next) { - if (strcmp(key, entry->varname) == 0) + if (strcmp(key, entry->key) == 0) return entry; } return NULL; } -int dict_insert_entry(struct dictlist *dictionary, char *key, char *value) +int dict_insert_entry(struct dict *dictionary, char *key, char *value) { struct dict_entry *entry = (struct dict_entry *)malloc(sizeof(*entry)); @@ -51,7 +51,7 @@ int dict_insert_entry(struct dictlist *dictionary, char *key, char *value) return -ENOMEM; memset(entry, 0, sizeof(*entry)); - entry->varname = strdup(key); + entry->key = strdup(key); entry->value = strdup(value); LIST_INSERT_HEAD(dictionary, entry, next); @@ -59,7 +59,7 @@ int dict_insert_entry(struct dictlist *dictionary, char *key, char *value) return 0; } -char *dict_get_value(struct dictlist *dictionary, char *key) +char *dict_get_value(struct dict *dictionary, char *key) { struct dict_entry *entry = get_entry(dictionary, key); @@ -69,7 +69,7 @@ char *dict_get_value(struct dictlist *dictionary, char *key) return entry->value; } -int dict_set_value(struct dictlist *dictionary, char *key, char *value) +int dict_set_value(struct dict *dictionary, char *key, char *value) { struct dict_entry *entry = get_entry(dictionary, key); @@ -88,12 +88,12 @@ int dict_set_value(struct dictlist *dictionary, char *key, char *value) void dict_remove_entry(struct dict_entry *entry) { LIST_REMOVE(entry, next); - free(entry->varname); + free(entry->key); free(entry->value); free(entry); } -void dict_remove(struct dictlist *dictionary, char *key) +void dict_remove(struct dict *dictionary, char *key) { struct dict_entry *entry = get_entry(dictionary, key); @@ -104,7 +104,7 @@ void dict_remove(struct dictlist *dictionary, char *key) dict_remove_entry(entry); } -void dict_drop_db(struct dictlist *dictionary) +void dict_drop_db(struct dict *dictionary) { struct dict_entry *var; diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c index 61a3346..54aef4b 100644 --- a/handlers/swuforward_handler.c +++ b/handlers/swuforward_handler.c @@ -339,7 +339,7 @@ static int install_remote_swu(struct img_type *img, LIST_FOREACH(url, &img->properties, next) { char curlheader[SWUPDATE_GENERAL_STRING_SIZE + strlen(CUSTOM_HEADER)]; - if (!url->varname || !url->value || strcmp(url->varname, "url")) + if (!url->key || !url->value || strcmp(url->key, "url")) continue; conn = (struct curlconn *)calloc(1, sizeof(struct curlconn)); diff --git a/include/swupdate.h b/include/swupdate.h index b065f7e..2e79817 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -78,7 +78,7 @@ struct img_type { int install_directly; int is_script; int is_partitioner; - struct dictlist properties; + struct dict properties; long long partsize; int fdin; /* Used for streaming file */ off_t offset; /* offset in cpio file */ @@ -134,7 +134,7 @@ struct swupdate_cfg { struct imglist images; struct imglist partitions; struct imglist scripts; - struct dictlist bootloader; + struct dict bootloader; struct proclist extprocs; void *dgst; /* Structure for signed images */ struct swupdate_global_cfg globals; diff --git a/include/swupdate_dict.h b/include/swupdate_dict.h index d8edb63..f8b696f 100644 --- a/include/swupdate_dict.h +++ b/include/swupdate_dict.h @@ -24,18 +24,18 @@ #include struct dict_entry { - char *varname; + char *key; char *value; LIST_ENTRY(dict_entry) next; }; -LIST_HEAD(dictlist, dict_entry); +LIST_HEAD(dict, dict_entry); -char *dict_get_value(struct dictlist *dictionary, char *key); -int dict_set_value(struct dictlist *dictionary, char *key, char *value); -int dict_insert_entry(struct dictlist *dictionary, char *key, char *value); -void dict_remove(struct dictlist *dictionary, char *key); +char *dict_get_value(struct dict *dictionary, char *key); +int dict_set_value(struct dict *dictionary, char *key, char *value); +int dict_insert_entry(struct dict *dictionary, char *key, char *value); +void dict_remove(struct dict *dictionary, char *key); void dict_remove_entry(struct dict_entry *entry); -void dict_drop_db(struct dictlist *dictionary); +void dict_drop_db(struct dict *dictionary); #endif diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 670c7ae..51ed32f 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -1348,7 +1348,7 @@ int get_target_data_length(void) struct dict_entry *entry; LIST_FOREACH(entry, &server_hawkbit.configdata, next) { - len += strlen(entry->varname) + strlen(entry->value) + strlen (" : ") + 6; + len += strlen(entry->key) + strlen(entry->value) + strlen (" : ") + 6; } return len; @@ -1382,14 +1382,14 @@ server_op_res_t server_send_target_data(void) if (ENOMEM_ASPRINTF == asprintf(&keyvalue, config_data, ((first) ? ' ' : ','), - entry->varname, + entry->key, entry->value)) { ERROR("hawkBit server reply cannot be sent because of OOM.\n"); result = SERVER_EINIT; goto cleanup; } first = false; - TRACE("KEYVALUE=%s %s %s", keyvalue, entry->varname, entry->value); + TRACE("KEYVALUE=%s %s %s", keyvalue, entry->key, entry->value); strcat(configData, keyvalue); free(keyvalue); diff --git a/suricatta/server_hawkbit.h b/suricatta/server_hawkbit.h index 0655980..33f4afb 100644 --- a/suricatta/server_hawkbit.h +++ b/suricatta/server_hawkbit.h @@ -40,7 +40,7 @@ typedef struct { unsigned int polling_interval; bool polling_interval_from_server; bool debug; - struct dictlist configdata; + struct dict configdata; bool has_to_send_configData; char *configData_url; char *cancel_url;