Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/111555/?format=api
http://patches.dpdk.org/api/patches/111555/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220520151240.139566-2-bruce.richardson@intel.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": "<20220520151240.139566-2-bruce.richardson@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220520151240.139566-2-bruce.richardson@intel.com", "date": "2022-05-20T15:12:39", "name": "[v2,1/2] cmdline: add function to verify valid commands", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "9d832de03ed7782dca2fb8c7e70e58be2d165b25", "submitter": { "id": 20, "url": "http://patches.dpdk.org/api/people/20/?format=api", "name": "Bruce Richardson", "email": "bruce.richardson@intel.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/20220520151240.139566-2-bruce.richardson@intel.com/mbox/", "series": [ { "id": 23069, "url": "http://patches.dpdk.org/api/series/23069/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=23069", "date": "2022-05-20T15:12:38", "name": "fix uncallable unit tests (Bugzilla 1002)", "version": 2, "mbox": "http://patches.dpdk.org/series/23069/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/111555/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/111555/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 C9793A0503;\n\tFri, 20 May 2022 17:12:58 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 861D142824;\n\tFri, 20 May 2022 17:12:56 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id 69063427F2;\n Fri, 20 May 2022 17:12:54 +0200 (CEST)", "from orsmga008.jf.intel.com ([10.7.209.65])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 20 May 2022 08:12:54 -0700", "from silpixa00401385.ir.intel.com (HELO\n silpixa00401385.ger.corp.intel.com.) ([10.237.223.87])\n by orsmga008.jf.intel.com with ESMTP; 20 May 2022 08:12:52 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1653059574; x=1684595574;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=trK68Cj9Vi3JnvQxcGoS3yQpelkgnzin7xn7oTHPI/M=;\n b=MJjoxzQ2SKpi+fw/hX+CrrxPgfIe19Th7Hd4d+a4dTi5NGRrYY4VYPxx\n s1+CVMLSoOmThPQ7UR3e1jjLjYAZ5Ns7wuTTObt0m+lz2UYoSUiYfe40m\n jMz8VuqGgCvyZDFcUQ31IBgBNOsQHZI/hlzBU2mUvbjMZKK4lDk3Es7GJ\n JBP+3W5IvM1vgL4PKbFsitZ8+rLDGyR1UyjyNqW04zbwNEkaVpFwbDicH\n e+Wi3HtKLilflOtuWHTz7Flb2cJMVIKTxSkqoPgKKNG5qplUmk+WhWhRc\n YID9NFXEdN7VtqW6XeDvS/OlCMciw6SegFymXRpAY8dyXHQSD9zsMu7li A==;", "X-IronPort-AV": [ "E=McAfee;i=\"6400,9594,10353\"; a=\"260216945\"", "E=Sophos;i=\"5.91,239,1647327600\"; d=\"scan'208\";a=\"260216945\"", "E=Sophos;i=\"5.91,239,1647327600\"; d=\"scan'208\";a=\"599263751\"" ], "X-ExtLoop1": "1", "From": "Bruce Richardson <bruce.richardson@intel.com>", "To": "dev@dpdk.org", "Cc": "stable@dpdk.org, weiyuanx.li@intel.com,\n Bruce Richardson <bruce.richardson@intel.com>,\n Olivier Matz <olivier.matz@6wind.com>, Ray Kinsella <mdr@ashroe.eu>", "Subject": "[PATCH v2 1/2] cmdline: add function to verify valid commands", "Date": "Fri, 20 May 2022 16:12:39 +0100", "Message-Id": "<20220520151240.139566-2-bruce.richardson@intel.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220520151240.139566-1-bruce.richardson@intel.com>", "References": "<20220520145631.137962-1-bruce.richardson@intel.com>\n <20220520151240.139566-1-bruce.richardson@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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 cmdline library cmdline_parse() function parses a command and\nexecutes the action automatically too. The cmdline_valid_buffer function\nalso uses this function to validate commands, meaning that there is no\nfunction to validate a command as ok without executing it.\n\nTo fix this omission, we extract the body of cmdline_parse into a new\nstatic inline function with an extra parameter to indicate whether the\naction should be performed or not. Then we create two wrappers around\nthat - a replacement for the existing cmdline_parse function where the\nextra parameter is \"true\" to execute the command, and a new function\n\"cmdline_parse_check\" which passes the parameter as \"false\" to perform\ncmdline validation only.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/cmdline/cmdline_parse.c | 20 +++++++++++++++++---\n lib/cmdline/cmdline_parse.h | 17 +++++++++++++++--\n lib/cmdline/version.map | 3 +++\n 3 files changed, 35 insertions(+), 5 deletions(-)", "diff": "diff --git a/lib/cmdline/cmdline_parse.c b/lib/cmdline/cmdline_parse.c\nindex 349ec87bd7..b7fdc67ae5 100644\n--- a/lib/cmdline/cmdline_parse.c\n+++ b/lib/cmdline/cmdline_parse.c\n@@ -7,6 +7,7 @@\n #include <stdio.h>\n #include <errno.h>\n #include <string.h>\n+#include <stdbool.h>\n \n #include <rte_string_fns.h>\n \n@@ -182,8 +183,8 @@ match_inst(cmdline_parse_inst_t *inst, const char *buf,\n }\n \n \n-int\n-cmdline_parse(struct cmdline *cl, const char * buf)\n+static inline int\n+__cmdline_parse(struct cmdline *cl, const char *buf, bool call_fn)\n {\n \tunsigned int inst_num=0;\n \tcmdline_parse_inst_t *inst;\n@@ -284,7 +285,8 @@ cmdline_parse(struct cmdline *cl, const char * buf)\n \n \t/* call func */\n \tif (f) {\n-\t\tf(result.buf, cl, data);\n+\t\tif (call_fn)\n+\t\t\tf(result.buf, cl, data);\n \t}\n \n \t/* no match */\n@@ -296,6 +298,18 @@ cmdline_parse(struct cmdline *cl, const char * buf)\n \treturn linelen;\n }\n \n+int\n+cmdline_parse(struct cmdline *cl, const char *buf)\n+{\n+\treturn __cmdline_parse(cl, buf, true);\n+}\n+\n+int\n+cmdline_parse_check(struct cmdline *cl, const char *buf)\n+{\n+\treturn __cmdline_parse(cl, buf, false);\n+}\n+\n int\n cmdline_complete(struct cmdline *cl, const char *buf, int *state,\n \t\t char *dst, unsigned int size)\ndiff --git a/lib/cmdline/cmdline_parse.h b/lib/cmdline/cmdline_parse.h\nindex e4d802fff7..6dd210d843 100644\n--- a/lib/cmdline/cmdline_parse.h\n+++ b/lib/cmdline/cmdline_parse.h\n@@ -7,6 +7,8 @@\n #ifndef _CMDLINE_PARSE_H_\n #define _CMDLINE_PARSE_H_\n \n+#include <rte_compat.h>\n+\n #ifdef __cplusplus\n extern \"C\" {\n #endif\n@@ -149,11 +151,22 @@ typedef cmdline_parse_inst_t *cmdline_parse_ctx_t;\n * argument buf must ends with \"\\n\\0\". The function returns\n * CMDLINE_PARSE_AMBIGUOUS, CMDLINE_PARSE_NOMATCH or\n * CMDLINE_PARSE_BAD_ARGS on error. Else it calls the associated\n- * function (defined in the context) and returns 0\n- * (CMDLINE_PARSE_SUCCESS).\n+ * function (defined in the context) and returns the parsed line length (>= 0)\n */\n int cmdline_parse(struct cmdline *cl, const char *buf);\n \n+/**\n+ * Try to parse a buffer according to the specified context, but do not\n+ * perform any function calls if parse is successful.\n+ *\n+ * The argument buf must ends with \"\\n\\0\".\n+ * The function returns CMDLINE_PARSE_AMBIGUOUS, CMDLINE_PARSE_NOMATCH or\n+ * CMDLINE_PARSE_BAD_ARGS on error and returns the parsed line length (>=0).\n+ * on successful parse\n+ */\n+__rte_experimental\n+int cmdline_parse_check(struct cmdline *cl, const char *buf);\n+\n /**\n * complete() must be called with *state==0 (try to complete) or\n * with *state==-1 (just display choices), then called without\ndiff --git a/lib/cmdline/version.map b/lib/cmdline/version.map\nindex b9bbb87510..fc7fdd6ea4 100644\n--- a/lib/cmdline/version.map\n+++ b/lib/cmdline/version.map\n@@ -81,5 +81,8 @@ EXPERIMENTAL {\n \trdline_get_history_buffer_size;\n \trdline_get_opaque;\n \n+\t# added in 22.07\n+\tcmdline_parse_check;\n+\n \tlocal: *;\n };\n", "prefixes": [ "v2", "1/2" ] }{ "id": 111555, "url": "