From patchwork Mon Jan 12 10:50:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 42960 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55A4626C86 for ; Mon, 12 Jan 2015 10:50:58 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf6176138wiv.1 for ; Mon, 12 Jan 2015 02:50:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=/PQQxSGEIIUss2fjSkiUGTbslhvKziM9Dgyh8UdwVRw=; b=lZ5FWouYkCwVeFxAMeECgOhZWZGnEgl35W2kwbX/uG6xRPYuiiXKllnJAiR2gW389H gMcsEvelw18XhzpxDE4qfjML0+WM+Vr5rcN+UERb65UXCllNPru+/n5jAbd+SV1pcd17 0x1ZRLwvOy6Iqlbu2I+6NP4pPWux19WoBjnNw0EgwtnyXSSMn1Mu9fjepv74pMncMr9S nLLzeMfxXBrnjrMt0aXMV7O2bmG0c2F/SgNoDWpKd20oGqGll43hf98dSx4Ulwxb7m1w YwNEV7l/Cbr2YmmEFZJLcDSHHv2QaiCrrfqNp+xxIYvsgtdrXssGOc7gGShC0dqsmQmN RmaA== X-Gm-Message-State: ALoCoQmvh7Vvi5bUBut9czINDGanoU6Yz9IJ1ONdrUFha7yzoYCZr4FbvBBEIRwRdFH2vmhQUihc X-Received: by 10.180.19.42 with SMTP id b10mr2011578wie.0.1421059857577; Mon, 12 Jan 2015 02:50:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.133 with SMTP id j5ls510532laa.28.gmail; Mon, 12 Jan 2015 02:50:57 -0800 (PST) X-Received: by 10.112.54.167 with SMTP id k7mr35561193lbp.72.1421059857348; Mon, 12 Jan 2015 02:50:57 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id y3si20840013laj.75.2015.01.12.02.50.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 Jan 2015 02:50:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so16964438lbv.12 for ; Mon, 12 Jan 2015 02:50:57 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr36161019laa.59.1421059857238; Mon, 12 Jan 2015 02:50:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1038785lbb; Mon, 12 Jan 2015 02:50:56 -0800 (PST) X-Received: by 10.140.98.225 with SMTP id o88mr46541225qge.5.1421059855776; Mon, 12 Jan 2015 02:50:55 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id w12si7956517qge.63.2015.01.12.02.50.54 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 12 Jan 2015 02:50:55 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YAcaB-0002IK-1k; Mon, 12 Jan 2015 10:50:51 +0000 Received: from mail-pa0-f54.google.com ([209.85.220.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YAca5-0002IF-1X for lng-odp@lists.linaro.org; Mon, 12 Jan 2015 10:50:45 +0000 Received: by mail-pa0-f54.google.com with SMTP id fb1so31353331pad.13 for ; Mon, 12 Jan 2015 02:50:39 -0800 (PST) X-Received: by 10.66.159.164 with SMTP id xd4mr43804455pab.54.1421059839573; Mon, 12 Jan 2015 02:50:39 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id j9sm14037892pdl.72.2015.01.12.02.50.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 Jan 2015 02:50:38 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Mon, 12 Jan 2015 12:50:19 +0200 Message-Id: <1421059819-20423-1-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Topics: patch Subject: [lng-odp] [PATCH] example: pktio: replace strtok_r to make C99 compliant X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ciprian Barbu --- Fix for https://bugs.linaro.org/show_bug.cgi?id=1049 example/packet/odp_pktio.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index b162fac..0d5918a 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -69,6 +69,7 @@ typedef struct { int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ + char *if_str; /**< Storage for interface names */ } appl_args_t; /** @@ -376,6 +377,8 @@ int main(int argc, char *argv[]) /* Master thread waits for other threads to exit */ odph_linux_pthread_join(thread_tbl, num_workers); + free(args->appl.if_names); + free(args->appl.if_str); free(args); printf("Exit\n\n"); @@ -462,7 +465,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) { int opt; int long_index; - char *names, *str, *token, *save; + char *token; size_t len; int i; static struct option longopts[] = { @@ -495,19 +498,19 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) } len += 1; /* add room for '\0' */ - names = malloc(len); - if (names == NULL) { + appl_args->if_str = malloc(len); + if (appl_args->if_str == NULL) { usage(argv[0]); exit(EXIT_FAILURE); } /* count the number of tokens separated by ',' */ - strcpy(names, optarg); - for (str = names, i = 0;; str = NULL, i++) { - token = strtok_r(str, ",", &save); - if (token == NULL) - break; - } + strcpy(appl_args->if_str, optarg); + for (token = strtok(appl_args->if_str, ","), i = 0; + token != NULL; + token = strtok(NULL, ","), i++) + ; + appl_args->if_count = i; if (appl_args->if_count == 0) { @@ -520,11 +523,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) calloc(appl_args->if_count, sizeof(char *)); /* store the if names (reset names string) */ - strcpy(names, optarg); - for (str = names, i = 0;; str = NULL, i++) { - token = strtok_r(str, ",", &save); - if (token == NULL) - break; + strcpy(appl_args->if_str, optarg); + for (token = strtok(appl_args->if_str, ","), i = 0; + token != NULL; token = strtok(NULL, ","), i++) { appl_args->if_names[i] = token; } break;