get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 88478,
    "url": "http://patches.dpdk.org/api/patches/88478/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1614868228-13685-10-git-send-email-xuemingl@nvidia.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1614868228-13685-10-git-send-email-xuemingl@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1614868228-13685-10-git-send-email-xuemingl@nvidia.com",
    "date": "2021-03-04T14:30:25",
    "name": "[v8,9/9] kvargs: update parser to support lists",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "87ce34f3bb62717eba444a1428d3457e9724ca6c",
    "submitter": {
        "id": 1904,
        "url": "http://patches.dpdk.org/api/people/1904/?format=api",
        "name": "Xueming Li",
        "email": "xuemingl@nvidia.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1614868228-13685-10-git-send-email-xuemingl@nvidia.com/mbox/",
    "series": [
        {
            "id": 15491,
            "url": "http://patches.dpdk.org/api/series/15491/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=15491",
            "date": "2021-03-04T14:30:16",
            "name": "ethdev: support SubFunction representor",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/15491/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/88478/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/88478/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id B505FA0561;\n\tThu,  4 Mar 2021 15:32:09 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2147822A318;\n\tThu,  4 Mar 2021 15:31:24 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id 4416D22A2F7\n for <dev@dpdk.org>; Thu,  4 Mar 2021 15:31:21 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n xuemingl@nvidia.com) with SMTP; 4 Mar 2021 16:31:18 +0200",
            "from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 124EUkoX027668;\n Thu, 4 Mar 2021 16:31:18 +0200"
        ],
        "From": "Xueming Li <xuemingl@nvidia.com>",
        "To": "Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>",
        "Cc": "dev@dpdk.org, Viacheslav Ovsiienko <viacheslavo@nvidia.com>,\n xuemingl@nvidia.com, Asaf Penso <asafp@nvidia.com>,\n Olivier Matz <olivier.matz@6wind.com>",
        "Date": "Thu,  4 Mar 2021 14:30:25 +0000",
        "Message-Id": "<1614868228-13685-10-git-send-email-xuemingl@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<1614868228-13685-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "References": [
            "<1614868228-13685-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v8 9/9] kvargs: update parser to support lists",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch updates kvargs parser to support lists on top of range, allow\nmultiple lists or range:\n  k1=a[1,2]b[3-5]\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>\nAcked-by: Thomas Monjalon <thomas@monjalon.net>\n---\n app/test/test_kvargs.c         |  46 +++++++++++++--\n lib/librte_kvargs/rte_kvargs.c | 101 +++++++++++++++++++++++----------\n 2 files changed, 112 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c\nindex 2a2dae43a0..a91ea8dc47 100644\n--- a/app/test/test_kvargs.c\n+++ b/app/test/test_kvargs.c\n@@ -35,6 +35,25 @@ static int check_handler(const char *key, const char *value,\n \treturn 0;\n }\n \n+/* test parsing. */\n+static int test_kvargs_parsing(const char *args, unsigned int n)\n+{\n+\tstruct rte_kvargs *kvlist;\n+\n+\tkvlist = rte_kvargs_parse(args, NULL);\n+\tif (kvlist == NULL) {\n+\t\tprintf(\"rte_kvargs_parse() error: %s\\n\", args);\n+\t\treturn -1;\n+\t}\n+\tif (kvlist->count != n) {\n+\t\tprintf(\"invalid count value %d: %s\\n\", kvlist->count, args);\n+\t\trte_kvargs_free(kvlist);\n+\t\treturn -1;\n+\t}\n+\trte_kvargs_free(kvlist);\n+\treturn 0;\n+}\n+\n /* test a valid case */\n static int test_valid_kvargs(void)\n {\n@@ -42,6 +61,19 @@ static int test_valid_kvargs(void)\n \tconst char *args;\n \tconst char *valid_keys_list[] = { \"foo\", \"check\", NULL };\n \tconst char **valid_keys;\n+\tstatic const struct {\n+\t\tunsigned int expected;\n+\t\tconst char *input;\n+\t} valid_inputs[] = {\n+\t\t{ 2, \"foo=1,foo=\" },\n+\t\t{ 2, \"foo=1,foo=\" },\n+\t\t{ 2, \"foo=1,foo\" },\n+\t\t{ 2, \"foo=1,=2\" },\n+\t\t{ 1, \"foo=[1,2\" },\n+\t\t{ 1, \",=\" },\n+\t\t{ 1, \"foo=[\" },\n+\t};\n+\tunsigned int i;\n \n \t/* empty args is valid */\n \targs = \"\";\n@@ -191,6 +223,14 @@ static int test_valid_kvargs(void)\n \t}\n \trte_kvargs_free(kvlist);\n \n+\tvalid_keys = NULL;\n+\n+\tfor (i = 0; i < RTE_DIM(valid_inputs); ++i) {\n+\t\targs = valid_inputs[i].input;\n+\t\tif (test_kvargs_parsing(args, valid_inputs[i].expected))\n+\t\t\tgoto fail;\n+\t}\n+\n \treturn 0;\n \n  fail:\n@@ -212,12 +252,6 @@ static int test_invalid_kvargs(void)\n \t/* list of argument that should fail */\n \tconst char *args_list[] = {\n \t\t\"wrong-key=x\",     /* key not in valid_keys_list */\n-\t\t\"foo=1,foo=\",      /* empty value */\n-\t\t\"foo=1,foo\",       /* no value */\n-\t\t\"foo=1,=2\",        /* no key */\n-\t\t\"foo=[1,2\",        /* no closing bracket in value */\n-\t\t\",=\",              /* also test with a smiley */\n-\t\t\"foo=[\",           /* no value in list and no closing bracket */\n \t\tNULL };\n \tconst char **args;\n \tconst char *valid_keys_list[] = { \"foo\", \"check\", NULL };\ndiff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c\nindex 285081c86c..ffae8914cf 100644\n--- a/lib/librte_kvargs/rte_kvargs.c\n+++ b/lib/librte_kvargs/rte_kvargs.c\n@@ -5,6 +5,7 @@\n \n #include <string.h>\n #include <stdlib.h>\n+#include <stdbool.h>\n \n #include <rte_string_fns.h>\n \n@@ -13,15 +14,19 @@\n /*\n  * Receive a string with a list of arguments following the pattern\n  * key=value,key=value,... and insert them into the list.\n- * strtok() is used so the params string will be copied to be modified.\n+ * Params string will be copied to be modified.\n+ * list \"[]\" and list element splitter \",\", \"-\" is treated as value.\n+ * Supported examples:\n+ *   k1=v1,k2=v2\n+ *   k1\n+ *   k1=x[0-1]y[1,3-5,9]z\n  */\n static int\n rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)\n {\n-\tunsigned i;\n-\tchar *str;\n-\tchar *ctx1 = NULL;\n-\tchar *ctx2 = NULL;\n+\tchar *str, *start;\n+\tbool in_list = false, end_key = false, end_value = false;\n+\tbool save = false, end_pair = false;\n \n \t/* Copy the const char *params to a modifiable string\n \t * to pass to rte_strsplit\n@@ -32,36 +37,74 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)\n \n \t/* browse each key/value pair and add it in kvlist */\n \tstr = kvlist->str;\n-\twhile ((str = strtok_r(str, RTE_KVARGS_PAIRS_DELIM, &ctx1)) != NULL) {\n+\tstart = str; /* start of current key or value */\n+\twhile (1) {\n+\t\tswitch (*str) {\n+\t\tcase '=': /* End of key. */\n+\t\t\tend_key = true;\n+\t\t\tsave = true;\n+\t\t\tbreak;\n+\t\tcase ',':\n+\t\t\t/* End of value, skip comma in middle of range */\n+\t\t\tif (!in_list) {\n+\t\t\t\tif (end_key)\n+\t\t\t\t\tend_value = true;\n+\t\t\t\telse\n+\t\t\t\t\tend_key = true;\n+\t\t\t\tsave = true;\n+\t\t\t\tend_pair = true;\n+\t\t\t}\n+\t\t\tbreak;\n+\t\tcase '[': /* Start of list. */\n+\t\t\tin_list = true;\n+\t\t\tbreak;\n+\t\tcase ']': /* End of list.  */\n+\t\t\tif (in_list)\n+\t\t\t\tin_list = false;\n+\t\t\tbreak;\n+\t\tcase '\\0': /* End of string */\n+\t\t\tif (end_key)\n+\t\t\t\tend_value = true;\n+\t\t\telse\n+\t\t\t\tend_key = true;\n+\t\t\tsave = true;\n+\t\t\tend_pair = true;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n \n-\t\ti = kvlist->count;\n-\t\tif (i >= RTE_KVARGS_MAX)\n-\t\t\treturn -1;\n+\t\tif (!save) {\n+\t\t\t/* Continue if not end of key or value. */\n+\t\t\tstr++;\n+\t\t\tcontinue;\n+\t\t}\n \n-\t\tkvlist->pairs[i].key = strtok_r(str, RTE_KVARGS_KV_DELIM, &ctx2);\n-\t\tkvlist->pairs[i].value = strtok_r(NULL, RTE_KVARGS_KV_DELIM, &ctx2);\n-\t\tif (kvlist->pairs[i].key == NULL ||\n-\t\t    kvlist->pairs[i].value == NULL)\n+\t\tif (kvlist->count >= RTE_KVARGS_MAX)\n \t\t\treturn -1;\n \n-\t\t/* Detect list [a,b] to skip comma delimiter in list. */\n-\t\tstr = kvlist->pairs[i].value;\n-\t\tif (str[0] == '[') {\n-\t\t\t/* Find the end of the list. */\n-\t\t\twhile (str[strlen(str) - 1] != ']') {\n-\t\t\t\t/* Restore the comma erased by strtok_r(). */\n-\t\t\t\tif (ctx1 == NULL || ctx1[0] == '\\0')\n-\t\t\t\t\treturn -1; /* no closing bracket */\n-\t\t\t\tstr[strlen(str)] = ',';\n-\t\t\t\t/* Parse until next comma. */\n-\t\t\t\tstr = strtok_r(NULL, RTE_KVARGS_PAIRS_DELIM, &ctx1);\n-\t\t\t\tif (str == NULL)\n-\t\t\t\t\treturn -1; /* no closing bracket */\n-\t\t\t}\n+\t\tif (end_value)\n+\t\t\t/* Value parsed */\n+\t\t\tkvlist->pairs[kvlist->count].value = start;\n+\t\telse if (end_key)\n+\t\t\t/* Key parsed. */\n+\t\t\tkvlist->pairs[kvlist->count].key = start;\n+\n+\t\tif (end_pair) {\n+\t\t\tif (end_value || str != start)\n+\t\t\t\t/* Ignore empty pair. */\n+\t\t\t\tkvlist->count++;\n+\t\t\tend_key = false;\n+\t\t\tend_value = false;\n+\t\t\tend_pair = false;\n \t\t}\n \n-\t\tkvlist->count++;\n-\t\tstr = NULL;\n+\t\tif (*str == '\\0') /* End of string. */\n+\t\t\tbreak;\n+\t\t*str = '\\0';\n+\t\tstr++;\n+\t\tstart = str;\n+\t\tsave = false;\n \t}\n \n \treturn 0;\n",
    "prefixes": [
        "v8",
        "9/9"
    ]
}