get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/179816/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 179816,
    "url": "http://patchwork.ozlabs.org/api/patches/179816/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/1345803102-21110-3-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-3-git-send-email-gerlando.falauto@keymile.com>",
    "list_archive_url": null,
    "date": "2012-08-24T10:11:37",
    "name": "[U-Boot,v4,2/7] env: unify logic to check and apply changes",
    "commit_ref": "c3f6525854bbc664ce9fbed9754af1daf56ba08e",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c98029f424441c07d433bfe61c8bc1104565c4d5",
    "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-3-git-send-email-gerlando.falauto@keymile.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/179816/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/179816/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 044262C00C4\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 24 Aug 2012 20:19:55 +1000 (EST)",
            "from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 22D3828127;\n\tFri, 24 Aug 2012 12:19:31 +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 GXmxGZjklIL5; Fri, 24 Aug 2012 12:19:30 +0200 (CEST)",
            "from theia.denx.de (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 4403828129;\n\tFri, 24 Aug 2012 12:18:53 +0200 (CEST)",
            "from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id D55F328101\n\tfor <u-boot@lists.denx.de>; Fri, 24 Aug 2012 12:18:42 +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 JhCdUeHJGt8R for <u-boot@lists.denx.de>;\n\tFri, 24 Aug 2012 12:18:40 +0200 (CEST)",
            "from mail-de.keymile.com (mail-de.keymile.com [195.8.104.1])\n\tby theia.denx.de (Postfix) with SMTP id AF5B0280C4\n\tfor <u-boot@lists.denx.de>; Fri, 24 Aug 2012 12:18:38 +0200 (CEST)",
            "from mailrelay.de.keymile.net ([10.9.1.54]) by eSafe SMTP Relay\n\t1345792219; Fri, 24 Aug 2012 12:18:37 +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 q7OAHMjA026728; Fri, 24 Aug 2012 12:17:28 +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:37 +0200",
        "Message-Id": "<1345803102-21110-3-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 2/7] env: unify logic to check and apply changes",
        "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": "The logic of checking special parameters (e.g. baudrate, stdin, stdout,\nfor a valid value and/or whether can be overwritten) and applying the\nnew value to the running system is now all within a single function\nenv_check_apply() which can be called whenever changes are made\nto the environment, no matter if by set, default or import.\n\nWith this patch env_check_apply() is only called by \"env set\",\nretaining previous behavior.\n\nSigned-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>\n---\n common/cmd_nvedit.c |  141 +++++++++++++++++++++++++++++++++------------------\n include/search.h    |    3 +-\n 2 files changed, 94 insertions(+), 50 deletions(-)",
    "diff": "diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c\nindex b8c7676..2f5dcbc 100644\n--- a/common/cmd_nvedit.c\n+++ b/common/cmd_nvedit.c\n@@ -198,31 +198,19 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag,\n #endif\n \n /*\n- * Set a new environment variable,\n- * or replace or delete an existing one.\n+ * Perform consistency checking before setting, replacing, or deleting an\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+ * 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  */\n-int _do_env_set(int flag, int argc, char * const argv[])\n+\n+int env_check_apply(const char *name, const char *oldval,\n+\t\t\tconst char *newval, int flag)\n {\n-\tint   i, len;\n \tint   console = -1;\n-\tchar  *name, *value, *s;\n-\tENTRY e, *ep;\n-\n-\tname = argv[1];\n-\n-\tif (strchr(name, '=')) {\n-\t\tprintf(\"## Error: illegal character '=' in variable name\"\n-\t\t       \"\\\"%s\\\"\\n\", name);\n-\t\treturn 1;\n-\t}\n-\n-\tenv_id++;\n-\t/*\n-\t * search if variable with this name already exists\n-\t */\n-\te.key = name;\n-\te.data = NULL;\n-\thsearch_r(e, FIND, &ep, &env_htab);\n \n \t/* Check for console redirection */\n \tif (strcmp(name, \"stdin\") == 0)\n@@ -233,59 +221,75 @@ int _do_env_set(int flag, int argc, char * const argv[])\n \t\tconsole = stderr;\n \n \tif (console != -1) {\n-\t\tif (argc < 3) {\t\t/* Cannot delete it! */\n-\t\t\tprintf(\"Can't delete \\\"%s\\\"\\n\", name);\n+\t\tif ((newval == NULL) || (*newval == '\\0')) {\n+\t\t\t/* We cannot delete stdin/stdout/stderr */\n+\t\t\tif ((flag & H_FORCE) == 0)\n+\t\t\t\tprintf(\"Can't delete \\\"%s\\\"\\n\", name);\n \t\t\treturn 1;\n \t\t}\n \n #ifdef CONFIG_CONSOLE_MUX\n-\t\tif (iomux_doenv(console, argv[2]))\n+\t\tif (iomux_doenv(console, newval))\n \t\t\treturn 1;\n #else\n \t\t/* Try assigning specified device */\n-\t\tif (console_assign(console, argv[2]) < 0)\n+\t\tif (console_assign(console, newval) < 0)\n \t\t\treturn 1;\n \n #ifdef CONFIG_SERIAL_MULTI\n-\t\tif (serial_assign(argv[2]) < 0)\n+\t\tif (serial_assign(newval) < 0)\n \t\t\treturn 1;\n #endif\n #endif /* CONFIG_CONSOLE_MUX */\n \t}\n \n \t/*\n-\t * Some variables like \"ethaddr\" and \"serial#\" can be set only\n-\t * once and cannot be deleted; also, \"ver\" is readonly.\n+\t * Some variables like \"ethaddr\" and \"serial#\" can be set only once and\n+\t * cannot be deleted, unless CONFIG_ENV_OVERWRITE is defined.\n \t */\n-\tif (ep) {\t\t/* variable exists */\n #ifndef CONFIG_ENV_OVERWRITE\n+\tif (oldval != NULL &&\t\t\t/* variable exists */\n+\t\t(flag & H_FORCE) == 0) {\t/* and we are not forced */\n \t\tif (strcmp(name, \"serial#\") == 0 ||\n \t\t    (strcmp(name, \"ethaddr\") == 0\n #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)\n-\t\t     && strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0\n+\t\t     && strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0\n #endif\t/* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */\n \t\t\t)) {\n \t\t\tprintf(\"Can't overwrite \\\"%s\\\"\\n\", name);\n \t\t\treturn 1;\n \t\t}\n+\t}\n #endif\n+\t/*\n+\t * When we change baudrate, or we are doing an env default -a\n+\t * (which will erase all variables prior to calling this),\n+\t * we want the baudrate to actually change - for real.\n+\t */\n+\tif (oldval != NULL ||\t\t\t/* variable exists */\n+\t\t(flag & H_NOCLEAR) == 0) {\t/* or env is clear */\n \t\t/*\n \t\t * Switch to new baudrate if new baudrate is supported\n \t\t */\n \t\tif (strcmp(name, \"baudrate\") == 0) {\n-\t\t\tint baudrate = simple_strtoul(argv[2], NULL, 10);\n+\t\t\tint baudrate = simple_strtoul(newval, NULL, 10);\n \t\t\tint i;\n \t\t\tfor (i = 0; i < N_BAUDRATES; ++i) {\n \t\t\t\tif (baudrate == baudrate_table[i])\n \t\t\t\t\tbreak;\n \t\t\t}\n \t\t\tif (i == N_BAUDRATES) {\n-\t\t\t\tprintf(\"## Baudrate %d bps not supported\\n\",\n-\t\t\t\t\tbaudrate);\n+\t\t\t\tif ((flag & H_FORCE) == 0)\n+\t\t\t\t\tprintf(\"## Baudrate %d bps not \"\n+\t\t\t\t\t\t\"supported\\n\", baudrate);\n \t\t\t\treturn 1;\n \t\t\t}\n+\t\t\tif (gd->baudrate == baudrate) {\n+\t\t\t\t/* If unchanged, we just say it's OK */\n+\t\t\t\treturn 0;\n+\t\t\t}\n \t\t\tprintf(\"## Switch baudrate to %d bps and\"\n-\t\t\t       \"press ENTER ...\\n\", baudrate);\n+\t\t\t\t\"press ENTER ...\\n\", baudrate);\n \t\t\tudelay(50000);\n \t\t\tgd->baudrate = baudrate;\n #if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)\n@@ -299,6 +303,59 @@ int _do_env_set(int flag, int argc, char * const argv[])\n \t\t}\n \t}\n \n+\t/*\n+\t * Some variables should be updated when the corresponding\n+\t * entry in the environment is changed\n+\t */\n+\tif (strcmp(name, \"loadaddr\") == 0) {\n+\t\tload_addr = simple_strtoul(newval, NULL, 16);\n+\t\treturn 0;\n+\t}\n+#if defined(CONFIG_CMD_NET)\n+\telse if (strcmp(name, \"bootfile\") == 0) {\n+\t\tcopy_filename(BootFile, newval, sizeof(BootFile));\n+\t\treturn 0;\n+\t}\n+#endif\n+\treturn 0;\n+}\n+\n+/*\n+ * Set a new environment variable,\n+ * or replace or delete an existing one.\n+*/\n+int _do_env_set(int flag, int argc, char * const argv[])\n+{\n+\tint   i, len;\n+\tchar  *name, *value, *s;\n+\tENTRY e, *ep;\n+\n+\tname = argv[1];\n+\tvalue = argv[2];\n+\n+\tif (strchr(name, '=')) {\n+\t\tprintf(\"## Error: illegal character '='\"\n+\t\t       \"in variable name \\\"%s\\\"\\n\", name);\n+\t\treturn 1;\n+\t}\n+\n+\tenv_id++;\n+\t/*\n+\t * search if variable with this name already exists\n+\t */\n+\te.key = name;\n+\te.data = NULL;\n+\thsearch_r(e, FIND, &ep, &env_htab);\n+\n+\t/*\n+\t * Perform requested checks. Notice how since we are overwriting\n+\t * a single variable, we need to set H_NOCLEAR\n+\t */\n+\tif (env_check_apply(name, ep ? ep->data : NULL, value, H_NOCLEAR)) {\n+\t\tdebug(\"check function did not approve, refusing\\n\");\n+\t\treturn 1;\n+\t}\n+\n \t/* Delete only ? */\n \tif (argc < 3 || argv[2] == NULL) {\n \t\tint rc = hdelete_r(name, &env_htab);\n@@ -336,20 +393,6 @@ int _do_env_set(int flag, int argc, char * const argv[])\n \t\treturn 1;\n \t}\n \n-\t/*\n-\t * Some variables should be updated when the corresponding\n-\t * entry in the environment is changed\n-\t */\n-\tif (strcmp(argv[1], \"loadaddr\") == 0) {\n-\t\tload_addr = simple_strtoul(argv[2], NULL, 16);\n-\t\treturn 0;\n-\t}\n-#if defined(CONFIG_CMD_NET)\n-\telse if (strcmp(argv[1], \"bootfile\") == 0) {\n-\t\tcopy_filename(BootFile, argv[2], sizeof(BootFile));\n-\t\treturn 0;\n-\t}\n-#endif\n \treturn 0;\n }\n \ndiff --git a/include/search.h b/include/search.h\nindex ef53edb..a4a5ef4 100644\n--- a/include/search.h\n+++ b/include/search.h\n@@ -99,6 +99,7 @@ extern int himport_r(struct hsearch_data *__htab,\n \t\t     int __flag);\n \n /* Flags for himport_r() */\n-#define\tH_NOCLEAR\t1\t/* do not clear hash table before importing */\n+#define\tH_NOCLEAR\t(1 << 0) /* do not clear hash table before importing */\n+#define\tH_FORCE\t\t(1 << 1) /* overwrite read-only/write-once variables */\n \n #endif /* search.h */\n",
    "prefixes": [
        "U-Boot",
        "v4",
        "2/7"
    ]
}