From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 049A4C11F64 for ; Thu, 1 Jul 2021 06:20:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7514A61582 for ; Thu, 1 Jul 2021 06:20:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7514A61582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6FBCD832B5; Thu, 1 Jul 2021 08:17:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tnArAtw8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F05983270; Thu, 1 Jul 2021 08:16:59 +0200 (CEST) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE5A083278 for ; Thu, 1 Jul 2021 08:16:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x836.google.com with SMTP id f20so3362132qtk.10 for ; Wed, 30 Jun 2021 23:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GuJjD7gJwPNC1Ib0JnyBXbtkoWY0/IHCQdCIGqtPp0Y=; b=tnArAtw85wNbd7OAM2yUIHdKNaWDZAIsA47DmNliTBvz20YKf8Eh5j8lLQkVIts11a eAUa5/Nb6xwf5YMBQmH2MF9EaDjuOgylwr1ZR8BSTQTy0Omr0Hz1bsArAID6A8qJDgy+ A6S7Yh7EvDI2a7JpIBPvkWPtHz08iAAyRWonG7UQxKfW91nuE8PJsJnCG/j1aMyjt2Tr fo17DLt0mar1kNjoer6WiRkx3Nfvs8BHZpFbNnwudbRVzVkp5xsYWA/mxKnhir2oMOoc 1gpUaMEtHTAPbYfqIkvti+JX2WQ7qHoNSZ6aVR2NtdIheK9ROQg9HFmnZarZ6Gi68isv txXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GuJjD7gJwPNC1Ib0JnyBXbtkoWY0/IHCQdCIGqtPp0Y=; b=fo8CxXiIQ99XSD8/5IUy6EZzHdFjwZYTbn+p0syLNPRS6/X/IBdOcRTZxymHJkeBGY Cj1bYVpA4mpWXSH96gzJ0JYlp6eabj3lq/hDa6AjYtiwW/QxBY2/2pBUpQXx444QBXNE hY8SqlMFezbr+IKaUdbsiqE5+4vWfeAZEfWNSIOlEEa3q3ziz+C4o8lJ0KPh7MVw/yJb lTflrVzKIGwAUHrWMgTopP6Qap2/oMqlXNrVcyBpqL1JbkbqZb7UwvbzbOlE+4PGk0tb B9YO7nk4TYlow3FiAZIxEFPg7a/OmOuiExk1Si+6h+WYWrfHeSZaVP98mVczPENWpYmd cHJQ== X-Gm-Message-State: AOAM530/KA/hTg+SkYAfVqIK4KJYunX7oTtEX9NetXF1+Z+e6Hnd5AET KZQu7GIjZjp5uxYHBHnsgXDxTHICpy4= X-Google-Smtp-Source: ABdhPJygR6HieluFyDR6PwluSqv5R5zVpPrgFE/cFh6pmuVG3vwVyk9MlsHTsCPZtEhEtAmgnNS1lw== X-Received: by 2002:ac8:5c8c:: with SMTP id r12mr35373665qta.265.1625120191365; Wed, 30 Jun 2021 23:16:31 -0700 (PDT) Received: from godwin.fios-router.home (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.gmail.com with ESMTPSA id g21sm1684673qts.90.2021.06.30.23.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:16:31 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Tom Rini Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Wolfgang Denk , Simon Glass , Roland Gaudig , Heinrich Schuchardt , Kostas Michalopoulos , Sean Anderson Subject: [RFC PATCH 22/28] env: Add a priv pointer to hwalk_r Date: Thu, 1 Jul 2021 02:16:05 -0400 Message-Id: <20210701061611.957918-23-seanga2@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210701061611.957918-1-seanga2@gmail.com> References: <20210701061611.957918-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This allows callers of hwalk_r to pass data to their callback. This mirrors e.g. env_attr_walk. Signed-off-by: Sean Anderson --- cmd/nvedit.c | 8 ++++---- env/callback.c | 4 ++-- env/flags.c | 4 ++-- include/search.h | 2 +- lib/hashtable.c | 5 +++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index d14ba10cef..b855e502c0 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -481,7 +481,7 @@ static int print_static_binding(const char *var_name, const char *callback_name, return 0; } -static int print_active_callback(struct env_entry *entry) +static int print_active_callback(struct env_entry *entry, void *priv) { struct env_clbk_tbl *clbkp; int i; @@ -544,7 +544,7 @@ int do_env_callback(struct cmd_tbl *cmdtp, int flag, int argc, puts("Active callback bindings:\n"); printf("\t%-20s %-20s\n", "Variable Name", "Callback Name"); printf("\t%-20s %-20s\n", "-------------", "-------------"); - hwalk_r(&env_htab, print_active_callback); + hwalk_r(&env_htab, print_active_callback, NULL); return 0; } #endif @@ -563,7 +563,7 @@ static int print_static_flags(const char *var_name, const char *flags, return 0; } -static int print_active_flags(struct env_entry *entry) +static int print_active_flags(struct env_entry *entry, void *priv) { enum env_flags_vartype type; enum env_flags_varaccess access; @@ -617,7 +617,7 @@ int do_env_flags(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) "Variable Access"); printf("\t%-20s %-20s %-20s\n", "-------------", "-------------", "---------------"); - hwalk_r(&env_htab, print_active_flags); + hwalk_r(&env_htab, print_active_flags, NULL); return 0; } #endif diff --git a/env/callback.c b/env/callback.c index 638a02b28f..47075acb92 100644 --- a/env/callback.c +++ b/env/callback.c @@ -83,7 +83,7 @@ void env_callback_init(struct env_entry *var_entry) * Called on each existing env var prior to the blanket update since removing * a callback association should remove its callback. */ -static int clear_callback(struct env_entry *entry) +static int clear_callback(struct env_entry *entry, void *priv) { entry->callback = NULL; @@ -127,7 +127,7 @@ static int on_callbacks(const char *name, const char *value, enum env_op op, int flags) { /* remove all callbacks */ - hwalk_r(&env_htab, clear_callback); + hwalk_r(&env_htab, clear_callback, NULL); /* configure any static callback bindings */ env_attr_walk(ENV_CALLBACK_LIST_STATIC, set_callback, NULL); diff --git a/env/flags.c b/env/flags.c index e3e833c433..f2e36e3dd3 100644 --- a/env/flags.c +++ b/env/flags.c @@ -468,7 +468,7 @@ void env_flags_init(struct env_entry *var_entry) * Called on each existing env var prior to the blanket update since removing * a flag in the flag list should remove its flags. */ -static int clear_flags(struct env_entry *entry) +static int clear_flags(struct env_entry *entry, void *priv) { entry->flags = 0; @@ -503,7 +503,7 @@ static int on_flags(const char *name, const char *value, enum env_op op, int flags) { /* remove all flags */ - hwalk_r(&env_htab, clear_flags); + hwalk_r(&env_htab, clear_flags, NULL); /* configure any static flags */ env_attr_walk(ENV_FLAGS_LIST_STATIC, set_flags, NULL); diff --git a/include/search.h b/include/search.h index d0bb44388e..4a0828fb8d 100644 --- a/include/search.h +++ b/include/search.h @@ -105,7 +105,7 @@ int himport_r(struct hsearch_data *htab, const char *env, size_t size, /* Walk the whole table calling the callback on each element */ int hwalk_r(struct hsearch_data *htab, - int (*callback)(struct env_entry *entry)); + int (*callback)(struct env_entry *entry, void *priv), void *priv); /* Flags for himport_r(), hexport_r(), hdelete_r(), and hsearch_r() */ #define H_NOCLEAR (1 << 0) /* do not clear hash table before importing */ diff --git a/lib/hashtable.c b/lib/hashtable.c index ff5ff72639..425a880222 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -998,14 +998,15 @@ end: * Walk all of the entries in the hash, calling the callback for each one. * this allows some generic operation to be performed on each element. */ -int hwalk_r(struct hsearch_data *htab, int (*callback)(struct env_entry *entry)) +int hwalk_r(struct hsearch_data *htab, + int (*callback)(struct env_entry *entry, void *priv), void *priv) { int i; int retval; for (i = 1; i <= htab->size; ++i) { if (htab->table[i].used > 0) { - retval = callback(&htab->table[i].entry); + retval = callback(&htab->table[i].entry, priv); if (retval) return retval; } -- 2.32.0