Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/5476/?format=api
https://patches.dpdk.org/api/patches/5476/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1434552528-3576-5-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-5-git-send-email-maciejx.t.gajdzica@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1434552528-3576-5-git-send-email-maciejx.t.gajdzica@intel.com", "date": "2015-06-17T14:48:46", "name": "[dpdk-dev,v2,4/6] cfgfile: added line continue character '\\' to make multiline values possible", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "cbbb881e3f478da58865287e2f0dc0b683e0165a", "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-5-git-send-email-maciejx.t.gajdzica@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/5476/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/5476/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 6DD6EC4C0;\n\tWed, 17 Jun 2015 17:08:09 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id E2F37C4BE\n\tfor <dev@dpdk.org>; Wed, 17 Jun 2015 17:08:07 +0200 (CEST)", "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby fmsmga101.fm.intel.com with ESMTP; 17 Jun 2015 08:07:48 -0700", "from unknown (HELO stargo) ([10.217.248.233])\n\tby orsmga002.jf.intel.com with SMTP; 17 Jun 2015 08:07:46 -0700", "by stargo (sSMTP sendmail emulation);\n\tWed, 17 Jun 2015 17:08:30 +0200" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.13,633,1427785200\"; d=\"scan'208\";a=\"748396320\"", "From": "Maciej Gajdzica <maciejx.t.gajdzica@intel.com>", "To": "dev@dpdk.org", "Date": "Wed, 17 Jun 2015 16:48:46 +0200", "Message-Id": "<1434552528-3576-5-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 4/6] cfgfile: added line continue character\n\t'\\' to make multiline values possible", "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 | 147 ++++++++++++++++++++++++++++++++++----\n 1 file changed, 133 insertions(+), 14 deletions(-)", "diff": "diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c\nindex 2e78583..4e77ef5 100644\n--- a/lib/librte_cfgfile/rte_cfgfile.c\n+++ b/lib/librte_cfgfile/rte_cfgfile.c\n@@ -116,6 +116,122 @@ strip_comment(char *buffer, size_t len)\n \treturn len;\n }\n \n+/* Get line from file. It concatanate lines with line continue.\n+ * If *line is not NULL it must point to malloced data buffer and *len must\n+ * be the length of *line.\n+ */\n+static int\n+rte_cfgfile_getline(char **line, size_t *len, FILE *f, size_t *lineno)\n+{\n+\tchar *str = NULL;\n+\tsize_t str_len = 0;\n+\n+\tvoid *buf;\n+\tchar *line_str = NULL;\n+\tsize_t line_size = 0; /* Whole buffer size */\n+\tssize_t line_len = 0; /* Length of line_str */\n+\n+\tsize_t line_cnt = 0;\n+\tint status = 0;\n+\n+\tif (!line) {\n+\t\tstatus = EINVAL;\n+\t\tgoto error_exit;\n+\t}\n+\n+\twhile (1) {\n+\t\tline_len = getline(&line_str, &line_size, f);\n+\t\tif (line_len <= 0) {\n+\t\t\tif (!feof(f)) {\n+\t\t\t\tstatus = -EIO;\n+\t\t\t\tgoto error_exit;\n+\t\t\t}\n+\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tline_cnt++;\n+\t\t/* Replace last CR with LF */\n+\t\tif (line_len > 0 && line_str[line_len - 1] == '\\r')\n+\t\t\tline_str[line_len - 1] = '\\n';\n+\n+\t\t/* Replace last CRLF with LF */\n+\t\tif (line_len > 1 && line_str[line_len - 2] == '\\r' &&\n+\t\t\t\t\tline_str[line_len - 1] == '\\n') {\n+\t\t\tline_str[line_len - 1] = '\\0';\n+\t\t\tline_str[line_len - 2] = '\\n';\n+\t\t\tline_len -= 1;\n+\t\t}\n+\n+\t\tline_len = strip_comment(line_str, line_len);\n+\n+\t\t/* Special case for first line. */\n+\t\tif (str == NULL) {\n+\t\t\tif (line_len == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\tstr = line_str;\n+\t\t\tstr_len = line_len;\n+\n+\t\t\tline_str = NULL;\n+\t\t\tline_len = 0;\n+\t\t} else {\n+\t\t\tif (line_len == 0)\n+\t\t\t\tbreak;\n+\n+\t\t\tbuf = realloc(str, str_len + line_len + 1);\n+\t\t\tif (buf == NULL) {\n+\t\t\t\tstatus = -ENOMEM;\n+\t\t\t\tgoto error_exit;\n+\t\t\t}\n+\n+\t\t\tstr = buf;\n+\t\t\tmemcpy(&str[str_len], line_str, line_len + 1);\n+\n+\t\t\tstr_len += line_len;\n+\t\t}\n+\n+\t\t/* Check for line continue */\n+\t\tif (str_len < 2 || str[str_len - 1] != '\\n' || str[str_len - 2] != '\\\\')\n+\t\t\tbreak;\n+\n+\t\t/* Remove line continue character. */\n+\t\tstr[str_len - 1] = '\\0';\n+\t\t/* Change new line into space */\n+\t\tstr[str_len - 2] = ' ';\n+\t\tstr_len -= 1;\n+\t}\n+\n+\tif (str_len) {\n+\t\t/* Squeeze str */\n+\t\tbuf = realloc(str, str_len + 1);\n+\t\tif (buf == NULL) {\n+\t\t\tstatus = -ENOMEM;\n+\t\t\tgoto error_exit;\n+\t\t}\n+\n+\t\tfree(*line);\n+\t\t*line = buf;\n+\t}\n+\n+\tif (len)\n+\t\t*len = str_len;\n+\n+\tif (lineno)\n+\t\t*lineno += line_cnt;\n+\n+\tfree(line_str);\n+\treturn 0;\n+\n+error_exit:\n+\tprintf(\"Error: %s\\n\", strerror(status));\n+\tif (lineno)\n+\t\t*lineno += line_cnt;\n+\tfree(str);\n+\tfree(line_str);\n+\treturn status;\n+}\n+\n /**\n * Create new apty config file object.\n *\n@@ -153,9 +269,11 @@ rte_cfgfile_read(FILE *f, int flags)\n \tint allocated_entries = 0;\n \tint curr_section = -1;\n \tint curr_entry = -1;\n-\tchar buffer[256];\n-\tint lineno = 0;\n+\tchar *buffer = NULL;\n+\tsize_t len;\n+\tsize_t lineno = 0;\n \tstruct rte_cfgfile *cfg = NULL;\n+\tint status;\n \n \tif (f == NULL)\n \t\treturn NULL;\n@@ -164,15 +282,12 @@ rte_cfgfile_read(FILE *f, int flags)\n \tif (cfg == NULL)\n \t\tgoto error2;\n \n-\twhile (fgets(buffer, sizeof(buffer), f) != 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-\t\t\tprintf(\"Error line %d - no \\\\n found on string. \"\n-\t\t\t\t\t\"Check if line too long\\n\", lineno);\n-\t\t\tgoto error1;\n-\t\t}\n-\t\tlen = strip_comment(buffer, len);\n+\twhile (!feof(f)) {\n+\t\tstatus = rte_cfgfile_getline(&buffer, &len, f, &lineno);\n+\t\tif (status)\n+\t\t\tbreak;\n+\t\telse if (!len)\n+\t\t\tcontinue;\n \n \t\tlen = _strip(buffer, len);\n \t\tif (buffer[0] != '[' && memchr(buffer, '=', len) == NULL)\n@@ -182,7 +297,7 @@ rte_cfgfile_read(FILE *f, int flags)\n \t\t\t/* section heading line */\n \t\t\tchar *end = memchr(buffer, ']', len);\n \t\t\tif (end == NULL) {\n-\t\t\t\tprintf(\"Error line %d - no terminating '['\"\n+\t\t\t\tprintf(\"Error line %zu - no terminating '['\"\n \t\t\t\t\t\"character found\\n\", lineno);\n \t\t\t\tgoto error1;\n \t\t\t}\n@@ -227,7 +342,7 @@ rte_cfgfile_read(FILE *f, int flags)\n \t\t} else {\n \t\t\t/* value line */\n \t\t\tif (curr_section < 0) {\n-\t\t\t\tprintf(\"Error line %d - value outside of\"\n+\t\t\t\tprintf(\"Error line %zu - value outside of\"\n \t\t\t\t\t\"section\\n\", lineno);\n \t\t\t\tgoto error1;\n \t\t\t}\n@@ -237,7 +352,7 @@ rte_cfgfile_read(FILE *f, int flags)\n \t\t\tchar *split[2];\n \t\t\tif (rte_strsplit(buffer, sizeof(buffer), split, 2, '=')\n \t\t\t\t!= 2) {\n-\t\t\t\tprintf(\"Error at line %d - cannot split \"\n+\t\t\t\tprintf(\"Error at line %zu - cannot split \"\n \t\t\t\t\t\"string\\n\", lineno);\n \t\t\t\tgoto error1;\n \t\t\t}\n@@ -275,6 +390,10 @@ rte_cfgfile_read(FILE *f, int flags)\n \t\t\t\tsizeof(entry->value)));\n \t\t}\n \t}\n+\n+\tif (status)\n+\t\tgoto error1;\n+\n \tfclose(f);\n \tcfg->flags = flags;\n \tcfg->num_sections = curr_section + 1;\n", "prefixes": [ "dpdk-dev", "v2", "4/6" ] }{ "id": 5476, "url": "