Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/179817/?format=api
{ "id": 179817, "url": "http://patchwork.ozlabs.org/api/patches/179817/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/1345803102-21110-5-git-send-email-gerlando.falauto@keymile.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1345803102-21110-5-git-send-email-gerlando.falauto@keymile.com>", "list_archive_url": null, "date": "2012-08-24T10:11:39", "name": "[U-Boot,v4,4/7] env: add check/apply logic to himport_r()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "aee461a9b1e9a8801047b56b3b0c4766f4cfd7f0", "submitter": { "id": 9154, "url": "http://patchwork.ozlabs.org/api/people/9154/?format=api", "name": "Gerlando Falauto", "email": "gerlando.falauto@keymile.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/1345803102-21110-5-git-send-email-gerlando.falauto@keymile.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/179817/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/179817/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Received": [ "from theia.denx.de (theia.denx.de [85.214.87.163])\n\tby ozlabs.org (Postfix) with ESMTP id 5BBD92C00C4\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 24 Aug 2012 20:20:06 +1000 (EST)", "from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id B346D2812E;\n\tFri, 24 Aug 2012 12:19:38 +0200 (CEST)", "from theia.denx.de ([127.0.0.1])\n\tby localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 9e8D-MQOrseF; Fri, 24 Aug 2012 12:19:38 +0200 (CEST)", "from theia.denx.de (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 90BA928130;\n\tFri, 24 Aug 2012 12:18:54 +0200 (CEST)", "from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 007F82809F\n\tfor <u-boot@lists.denx.de>; Fri, 24 Aug 2012 12:18:47 +0200 (CEST)", "from theia.denx.de ([127.0.0.1])\n\tby localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id CT4Gu3FH4H2n for <u-boot@lists.denx.de>;\n\tFri, 24 Aug 2012 12:18:46 +0200 (CEST)", "from mail-de.keymile.com (mail-de.keymile.com [195.8.104.1])\n\tby theia.denx.de (Postfix) with SMTP id 54686280CA\n\tfor <u-boot@lists.denx.de>; Fri, 24 Aug 2012 12:18:41 +0200 (CEST)", "from mailrelay.de.keymile.net ([10.9.1.54]) by eSafe SMTP Relay\n\t1345792219; Fri, 24 Aug 2012 12:18:39 +0200", "from chber1-10555x.ch.keymile.net (chber1-10555x.ch.keymile.net\n\t[172.31.40.82]) by mailrelay.de.keymile.net (8.12.2/8.12.2)\n\twith ESMTP id q7OAHMjC026728; Fri, 24 Aug 2012 12:17:30 +0200 (MEST)" ], "X-Virus-Scanned": [ "Debian amavisd-new at theia.denx.de", "Debian amavisd-new at theia.denx.de" ], "X-policyd-weight": "NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5\n\tNOT_IN_BL_NJABL=-1.5 (only DNSBL check requested)", "From": "Gerlando Falauto <gerlando.falauto@keymile.com>", "To": "u-boot@lists.denx.de", "Date": "Fri, 24 Aug 2012 12:11:39 +0200", "Message-Id": "<1345803102-21110-5-git-send-email-gerlando.falauto@keymile.com>", "X-Mailer": "git-send-email 1.7.10.4", "In-Reply-To": "<1345803102-21110-1-git-send-email-gerlando.falauto@keymile.com>", "References": "<1321634955-5561-1-git-send-email-gerlando.falauto@keymile.com><1345803102-21110-1-git-send-email-gerlando.falauto@keymile.com>", "X-ESAFE-STATUS": "[srvhellgate.de.keymile.net] Mail clean", "Cc": "marex@denx.de, holger.brunck@keymile.com,\n\tGerlando Falauto <gerlando.falauto@keymile.com>", "Subject": "[U-Boot] [PATCH v4 4/7] env: add check/apply logic to himport_r()", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.11", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<http://lists.denx.de/mailman/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<http://lists.denx.de/mailman/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "u-boot-bounces@lists.denx.de", "Errors-To": "u-boot-bounces@lists.denx.de" }, "content": "Change hashtable so that a callback function will decide whether a\nvariable can be overwritten, and possibly apply the changes.\n\nSo add a new field to struct hsearch_data:\n\n o \"apply\" callback function to check whether a variable can be\n overwritten, and possibly immediately apply the changes;\n when NULL, no check is performed.\n\nAnd a new argument to himport_r():\n o \"do_apply\": whether to call the apply callback function\n\nNOTE: This patch does not change the current behavior.\n\nSigned-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>\n---\n common/cmd_nvedit.c | 3 ++-\n common/env_common.c | 8 +++++---\n include/environment.h | 9 +++++++++\n include/search.h | 14 +++++++++++++-\n lib/hashtable.c | 20 +++++++++++++++++++-\n 5 files changed, 48 insertions(+), 6 deletions(-)", "diff": "diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c\nindex 493aecc..983e747 100644\n--- a/common/cmd_nvedit.c\n+++ b/common/cmd_nvedit.c\n@@ -202,6 +202,7 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag,\n * environment variable, then (if successful) apply the changes to internals so\n * to make them effective. Code for this function was taken out of\n * _do_env_set(), which now calls it instead.\n+ * Also called as a callback function by himport_r().\n * Returns 0 in case of success, 1 in case of failure.\n * When (flag & H_FORCE) is set, do not print out any error message and force\n * overwriting of write-once variables.\n@@ -915,7 +916,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,\n \t}\n \n \tif (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR,\n-\t\t\t0, NULL) == 0) {\n+\t\t\t0, NULL, 0 /* do_apply */) == 0) {\n \t\terror(\"Environment import failed: errno = %d\\n\", errno);\n \t\treturn 1;\n \t}\ndiff --git a/common/env_common.c b/common/env_common.c\nindex 8f142ed..c6e7c4c 100644\n--- a/common/env_common.c\n+++ b/common/env_common.c\n@@ -133,7 +133,9 @@ const uchar default_environment[] = {\n \t\"\\0\"\n };\n \n-struct hsearch_data env_htab;\n+struct hsearch_data env_htab = {\n+\t.apply = env_check_apply,\n+};\n \n static uchar __env_get_char_spec(int index)\n {\n@@ -194,7 +196,7 @@ void set_default_env(const char *s)\n \n \tif (himport_r(&env_htab, (char *)default_environment,\n \t\t\tsizeof(default_environment), '\\0', 0,\n-\t\t\t0, NULL) == 0)\n+\t\t\t0, NULL, 0 /* do_apply */) == 0)\n \t\terror(\"Environment import failed: errno = %d\\n\", errno);\n \n \tgd->flags |= GD_FLG_ENV_READY;\n@@ -220,7 +222,7 @@ int env_import(const char *buf, int check)\n \t}\n \n \tif (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\\0', 0,\n-\t\t\t0, NULL)) {\n+\t\t\t0, NULL, 0 /* do_apply */)) {\n \t\tgd->flags |= GD_FLG_ENV_READY;\n \t\treturn 1;\n \t}\ndiff --git a/include/environment.h b/include/environment.h\nindex ae3f7b6..90fb130 100644\n--- a/include/environment.h\n+++ b/include/environment.h\n@@ -184,6 +184,15 @@ void set_default_env(const char *s);\n /* Import from binary representation into hash table */\n int env_import(const char *buf, int check);\n \n+/*\n+ * Check if variable \"name\" can be changed from oldval to newval,\n+ * and if so, apply the changes (e.g. baudrate).\n+ * When (flag & H_FORCE) is set, it does not print out any error\n+ * message and forces overwriting of write-once variables.\n+ */\n+int env_check_apply(const char *name, const char *oldval,\n+\t\t\tconst char *newval, int flag);\n+\n #endif /* DO_DEPS_ONLY */\n \n #endif /* _ENVIRONMENT_H_ */\ndiff --git a/include/search.h b/include/search.h\nindex 94d75fc..721c8ac 100644\n--- a/include/search.h\n+++ b/include/search.h\n@@ -57,6 +57,16 @@ struct hsearch_data {\n \tstruct _ENTRY *table;\n \tunsigned int size;\n \tunsigned int filled;\n+/*\n+ * Callback function which will check whether the given change for variable\n+ * \"name\" from \"oldval\" to \"newval\" may be applied or not, and possibly apply\n+ * such change.\n+ * When (flag & H_FORCE) is set, it shall not print out any error message and\n+ * shall force overwriting of write-once variables.\n+.* Must return 0 for approval, 1 for denial.\n+ */\n+\tint (*apply)(const char *name, const char *oldval,\n+\t\t\tconst char *newval, int flag);\n };\n \n /* Create a new hashing table which will at most contain NEL elements. */\n@@ -97,10 +107,12 @@ extern ssize_t hexport_r(struct hsearch_data *__htab,\n /*\n * nvars: length of vars array\n * vars: array of strings (variable names) to import (nvars == 0 means all)\n+ * do_apply: whether to call callback function to check the new argument,\n+ * and possibly apply changes (false means accept everything)\n */\n extern int himport_r(struct hsearch_data *__htab,\n \t\t const char *__env, size_t __size, const char __sep,\n-\t\t int __flag, int nvars, char * const vars[]);\n+\t\t int __flag, int nvars, char * const vars[], int do_apply);\n \n /* Flags for himport_r() */\n #define\tH_NOCLEAR\t(1 << 0) /* do not clear hash table before importing */\ndiff --git a/lib/hashtable.c b/lib/hashtable.c\nindex 0610e86..6cfba56 100644\n--- a/lib/hashtable.c\n+++ b/lib/hashtable.c\n@@ -658,7 +658,7 @@ static int is_var_in_set(const char *name, int nvars, char * const vars[])\n \n int himport_r(struct hsearch_data *htab,\n \t\tconst char *env, size_t size, const char sep, int flag,\n-\t\tint nvars, char * const vars[])\n+\t\tint nvars, char * const vars[], int do_apply)\n {\n \tchar *data, *sp, *dp, *name, *value;\n \n@@ -772,6 +772,24 @@ int himport_r(struct hsearch_data *htab,\n \t\te.key = name;\n \t\te.data = value;\n \n+\t\t/* if there is an apply function, check what it has to say */\n+\t\tif (do_apply && htab->apply != NULL) {\n+\t\t\tdebug(\"searching before calling cb function\"\n+\t\t\t\t\" for %s\\n\", name);\n+\t\t\t/*\n+\t\t\t * Search for variable in existing env, so to pass\n+\t\t\t * its previous value to the apply callback\n+\t\t\t */\n+\t\t\thsearch_r(e, FIND, &rv, htab);\n+\t\t\tdebug(\"previous value was %s\\n\", rv ? rv->data : \"\");\n+\t\t\tif (htab->apply(name, rv ? rv->data : NULL,\n+\t\t\t\tvalue, flag)) {\n+\t\t\t\tdebug(\"callback function refused to set\"\n+\t\t\t\t\t\" variable %s, skipping it!\\n\", name);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t}\n+\n \t\thsearch_r(e, ENTER, &rv, htab);\n \t\tif (rv == NULL) {\n \t\t\tprintf(\"himport_r: can't insert \\\"%s=%s\\\" into hash table\\n\",\n", "prefixes": [ "U-Boot", "v4", "4/7" ] }