get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 138435,
    "url": "https://patches.dpdk.org/api/patches/138435/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20240315151407.7517-1-stephen@networkplumber.org/",
    "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": "<20240315151407.7517-1-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240315151407.7517-1-stephen@networkplumber.org",
    "date": "2024-03-15T15:14:06",
    "name": "windows: make getopt functions have const properties",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d7556fa1003a4002c0d396197e83fb485ad51e74",
    "submitter": {
        "id": 27,
        "url": "https://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20240315151407.7517-1-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31536,
            "url": "https://patches.dpdk.org/api/series/31536/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=31536",
            "date": "2024-03-15T15:14:06",
            "name": "windows: make getopt functions have const properties",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/31536/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/138435/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/138435/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 373B643CBB;\n\tFri, 15 Mar 2024 16:14:20 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 059D8402C7;\n\tFri, 15 Mar 2024 16:14:20 +0100 (CET)",
            "from mail-pg1-f171.google.com (mail-pg1-f171.google.com\n [209.85.215.171])\n by mails.dpdk.org (Postfix) with ESMTP id 8527A402C3\n for <dev@dpdk.org>; Fri, 15 Mar 2024 16:14:18 +0100 (CET)",
            "by mail-pg1-f171.google.com with SMTP id\n 41be03b00d2f7-5d42e7ab8a9so1457118a12.3\n for <dev@dpdk.org>; Fri, 15 Mar 2024 08:14:18 -0700 (PDT)",
            "from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141])\n by smtp.gmail.com with ESMTPSA id\n so10-20020a17090b1f8a00b0029df6fd2780sm1488216pjb.9.2024.03.15.08.14.16\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 15 Mar 2024 08:14:16 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710515657;\n x=1711120457; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=S9ZV1Svnfl3mHFTUa47td7nQM42fpTruIk7rWAlyvWI=;\n b=M+6khoEWb4nN9DIriJ47Hp8nAK8G0WDc2ADvjFj6LEUF/RxANqK6sagASG2UQroV0B\n cX7sZo8PYGEaANJczmQuTLqzziz3H0Xdiv7Kf7MzXHX23ElcNwRnc/4BF+1BMUTD+CQI\n 7adQwTW8mRiCizvkGuomXkya2QyrjVbz8xcBEMfVBQgwo7fLz0uhNdmykZEE4O7N0+Om\n CPxvMxmMMAbN/MRtvk9m6Vi1aQPMyca00ae+QJyim8sgHchrhm3eSmCnRtW82Td+nzMc\n YqamfGuRY59/rz7dx7XFpeJ3hEDCeNDizp7g1gD17vKJ008M96ntj3EwzPDRb4rHfEw4\n wQ+g==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1710515657; x=1711120457;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=S9ZV1Svnfl3mHFTUa47td7nQM42fpTruIk7rWAlyvWI=;\n b=BHlhUP8Rbs7lGpYkOTEQOPQd2KVQYNvernNt42tNm4exqAHtvaFq8k30/FbX7sFjsB\n 7KqBoIHzq9koDFFnYToGF/64cBwLO8guUI1CB0W+2bis+k0WtI/b7mo0ZBMw+vlDrUm9\n Jvmt8hLpygrZlNNhPuFbw8AT3amHpuyiAxSAQU2tz1N0Km7E+wZy+VBRUywdWuRuadxF\n g6LvjtOyF9rgYuS8KAMMVp7MF9YoSjH2Kc2yfUVRqHf98q+sliPnG3AmW3ljV2A5QnkI\n IOOPQZgUmgp8E1T7PKnMs4mQIZHpbIuo/NmwHPvoec1kIc2MyzuHDaTx1iBgfyoTqerw\n 3sTA==",
        "X-Gm-Message-State": "AOJu0YwtpV9PNvV3pTguHnKkxhbtvkEq5JZ0YrzRR7L/TSE0RV/xTMt5\n VxmuuFqA9yM7pMiswR6jIxHIMwjSxw+IGvAgsHnIyPhK0ej2ilrVloV5ce04sDg7Atu5EdZ+2S+\n 1",
        "X-Google-Smtp-Source": "\n AGHT+IGK7ZWX2QiBDtYoqCu65/upboCNvx1rnmVbmGEWAgnKIf13jikZpsfsJhZm40oN+jCoqjhWxA==",
        "X-Received": "by 2002:a17:90b:151:b0:29b:a4d9:b125 with SMTP id\n em17-20020a17090b015100b0029ba4d9b125mr4591461pjb.30.1710515657215;\n Fri, 15 Mar 2024 08:14:17 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,\n Tyler Retzlaff <roretzla@linux.microsoft.com>,\n Pallavi Kadam <pallavi.kadam@intel.com>",
        "Subject": "[PATCH] windows: make getopt functions have const properties",
        "Date": "Fri, 15 Mar 2024 08:14:06 -0700",
        "Message-ID": "<20240315151407.7517-1-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "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": "Having different prototypes on different platforms can lead\nto lots of unnecessary workarounds.  Looks like the version of\ngetopt used from windows was based on an older out of date\nversion from FreeBSD.\n\nThis patch changes getopt, getopt_long, etc to have the same const\nattributes as Linux and FreeBSD. The changes are derived from\nthe current FreeBSD version of getopt_long.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/eal/windows/getopt.c         |  23 +-\n lib/eal/windows/getopt.c.orig    | 469 +++++++++++++++++++++++++++++++\n lib/eal/windows/include/getopt.h |   8 +-\n 3 files changed, 485 insertions(+), 15 deletions(-)\n create mode 100644 lib/eal/windows/getopt.c.orig",
    "diff": "diff --git a/lib/eal/windows/getopt.c b/lib/eal/windows/getopt.c\nindex a1f51c6c2318..50ff71b9300d 100644\n--- a/lib/eal/windows/getopt.c\n+++ b/lib/eal/windows/getopt.c\n@@ -20,7 +20,7 @@\n #include <string.h>\n #include <stdlib.h>\n \n-const char    *optarg;\t\t/* argument associated with option */\n+char    *optarg;\t\t/* argument associated with option */\n int\topterr = 1;\t\t/* if error message should be printed */\n int\toptind = 1;\t\t/* index into parent argv vector */\n int\toptopt = '?';\t\t/* character checked for validity */\n@@ -39,9 +39,9 @@ static void pass(const char *a) {(void) a; }\n #define\tBADARG\t\t((*options == ':') ? (int)':' : (int)'?')\n #define\tINORDER\t\t1\n \n-#define\tEMSG\t\t\"\"\n+static char EMSG[] = \"\";\n \n-static const char *place = EMSG; /* option letter processing */\n+static char *place = EMSG; /* option letter processing */\n \n /* XXX: set optreset to 1 rather than these two */\n static int nonopt_start = -1; /* first non option argument (for permute) */\n@@ -80,7 +80,7 @@ gcd(int a, int b)\n  */\n static void\n permute_args(int panonopt_start, int panonopt_end, int opt_end,\n-\tchar **nargv)\n+\tchar * const *nargv)\n {\n \tint cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;\n \tchar *swap;\n@@ -101,11 +101,12 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,\n \t\t\t\tpos -= nnonopts;\n \t\t\telse\n \t\t\t\tpos += nopts;\n+\n \t\t\tswap = nargv[pos];\n \t\t\t/* LINTED const cast */\n-\t\t\t((char **) nargv)[pos] = nargv[cstart];\n+\t\t\t((char **)(uintptr_t)nargv)[pos] = nargv[cstart];\n \t\t\t/* LINTED const cast */\n-\t\t\t((char **)nargv)[cstart] = swap;\n+\t\t\t((char **)(uintptr_t)nargv)[cstart] = swap;\n \t\t}\n \t}\n }\n@@ -116,7 +117,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,\n  * Returns -1 if short_too is set and the option does not match long_options.\n  */\n static int\n-parse_long_options(char **nargv, const char *options,\n+parse_long_options(char * const *nargv, const char *options,\n \tconst struct option *long_options, int *idx, int short_too)\n {\n \tconst char *current_argv;\n@@ -236,7 +237,7 @@ parse_long_options(char **nargv, const char *options,\n  *\tParse argc/argv argument vector.  Called by user level routines.\n  */\n static int\n-getopt_internal(int nargc, char **nargv, const char *options,\n+getopt_internal(int nargc, char *const nargv[], const char *options,\n \tconst struct option *long_options, int *idx, int flags)\n {\n \tchar *oli;\t\t\t\t/* option letter list index */\n@@ -434,7 +435,7 @@ getopt_internal(int nargc, char **nargv, const char *options,\n  *\tParse argc/argv argument vector.\n  */\n int\n-getopt(int nargc, char *nargv[], const char *options)\n+getopt(int nargc, char *const nargv[], const char *options)\n {\n \treturn getopt_internal(nargc, nargv, options, NULL, NULL,\n \t\t\t       FLAG_PERMUTE);\n@@ -445,7 +446,7 @@ getopt(int nargc, char *nargv[], const char *options)\n  *\tParse argc/argv argument vector.\n  */\n int\n-getopt_long(int nargc, char *nargv[], const char *options,\n+getopt_long(int nargc, char *const nargv[], const char *options,\n \tconst struct option *long_options, int *idx)\n {\n \n@@ -458,7 +459,7 @@ getopt_long(int nargc, char *nargv[], const char *options,\n  *\tParse argc/argv argument vector.\n  */\n int\n-getopt_long_only(int nargc, char *nargv[], const char *options,\n+getopt_long_only(int nargc, char *const nargv[], const char *options,\n \tconst struct option *long_options, int *idx)\n {\n \ndiff --git a/lib/eal/windows/getopt.c.orig b/lib/eal/windows/getopt.c.orig\nnew file mode 100644\nindex 000000000000..a1f51c6c2318\n--- /dev/null\n+++ b/lib/eal/windows/getopt.c.orig\n@@ -0,0 +1,469 @@\n+/* SPDX-License-Identifier: ISC AND BSD-2-Clause\n+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>\n+ *\n+ * Sponsored in part by the Defense Advanced Research Projects\n+ * Agency (DARPA) and Air Force Research Laboratory, Air Force\n+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.\n+ */\n+/*\n+ * Copyright (c) 2000 The NetBSD Foundation, Inc.\n+ * All rights reserved.\n+ *\n+ * This code is derived from software contributed to The NetBSD Foundation\n+ * by Dieter Baron and Thomas Klausner.\n+ */\n+\n+#include <getopt.h>\n+\n+#ifdef NEED_USUAL_GETOPT\n+\n+#include <string.h>\n+#include <stdlib.h>\n+\n+const char    *optarg;\t\t/* argument associated with option */\n+int\topterr = 1;\t\t/* if error message should be printed */\n+int\toptind = 1;\t\t/* index into parent argv vector */\n+int\toptopt = '?';\t\t/* character checked for validity */\n+\n+static void pass(const char *a) {(void) a; }\n+#define warnx(a, ...) pass(a)\n+\n+#define PRINT_ERROR\t((opterr) && (*options != ':'))\n+\n+#define FLAG_PERMUTE\t0x01\t/* permute non-options to the end of argv */\n+#define FLAG_ALLARGS\t0x02\t/* treat non-options as args to option \"-1\" */\n+#define FLAG_LONGONLY\t0x04\t/* operate as getopt_long_only */\n+\n+/* return values */\n+#define\tBADCH\t\t((int)'?')\n+#define\tBADARG\t\t((*options == ':') ? (int)':' : (int)'?')\n+#define\tINORDER\t\t1\n+\n+#define\tEMSG\t\t\"\"\n+\n+static const char *place = EMSG; /* option letter processing */\n+\n+/* XXX: set optreset to 1 rather than these two */\n+static int nonopt_start = -1; /* first non option argument (for permute) */\n+static int nonopt_end = -1;   /* first option after non options (for permute) */\n+\n+/* Error messages */\n+static const char recargchar[] = \"option requires an argument -- %c\";\n+static const char recargstring[] = \"option requires an argument -- %s\";\n+static const char ambig[] = \"ambiguous option -- %.*s\";\n+static const char noarg[] = \"option doesn't take an argument -- %.*s\";\n+static const char illoptchar[] = \"unknown option -- %c\";\n+static const char illoptstring[] = \"unknown option -- %s\";\n+\n+/*\n+ * Compute the greatest common divisor of a and b.\n+ */\n+static int\n+gcd(int a, int b)\n+{\n+\tint c;\n+\n+\tc = a % b;\n+\twhile (c != 0) {\n+\t\ta = b;\n+\t\tb = c;\n+\t\tc = a % b;\n+\t}\n+\n+\treturn (b);\n+}\n+\n+/*\n+ * Exchange the block from nonopt_start to nonopt_end with the block\n+ * from nonopt_end to opt_end (keeping the same order of arguments\n+ * in each block).\n+ */\n+static void\n+permute_args(int panonopt_start, int panonopt_end, int opt_end,\n+\tchar **nargv)\n+{\n+\tint cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;\n+\tchar *swap;\n+\n+\t/*\n+\t * compute lengths of blocks and number and size of cycles\n+\t */\n+\tnnonopts = panonopt_end - panonopt_start;\n+\tnopts = opt_end - panonopt_end;\n+\tncycle = gcd(nnonopts, nopts);\n+\tcyclelen = (opt_end - panonopt_start) / ncycle;\n+\n+\tfor (i = 0; i < ncycle; i++) {\n+\t\tcstart = panonopt_end+i;\n+\t\tpos = cstart;\n+\t\tfor (j = 0; j < cyclelen; j++) {\n+\t\t\tif (pos >= panonopt_end)\n+\t\t\t\tpos -= nnonopts;\n+\t\t\telse\n+\t\t\t\tpos += nopts;\n+\t\t\tswap = nargv[pos];\n+\t\t\t/* LINTED const cast */\n+\t\t\t((char **) nargv)[pos] = nargv[cstart];\n+\t\t\t/* LINTED const cast */\n+\t\t\t((char **)nargv)[cstart] = swap;\n+\t\t}\n+\t}\n+}\n+\n+/*\n+ * parse_long_options --\n+ *\tParse long options in argc/argv argument vector.\n+ * Returns -1 if short_too is set and the option does not match long_options.\n+ */\n+static int\n+parse_long_options(char **nargv, const char *options,\n+\tconst struct option *long_options, int *idx, int short_too)\n+{\n+\tconst char *current_argv;\n+\tchar *has_equal;\n+\tsize_t current_argv_len;\n+\tint i, match;\n+\n+\tcurrent_argv = place;\n+\tmatch = -1;\n+\n+\toptind++;\n+\n+\thas_equal = strchr(current_argv, '=');\n+\tif (has_equal != NULL) {\n+\t\t/* argument found (--option=arg) */\n+\t\tcurrent_argv_len = has_equal - current_argv;\n+\t\thas_equal++;\n+\t} else\n+\t\tcurrent_argv_len = strlen(current_argv);\n+\n+\tfor (i = 0; long_options[i].name; i++) {\n+\t\t/* find matching long option */\n+\t\tif (strncmp(current_argv, long_options[i].name,\n+\t\t    current_argv_len))\n+\t\t\tcontinue;\n+\n+\t\tif (strlen(long_options[i].name) == current_argv_len) {\n+\t\t\t/* exact match */\n+\t\t\tmatch = i;\n+\t\t\tbreak;\n+\t\t}\n+\t\t/*\n+\t\t * If this is a known short option, don't allow\n+\t\t * a partial match of a single character.\n+\t\t */\n+\t\tif (short_too && current_argv_len == 1)\n+\t\t\tcontinue;\n+\n+\t\tif (match == -1)\t/* partial match */\n+\t\t\tmatch = i;\n+\t\telse {\n+\t\t\t/* ambiguous abbreviation */\n+\t\t\tif (PRINT_ERROR)\n+\t\t\t\twarnx(ambig, (int)current_argv_len,\n+\t\t\t\t     current_argv);\n+\t\t\toptopt = 0;\n+\t\t\treturn BADCH;\n+\t\t}\n+\t}\n+\tif (match != -1) {\t\t/* option found */\n+\t\tif (long_options[match].has_arg == no_argument\n+\t\t    && has_equal) {\n+\t\t\tif (PRINT_ERROR)\n+\t\t\t\twarnx(noarg, (int)current_argv_len,\n+\t\t\t\t     current_argv);\n+\t\t\t/*\n+\t\t\t * XXX: GNU sets optopt to val regardless of flag\n+\t\t\t */\n+\t\t\tif (long_options[match].flag == NULL)\n+\t\t\t\toptopt = long_options[match].val;\n+\t\t\telse\n+\t\t\t\toptopt = 0;\n+\t\t\treturn BADARG;\n+\t\t}\n+\t\tif (long_options[match].has_arg == required_argument ||\n+\t\t    long_options[match].has_arg == optional_argument) {\n+\t\t\tif (has_equal)\n+\t\t\t\toptarg = has_equal;\n+\t\t\telse if (long_options[match].has_arg ==\n+\t\t\t    required_argument) {\n+\t\t\t\t/*\n+\t\t\t\t * optional argument doesn't use next nargv\n+\t\t\t\t */\n+\t\t\t\toptarg = nargv[optind++];\n+\t\t\t}\n+\t\t}\n+\t\tif ((long_options[match].has_arg == required_argument)\n+\t\t    && (optarg == NULL)) {\n+\t\t\t/*\n+\t\t\t * Missing argument; leading ':' indicates no error\n+\t\t\t * should be generated.\n+\t\t\t */\n+\t\t\tif (PRINT_ERROR)\n+\t\t\t\twarnx(recargstring,\n+\t\t\t\t    current_argv);\n+\t\t\t/*\n+\t\t\t * XXX: GNU sets optopt to val regardless of flag\n+\t\t\t */\n+\t\t\tif (long_options[match].flag == NULL)\n+\t\t\t\toptopt = long_options[match].val;\n+\t\t\telse\n+\t\t\t\toptopt = 0;\n+\t\t\t--optind;\n+\t\t\treturn BADARG;\n+\t\t}\n+\t} else {\t\t\t/* unknown option */\n+\t\tif (short_too) {\n+\t\t\t--optind;\n+\t\t\treturn (-1);\n+\t\t}\n+\t\tif (PRINT_ERROR)\n+\t\t\twarnx(illoptstring, current_argv);\n+\t\toptopt = 0;\n+\t\treturn BADCH;\n+\t}\n+\tif (idx)\n+\t\t*idx = match;\n+\tif (long_options[match].flag) {\n+\t\t*long_options[match].flag = long_options[match].val;\n+\t\treturn 0;\n+\t} else\n+\t\treturn (long_options[match].val);\n+}\n+\n+/*\n+ * getopt_internal --\n+ *\tParse argc/argv argument vector.  Called by user level routines.\n+ */\n+static int\n+getopt_internal(int nargc, char **nargv, const char *options,\n+\tconst struct option *long_options, int *idx, int flags)\n+{\n+\tchar *oli;\t\t\t\t/* option letter list index */\n+\tint optchar, short_too;\n+\tstatic int posixly_correct = -1;\n+\tsize_t len;\n+\tint optreset = 0;\n+\n+\tif (options == NULL)\n+\t\treturn (-1);\n+\n+\t/*\n+\t * Disable GNU extensions if POSIXLY_CORRECT is set or options\n+\t * string begins with a '+'.\n+\t */\n+\tif (posixly_correct == -1) {\n+\t\terrno_t err = _wgetenv_s(&len, NULL, 0, L\"POSIXLY_CORRECT\");\n+\t\tposixly_correct = (err == 0) && (len > 0);\n+\t}\n+\tif (!posixly_correct || *options == '+')\n+\t\tflags &= ~FLAG_PERMUTE;\n+\telse if (*options == '-')\n+\t\tflags |= FLAG_ALLARGS;\n+\tif (*options == '+' || *options == '-')\n+\t\toptions++;\n+\t/*\n+\t * reset if requested\n+\t */\n+\tif (optind == 0)\n+\t\toptind = optreset = 1;\n+\n+\toptarg = NULL;\n+\tif (optreset)\n+\t\tnonopt_start = nonopt_end = -1;\n+start:\n+\tif (optreset || !*place) {\t\t/* update scanning pointer */\n+\t\toptreset = 0;\n+\t\tif (optind >= nargc) {          /* end of argument vector */\n+\t\t\tplace = EMSG;\n+\t\t\tif (nonopt_end != -1) {\n+\t\t\t\t/* do permutation, if we have to */\n+\t\t\t\tpermute_args(nonopt_start, nonopt_end,\n+\t\t\t\t    optind, nargv);\n+\t\t\t\toptind -= nonopt_end - nonopt_start;\n+\t\t\t} else if (nonopt_start != -1) {\n+\t\t\t\t/*\n+\t\t\t\t * If we skipped non-options, set optind\n+\t\t\t\t * to the first of them.\n+\t\t\t\t */\n+\t\t\t\toptind = nonopt_start;\n+\t\t\t}\n+\t\t\tnonopt_start = nonopt_end = -1;\n+\t\t\treturn (-1);\n+\t\t}\n+\t\tplace = nargv[optind];\n+\t\tif (*place != '-' ||\n+\t\t    (place[1] == '\\0' && strchr(options, '-') == NULL)) {\n+\t\t\tplace = EMSG;\t\t/* found non-option */\n+\t\t\tif (flags & FLAG_ALLARGS) {\n+\t\t\t\t/*\n+\t\t\t\t * GNU extension:\n+\t\t\t\t * return non-option as argument to option 1\n+\t\t\t\t */\n+\t\t\t\toptarg = nargv[optind++];\n+\t\t\t\treturn INORDER;\n+\t\t\t}\n+\t\t\tif (!(flags & FLAG_PERMUTE)) {\n+\t\t\t\t/*\n+\t\t\t\t * If no permutation wanted, stop parsing\n+\t\t\t\t * at first non-option.\n+\t\t\t\t */\n+\t\t\t\treturn (-1);\n+\t\t\t}\n+\t\t\t/* do permutation */\n+\t\t\tif (nonopt_start == -1)\n+\t\t\t\tnonopt_start = optind;\n+\t\t\telse if (nonopt_end != -1) {\n+\t\t\t\tpermute_args(nonopt_start, nonopt_end,\n+\t\t\t\t    optind, nargv);\n+\t\t\t\tnonopt_start = optind -\n+\t\t\t\t    (nonopt_end - nonopt_start);\n+\t\t\t\tnonopt_end = -1;\n+\t\t\t}\n+\t\t\toptind++;\n+\t\t\t/* process next argument */\n+\t\t\tgoto start;\n+\t\t}\n+\t\tif (nonopt_start != -1 && nonopt_end == -1)\n+\t\t\tnonopt_end = optind;\n+\n+\t\t/*\n+\t\t * If we have \"-\" do nothing, if \"--\" we are done.\n+\t\t */\n+\t\tif (place[1] != '\\0' && *++place == '-' && place[1] == '\\0') {\n+\t\t\toptind++;\n+\t\t\tplace = EMSG;\n+\t\t\t/*\n+\t\t\t * We found an option (--), so if we skipped\n+\t\t\t * non-options, we have to permute.\n+\t\t\t */\n+\t\t\tif (nonopt_end != -1) {\n+\t\t\t\tpermute_args(nonopt_start, nonopt_end,\n+\t\t\t\t    optind, nargv);\n+\t\t\t\toptind -= nonopt_end - nonopt_start;\n+\t\t\t}\n+\t\t\tnonopt_start = nonopt_end = -1;\n+\t\t\treturn (-1);\n+\t\t}\n+\t}\n+\n+\t/*\n+\t * Check long options if:\n+\t *  1) we were passed some\n+\t *  2) the arg is not just \"-\"\n+\t *  3) either the arg starts with -- we are getopt_long_only()\n+\t */\n+\tif (long_options != NULL && place != nargv[optind] &&\n+\t    (*place == '-' || (flags & FLAG_LONGONLY))) {\n+\t\tshort_too = 0;\n+\t\tif (*place == '-')\n+\t\t\tplace++;\t\t/* --foo long option */\n+\t\telse if (*place != ':' && strchr(options, *place) != NULL)\n+\t\t\tshort_too = 1;\t\t/* could be short option too */\n+\n+\t\toptchar = parse_long_options(nargv, options, long_options,\n+\t\t    idx, short_too);\n+\t\tif (optchar != -1) {\n+\t\t\tplace = EMSG;\n+\t\t\treturn optchar;\n+\t\t}\n+\t}\n+\n+\toptchar = (int)*place++;\n+\toli = strchr(options, optchar);\n+\tif (optchar == (int)':' ||\n+\t    (optchar == (int)'-' && *place != '\\0') ||\n+\t    oli == NULL) {\n+\t\t/*\n+\t\t * If the user specified \"-\" and  '-' isn't listed in\n+\t\t * options, return -1 (non-option) as per POSIX.\n+\t\t * Otherwise, it is an unknown option character (or ':').\n+\t\t */\n+\t\tif (optchar == (int)'-' && *place == '\\0')\n+\t\t\treturn (-1);\n+\t\tif (!*place)\n+\t\t\t++optind;\n+\t\tif (PRINT_ERROR)\n+\t\t\twarnx(illoptchar, optchar);\n+\t\toptopt = optchar;\n+\t\treturn BADCH;\n+\t}\n+\tif (long_options != NULL && optchar == 'W' && oli[1] == ';') {\n+\t\t/* -W long-option */\n+\t\tif (*place)\n+\t\t\t;\n+\t\telse if (++optind >= nargc) {\t/* no arg */\n+\t\t\tplace = EMSG;\n+\t\t\tif (PRINT_ERROR)\n+\t\t\t\twarnx(recargchar, optchar);\n+\t\t\toptopt = optchar;\n+\t\t\treturn BADARG;\n+\t\t}\t\t\t\t/* white space */\n+\t\tplace = nargv[optind];\n+\t\toptchar = parse_long_options(nargv, options, long_options,\n+\t\t    idx, 0);\n+\t\tplace = EMSG;\n+\t\treturn optchar;\n+\t}\n+\tif (*++oli != ':') {\t\t\t/* doesn't take argument */\n+\t\tif (!*place)\n+\t\t\t++optind;\n+\t} else {\t\t\t\t/* takes (optional) argument */\n+\t\toptarg = NULL;\n+\t\tif (*place)\t\t\t/* no white space */\n+\t\t\toptarg = place;\n+\t\telse if (oli[1] != ':') {\t/* arg not optional */\n+\t\t\tif (++optind >= nargc) {\t/* no arg */\n+\t\t\t\tplace = EMSG;\n+\t\t\t\tif (PRINT_ERROR)\n+\t\t\t\t\twarnx(recargchar, optchar);\n+\t\t\t\toptopt = optchar;\n+\t\t\t\treturn BADARG;\n+\t\t\t}\n+\t\t\toptarg = nargv[optind];\n+\t\t}\n+\t\tplace = EMSG;\n+\t\t++optind;\n+\t}\n+\t/* dump back option letter */\n+\treturn optchar;\n+}\n+\n+/*\n+ * getopt --\n+ *\tParse argc/argv argument vector.\n+ */\n+int\n+getopt(int nargc, char *nargv[], const char *options)\n+{\n+\treturn getopt_internal(nargc, nargv, options, NULL, NULL,\n+\t\t\t       FLAG_PERMUTE);\n+}\n+\n+/*\n+ * getopt_long --\n+ *\tParse argc/argv argument vector.\n+ */\n+int\n+getopt_long(int nargc, char *nargv[], const char *options,\n+\tconst struct option *long_options, int *idx)\n+{\n+\n+\treturn (getopt_internal(nargc, nargv, options, long_options, idx,\n+\t    FLAG_PERMUTE));\n+}\n+\n+/*\n+ * getopt_long_only --\n+ *\tParse argc/argv argument vector.\n+ */\n+int\n+getopt_long_only(int nargc, char *nargv[], const char *options,\n+\tconst struct option *long_options, int *idx)\n+{\n+\n+\treturn (getopt_internal(nargc, nargv, options, long_options, idx,\n+\t    FLAG_PERMUTE|FLAG_LONGONLY));\n+}\n+\n+#endif /* NEED_USUAL_GETOPT */\ndiff --git a/lib/eal/windows/include/getopt.h b/lib/eal/windows/include/getopt.h\nindex 6f57af454b17..e4cf6873cb0c 100644\n--- a/lib/eal/windows/include/getopt.h\n+++ b/lib/eal/windows/include/getopt.h\n@@ -44,7 +44,7 @@\n \n \n /** argument to current option, or NULL if it has none */\n-extern const char *optarg;\n+extern char *optarg;\n /** Current position in arg string.  Starts from 1.\n  * Setting to 0 resets state.\n  */\n@@ -80,14 +80,14 @@ struct option {\n };\n \n /** Compat: getopt */\n-int getopt(int argc, char *argv[], const char *options);\n+int getopt(int argc, char *const argv[], const char *options);\n \n /** Compat: getopt_long */\n-int getopt_long(int argc, char *argv[], const char *options,\n+int getopt_long(int argc, char *const argv[], const char *options,\n \t\tconst struct option *longopts, int *longindex);\n \n /** Compat: getopt_long_only */\n-int getopt_long_only(int nargc, char *argv[], const char *options,\n+int getopt_long_only(int nargc, char *const argv[], const char *options,\n \t\t     const struct option *long_options, int *idx);\n \n \n",
    "prefixes": []
}