From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ustc.edu.cn (smtp2.ustc.edu.cn [202.38.64.46]) by dpdk.org (Postfix) with ESMTP id 3699C8E93 for ; Tue, 13 Oct 2015 10:55:16 +0200 (CEST) Received: from dell.my.domain (unknown [222.195.92.204]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygBnVwjlxhxWjcmpAQ--.37974S3; Tue, 13 Oct 2015 16:55:14 +0800 (CST) From: Tiwei Bie To: dev@dpdk.org Date: Tue, 13 Oct 2015 16:54:06 +0800 Message-Id: <1444726446-8106-2-git-send-email-btw@mail.ustc.edu.cn> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1444726446-8106-1-git-send-email-btw@mail.ustc.edu.cn> References: <1444726446-8106-1-git-send-email-btw@mail.ustc.edu.cn> X-CM-TRANSID: LkAmygBnVwjlxhxWjcmpAQ--.37974S3 X-Coremail-Antispam: 1UD129KBjvdXoWrZrWxWFW7JryrtrW3Wr4rZrb_yoWkWFgE93 WSvFn5AF1UWrsrWw1ktr48GFZrurWDAF4I9w1xX342ka4qvr1jqr9rWr98AFyrJa1Uurn0 yw47Cr93Cr92gjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbTkYjsxI4VW3JwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7 IE14v26r18M28IrcIa0xkI8VCY1x0267AKxVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK 67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I 0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7Cj xVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrV C2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE 7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_GFyl42xK82IYc2Ij64vIr4 1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK 67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1j6r15MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI 8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAv wI8IcIk0rVWUCVW8JwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14 v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j4Q6LUUUUU= X-CM-SenderInfo: xewzqzxdloh3xvwfhvlgxou0/1tbiAQcBAVQhmEeO0gAIs4 Subject: [dpdk-dev] [PATCH] eal/bsd: reinitialize optind and optreset to 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2015 08:55:18 -0000 The variable optind must be reinitialized to 1 in order to skip over argv[0] on FreeBSD. Because getopt() on FreeBSD will return -1 when it meets an argument which doesn't start with '-'. The variable optreset is provided on FreeBSD to indicate the additional set of calls to getopt(). So, also reinitialize it to 1. Signed-off-by: Tiwei Bie --- lib/librte_eal/bsdapp/eal/eal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 1b6f705..35feaee 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -334,7 +334,8 @@ eal_log_level_parse(int argc, char **argv) break; } - optind = 0; /* reset getopt lib */ + optind = 1; /* reset getopt lib */ + optreset = 1; } /* Parse the argument given in the command line of the application */ @@ -403,7 +404,8 @@ eal_parse_args(int argc, char **argv) if (optind >= 0) argv[optind-1] = prgname; ret = optind-1; - optind = 0; /* reset getopt lib */ + optind = 1; /* reset getopt lib */ + optreset = 1; return ret; } -- 2.6.0