Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/5477/?format=api
https://patches.dpdk.org/api/patches/5477/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1434552528-3576-4-git-send-email-maciejx.t.gajdzica@intel.com/", "project": { "id": 1, "url": "https://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": "<1434552528-3576-4-git-send-email-maciejx.t.gajdzica@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1434552528-3576-4-git-send-email-maciejx.t.gajdzica@intel.com", "date": "2015-06-17T14:48:45", "name": "[dpdk-dev,v2,3/6] cfgfile: split rte_cfgfile_load to smaller functions", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "a75e897453e116f7b27dbf8240e1c35dfbb74cc7", "submitter": { "id": 18, "url": "https://patches.dpdk.org/api/people/18/?format=api", "name": "Maciej Gajdzica", "email": "maciejx.t.gajdzica@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1434552528-3576-4-git-send-email-maciejx.t.gajdzica@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/5477/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/5477/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id CEBD3C4D0;\n\tWed, 17 Jun 2015 17:08:50 +0200 (CEST)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id A8B22C4CC\n\tfor <dev@dpdk.org>; Wed, 17 Jun 2015 17:08:49 +0200 (CEST)", "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga103.jf.intel.com with ESMTP; 17 Jun 2015 08:07:39 -0700", "from unknown (HELO stargo) ([10.217.248.233])\n\tby orsmga002.jf.intel.com with SMTP; 17 Jun 2015 08:07:36 -0700", "by stargo (sSMTP sendmail emulation);\n\tWed, 17 Jun 2015 17:04:06 +0200" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.13,633,1427785200\"; d=\"scan'208\";a=\"748396119\"", "From": "Maciej Gajdzica <maciejx.t.gajdzica@intel.com>", "To": "dev@dpdk.org", "Date": "Wed, 17 Jun 2015 16:48:45 +0200", "Message-Id": "<1434552528-3576-4-git-send-email-maciejx.t.gajdzica@intel.com>", "X-Mailer": "git-send-email 1.9.1", "In-Reply-To": "<1434552528-3576-1-git-send-email-maciejx.t.gajdzica@intel.com>", "References": "<1434552528-3576-1-git-send-email-maciejx.t.gajdzica@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 3/6] cfgfile: split rte_cfgfile_load to\n\tsmaller functions", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Pawel Wodkowski <pawelx.wodkowski@intel.com>\n\nSigned-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>\n---\n lib/librte_cfgfile/rte_cfgfile.c | 93 ++++++++++++++++++++++++++++++++------\n 1 file changed, 80 insertions(+), 13 deletions(-)", "diff": "diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c\nindex b81c273..2e78583 100644\n--- a/lib/librte_cfgfile/rte_cfgfile.c\n+++ b/lib/librte_cfgfile/rte_cfgfile.c\n@@ -37,6 +37,8 @@\n #include <ctype.h>\n #include <rte_string_fns.h>\n \n+#include <rte_common.h>\n+\n #include \"rte_cfgfile.h\"\n \n struct rte_cfgfile_section {\n@@ -85,8 +87,67 @@ _strip(char *str, unsigned len)\n \treturn newlen;\n }\n \n-struct rte_cfgfile *\n-rte_cfgfile_load(const char *filename, int flags)\n+static size_t\n+strip_comment(char *buffer, size_t len)\n+{\n+\tchar *pos = memchr(buffer, ';', len);\n+\n+\tif (pos == NULL)\n+\t\treturn len;\n+\n+\tif (len == 1) {\n+\t\t*pos = '\\0';\n+\t\treturn 0;\n+\t}\n+\n+\tif (buffer[len - 1] == '\\n') {\n+\t\tif (buffer[len - 2] == '\\\\') {\n+\t\t\tpos[0] = '\\\\';\n+\t\t\tpos[1] = '\\n';\n+\t\t\tpos[2] = '\\0';\n+\t\t\tlen = pos - buffer + 2;\n+\t\t} else {\n+\t\t\tpos[0] = '\\n';\n+\t\t\tpos[1] = '\\0';\n+\t\t\tlen = pos - buffer + 1;\n+\t\t}\n+\t}\n+\n+\treturn len;\n+}\n+\n+/**\n+ * Create new apty config file object.\n+ *\n+ * @param flags\n+ * Config file flags, Reserved for future use. Must be set to 0.\n+ * @return\n+ * Handle to configuration file\n+ */\n+static struct rte_cfgfile *\n+rte_cfgfile_create(__rte_unused int flags, int allocated_sections)\n+{\n+\tstruct rte_cfgfile *cfg = malloc(sizeof(*cfg) + sizeof(cfg->sections[0]) *\n+\t\tallocated_sections);\n+\n+\tif (cfg != NULL)\n+\t\tmemset(cfg->sections, 0, sizeof(cfg->sections[0]) * allocated_sections);\n+\n+\treturn cfg;\n+}\n+\n+/**\n+* Open config *file*.\n+*\n+* @param file\n+* Config stream to read.\n+* @param flags\n+* Config file flags, Reserved for future use. Must be set to 0.\n+* @return\n+* Handle to configuration file\n+*/\n+static struct rte_cfgfile *\n+rte_cfgfile_read(FILE *f, int flags)\n {\n \tint allocated_sections = CFG_ALLOC_SECTION_BATCH;\n \tint allocated_entries = 0;\n@@ -96,19 +157,14 @@ rte_cfgfile_load(const char *filename, int flags)\n \tint lineno = 0;\n \tstruct rte_cfgfile *cfg = NULL;\n \n-\tFILE *f = fopen(filename, \"r\");\n \tif (f == NULL)\n \t\treturn NULL;\n \n-\tcfg = malloc(sizeof(*cfg) + sizeof(cfg->sections[0]) *\n-\t\tallocated_sections);\n+\tcfg = rte_cfgfile_create(flags, allocated_sections);\n \tif (cfg == NULL)\n \t\tgoto error2;\n \n-\tmemset(cfg->sections, 0, sizeof(cfg->sections[0]) * allocated_sections);\n-\n \twhile (fgets(buffer, sizeof(buffer), f) != NULL) {\n-\t\tchar *pos = NULL;\n \t\tsize_t len = strnlen(buffer, sizeof(buffer));\n \t\tlineno++;\n \t\tif ((len >= sizeof(buffer) - 1) && (buffer[len-1] != '\\n')) {\n@@ -116,11 +172,7 @@ rte_cfgfile_load(const char *filename, int flags)\n \t\t\t\t\t\"Check if line too long\\n\", lineno);\n \t\t\tgoto error1;\n \t\t}\n-\t\tpos = memchr(buffer, ';', sizeof(buffer));\n-\t\tif (pos != NULL) {\n-\t\t\t*pos = '\\0';\n-\t\t\tlen = pos - buffer;\n-\t\t}\n+\t\tlen = strip_comment(buffer, len);\n \n \t\tlen = _strip(buffer, len);\n \t\tif (buffer[0] != '[' && memchr(buffer, '=', len) == NULL)\n@@ -238,6 +290,21 @@ error2:\n \treturn NULL;\n }\n \n+struct rte_cfgfile *\n+rte_cfgfile_load(const char *filename, int flags)\n+{\n+\tstruct rte_cfgfile *cfg = NULL;\n+\tFILE *file = fopen(filename, \"r\");\n+\n+\tif (file == NULL)\n+\t\treturn NULL;\n+\n+\tcfg = rte_cfgfile_read(file, flags);\n+\tfclose(file);\n+\n+\treturn cfg;\n+}\n+\n \n int rte_cfgfile_close(struct rte_cfgfile *cfg)\n {\n", "prefixes": [ "dpdk-dev", "v2", "3/6" ] }{ "id": 5477, "url": "