get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 136887,
    "url": "http://patches.dpdk.org/api/patches/136887/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240220035840.32978-5-fengchengwen@huawei.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": "<20240220035840.32978-5-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240220035840.32978-5-fengchengwen@huawei.com",
    "date": "2024-02-20T03:58:40",
    "name": "[4/4] cfgfile: add unique name flag",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "3886dd852dd2bee724f4a5503e96614689e9bee0",
    "submitter": {
        "id": 2146,
        "url": "http://patches.dpdk.org/api/people/2146/?format=api",
        "name": "fengchengwen",
        "email": "fengchengwen@huawei.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240220035840.32978-5-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 31143,
            "url": "http://patches.dpdk.org/api/series/31143/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31143",
            "date": "2024-02-20T03:58:36",
            "name": "cfgfile: enhance error detecting",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/31143/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/136887/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/136887/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 62ED543AD8;\n\tTue, 20 Feb 2024 05:00:35 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2B5C24069F;\n\tTue, 20 Feb 2024 05:00:15 +0100 (CET)",
            "from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191])\n by mails.dpdk.org (Postfix) with ESMTP id 0DACA40691\n for <dev@dpdk.org>; Tue, 20 Feb 2024 05:00:12 +0100 (CET)",
            "from mail.maildlp.com (unknown [172.19.163.17])\n by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tf5CW0ddDz1FL5V;\n Tue, 20 Feb 2024 11:55:19 +0800 (CST)",
            "from dggpeml500024.china.huawei.com (unknown [7.185.36.10])\n by mail.maildlp.com (Postfix) with ESMTPS id C11911A0178;\n Tue, 20 Feb 2024 12:00:05 +0800 (CST)",
            "from localhost.localdomain (10.50.165.33) by\n dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.35; Tue, 20 Feb 2024 12:00:05 +0800"
        ],
        "From": "Chengwen Feng <fengchengwen@huawei.com>",
        "To": "<thomas@monjalon.net>",
        "CC": "<dev@dpdk.org>, <cristian.dumitrescu@intel.com>",
        "Subject": "[PATCH 4/4] cfgfile: add unique name flag",
        "Date": "Tue, 20 Feb 2024 03:58:40 +0000",
        "Message-ID": "<20240220035840.32978-5-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20240220035840.32978-1-fengchengwen@huawei.com>",
        "References": "<20240220035840.32978-1-fengchengwen@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.50.165.33]",
        "X-ClientProxiedBy": "dggems705-chm.china.huawei.com (10.3.19.182) To\n dggpeml500024.china.huawei.com (7.185.36.10)",
        "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"
    },
    "content": "The cfgfile supports duplicate section name and entry name when parsing\nconfig file, which may confused and hard to debug when accidentally set\nduplicate name.\n\nSo add unique name flag, it will treat as error if encounter duplicate\nsection name or entry name.\n\nCc: stable@dpdk.org\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n lib/cfgfile/rte_cfgfile.c | 32 +++++++++++++++++++++++---------\n lib/cfgfile/rte_cfgfile.h |  7 +++++++\n 2 files changed, 30 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/lib/cfgfile/rte_cfgfile.c b/lib/cfgfile/rte_cfgfile.c\nindex ad9314dc14..9e901b0977 100644\n--- a/lib/cfgfile/rte_cfgfile.c\n+++ b/lib/cfgfile/rte_cfgfile.c\n@@ -102,8 +102,8 @@ _get_section(struct rte_cfgfile *cfg, const char *sectionname)\n }\n \n static int\n-_add_entry(struct rte_cfgfile_section *section, const char *entryname,\n-\t\tconst char *entryvalue)\n+_add_entry(struct rte_cfgfile *cfg, struct rte_cfgfile_section *section,\n+\t   const char *entryname, const char *entryvalue, bool check_dup)\n {\n \tint name_len, value_len;\n \n@@ -115,6 +115,14 @@ _add_entry(struct rte_cfgfile_section *section, const char *entryname,\n \t\treturn -EINVAL;\n \t}\n \n+\tif (check_dup) {\n+\t\tif (rte_cfgfile_has_entry(cfg, section->name, entryname) != 0) {\n+\t\t\tCFG_LOG(ERR, \"duplicate entry name %s in section %s\",\n+\t\t\t\tentryname, section->name);\n+\t\t\treturn -EEXIST;\n+\t\t}\n+\t}\n+\n \t/* resize entry structure if we don't have room for more entries */\n \tif (section->num_entries == section->allocated_entries) {\n \t\tstruct rte_cfgfile_entry *n_entries = realloc(\n@@ -264,8 +272,9 @@ rte_cfgfile_load_with_params(const char *filename, int flags,\n \t\t\tif (cfg->num_sections == 0)\n \t\t\t\tgoto error1;\n \n-\t\t\tret = _add_entry(&cfg->sections[cfg->num_sections - 1],\n-\t\t\t\t\t split[0], split[1]);\n+\t\t\tret = _add_entry(cfg, &cfg->sections[cfg->num_sections - 1],\n+\t\t\t\t\t split[0], split[1],\n+\t\t\t\t\t !!(flags & CFG_FLAG_UNIQUE_NAME));\n \t\t\tif (ret != 0)\n \t\t\t\tgoto error1;\n \t\t}\n@@ -286,7 +295,8 @@ rte_cfgfile_create(int flags)\n \tstruct rte_cfgfile *cfg;\n \n \t/* future proof flags usage */\n-\tif (flags & ~(CFG_FLAG_GLOBAL_SECTION | CFG_FLAG_EMPTY_VALUES))\n+\tif (flags & ~(CFG_FLAG_GLOBAL_SECTION | CFG_FLAG_EMPTY_VALUES |\n+\t\t      CFG_FLAG_UNIQUE_NAME))\n \t\treturn NULL;\n \n \tcfg = malloc(sizeof(*cfg));\n@@ -356,6 +366,13 @@ rte_cfgfile_add_section(struct rte_cfgfile *cfg, const char *sectionname)\n \t\treturn -EINVAL;\n \t}\n \n+\tif (cfg->flags & CFG_FLAG_UNIQUE_NAME) {\n+\t\tif (rte_cfgfile_has_section(cfg, sectionname) != 0) {\n+\t\t\tCFG_LOG(ERR, \"duplicate section name %s\", sectionname);\n+\t\t\treturn -EEXIST;\n+\t\t}\n+\t}\n+\n \t/* resize overall struct if we don't have room for more\tsections */\n \tif (cfg->num_sections == cfg->allocated_sections) {\n \n@@ -396,16 +413,13 @@ int rte_cfgfile_add_entry(struct rte_cfgfile *cfg,\n \t\t\t|| (entryvalue == NULL))\n \t\treturn -EINVAL;\n \n-\tif (rte_cfgfile_has_entry(cfg, sectionname, entryname) != 0)\n-\t\treturn -EEXIST;\n-\n \t/* search for section pointer by sectionname */\n \tstruct rte_cfgfile_section *curr_section = _get_section(cfg,\n \t\t\t\t\t\t\t\tsectionname);\n \tif (curr_section == NULL)\n \t\treturn -EINVAL;\n \n-\tret = _add_entry(curr_section, entryname, entryvalue);\n+\tret = _add_entry(cfg, curr_section, entryname, entryvalue, true);\n \n \treturn ret;\n }\ndiff --git a/lib/cfgfile/rte_cfgfile.h b/lib/cfgfile/rte_cfgfile.h\nindex 232c65c77b..74057c1b73 100644\n--- a/lib/cfgfile/rte_cfgfile.h\n+++ b/lib/cfgfile/rte_cfgfile.h\n@@ -56,6 +56,13 @@ enum {\n \t * be zero length (e.g., \"key=\").\n \t */\n \tCFG_FLAG_EMPTY_VALUES = 2,\n+\n+\t/**\n+\t * Indicates that file should have unique section name AND unique\n+\t * entry's name. If a duplicate name is detected, the operation will\n+\t * return error.\n+\t */\n+\tCFG_FLAG_UNIQUE_NAME = 4,\n };\n /**@} */\n \n",
    "prefixes": [
        "4/4"
    ]
}