From patchwork Fri Jun 20 19:54:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 32297 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A232203F4 for ; Fri, 20 Jun 2014 19:54:42 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id tr6sf27330457ieb.7 for ; Fri, 20 Jun 2014 12:54:41 -0700 (PDT) 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:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=HPxpqp21hqJNPmvrSs1fKKrURd2dWnI5ElnecNcG1CY=; b=BgritkECwimC2gJTDdF3XdYlsPrjMsi9jgjtKDDJDSyDZiXz7vi5NQn8RMgB+pp0tJ Ii5TZqeIMcnN+nJoollrAXX+e8D91d//AooLLzlbjeOqdixx0ptsWe4G6r3f+qllEZhK JypsnRfRnOGwyOjg+IO47goa/k455lxsPKKhREvAXaq8BP8lK6JP2OyUEjaHU1krIfXs PrhVGTT/ZIWsVayJV9y2w/U8CZqERcVEJg8ZF2JossymvySzJprNp1DoClu22ywW5utj KMbLpe8kRtos07o+2c+e/PXAf2Tx1ZLC7pqrHfEEa+OpQZEiC5O/ulN+nqa8xhBrYj6u n33g== X-Gm-Message-State: ALoCoQlLvVo+SDhkTZrxIJtY/K3R9eM92uJS+2HMRrFGc8Y1teGFivOT78TV4+ABZSeaxpAffBBk X-Received: by 10.50.131.228 with SMTP id op4mr2319521igb.2.1403294081889; Fri, 20 Jun 2014 12:54:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.78 with SMTP id t72ls1045982qge.32.gmail; Fri, 20 Jun 2014 12:54:41 -0700 (PDT) X-Received: by 10.52.26.237 with SMTP id o13mr3973425vdg.1.1403294081751; Fri, 20 Jun 2014 12:54:41 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id o5si4687632vez.30.2014.06.20.12.54.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 12:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so4001265veb.34 for ; Fri, 20 Jun 2014 12:54:40 -0700 (PDT) X-Received: by 10.52.138.232 with SMTP id qt8mr2366806vdb.44.1403294079957; Fri, 20 Jun 2014 12:54:39 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp47128vcb; Fri, 20 Jun 2014 12:54:39 -0700 (PDT) X-Received: by 10.224.57.81 with SMTP id b17mr8518152qah.29.1403294079475; Fri, 20 Jun 2014 12:54:39 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id f10si12233630qay.89.2014.06.20.12.54.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 20 Jun 2014 12:54:39 -0700 (PDT) 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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wy4ri-0005VE-P4; Fri, 20 Jun 2014 19:52:50 +0000 Received: from mail-qa0-f53.google.com ([209.85.216.53]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wy4rc-0005V9-S9 for lng-odp@lists.linaro.org; Fri, 20 Jun 2014 19:52:44 +0000 Received: by mail-qa0-f53.google.com with SMTP id j15so3599878qaq.12 for ; Fri, 20 Jun 2014 12:54:27 -0700 (PDT) X-Received: by 10.229.178.202 with SMTP id bn10mr8201439qcb.6.1403294067044; Fri, 20 Jun 2014 12:54:27 -0700 (PDT) Received: from fedora1.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id r2sm15164646qam.35.2014.06.20.12.54.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jun 2014 12:54:26 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 20 Jun 2014 15:54:11 -0400 Message-Id: <1403294051-54030-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] Fix globaly shadowed variable 'args' 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: mike.holmes@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.128.175 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 Removes sparse -Wshadow warning by prefixing the global instace of args with gbl_. This makes it more aparrent to the reader that the global instance of args is being referenced rather than the local one in burst_mode_init_params() Signed-off-by: Mike Holmes Reviewed-by: Anders Roxell --- test/l2fwd/l2fwd.c | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/test/l2fwd/l2fwd.c b/test/l2fwd/l2fwd.c index 49e113d..fab01de 100644 --- a/test/l2fwd/l2fwd.c +++ b/test/l2fwd/l2fwd.c @@ -72,7 +72,7 @@ typedef struct { } args_t; /** Global pointer to args */ -static args_t *args; +static args_t *gbl_args; int num_workers; /* helper funcs */ @@ -181,7 +181,7 @@ static void *pktio_queue_thread(void *arg) * scheduler can take packets from any input queue */ for (i = 0; i < num_workers; i++) - dstpktio[i+1] = args->thread[i].dstpktio; + dstpktio[i+1] = gbl_args->thread[i].dstpktio; /* Loop packets */ for (;;) { @@ -294,38 +294,38 @@ int main(int argc, char *argv[]) } /* Reserve memory for args from shared mem */ - args = odp_shm_reserve("shm_args", sizeof(args_t), ODP_CACHE_LINE_SIZE); - if (args == NULL) { + gbl_args = odp_shm_reserve("shm_args", sizeof(args_t), ODP_CACHE_LINE_SIZE); + if (gbl_args == NULL) { ODP_ERR("Error: shared mem alloc failed.\n"); exit(EXIT_FAILURE); } - memset(args, 0, sizeof(*args)); + memset(gbl_args, 0, sizeof(*gbl_args)); /* Parse and store the application arguments */ - parse_args(argc, argv, &args->appl); + parse_args(argc, argv, &gbl_args->appl); /* Print both system and application information */ - print_info(NO_PATH(argv[0]), &args->appl); + print_info(NO_PATH(argv[0]), &gbl_args->appl); core_count = odp_sys_core_count(); num_workers = core_count; - if (args->appl.core_count) - num_workers = args->appl.core_count; + if (gbl_args->appl.core_count) + num_workers = gbl_args->appl.core_count; if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; printf("Num worker threads: %i\n", num_workers); - if (num_workers < args->appl.if_count) { + if (num_workers < gbl_args->appl.if_count) { ODP_ERR("Error: core count %d is less than interface count\n", num_workers); exit(EXIT_FAILURE); } - if (args->appl.if_count % 2 != 0) { + if (gbl_args->appl.if_count % 2 != 0) { ODP_ERR("Error: interface count %d is odd in fwd appl.\n", - args->appl.if_count); + gbl_args->appl.if_count); exit(EXIT_FAILURE); } /* @@ -367,38 +367,38 @@ int main(int argc, char *argv[]) for (i = 0; i < num_workers; ++i) { int if_idx; - if_idx = i % args->appl.if_count; + if_idx = i % gbl_args->appl.if_count; - args->thread[i].srcif = args->appl.if_names[if_idx]; + gbl_args->thread[i].srcif = gbl_args->appl.if_names[if_idx]; if (if_idx % 2 == 0) - args->thread[i].dstif = args->appl.if_names[if_idx+1]; + gbl_args->thread[i].dstif = gbl_args->appl.if_names[if_idx+1]; else - args->thread[i].dstif = args->appl.if_names[if_idx-1]; - args->thread[i].pool = pool; - args->thread[i].mode = args->appl.mode; - args->thread[i].type = args->appl.type; - args->thread[i].fanout = args->appl.fanout; - - if (args->appl.mode == APPL_MODE_PKT_BURST) { - pktio = burst_mode_init_params(&args->thread[i], pool); + gbl_args->thread[i].dstif = gbl_args->appl.if_names[if_idx-1]; + gbl_args->thread[i].pool = pool; + gbl_args->thread[i].mode = gbl_args->appl.mode; + gbl_args->thread[i].type = gbl_args->appl.type; + gbl_args->thread[i].fanout = gbl_args->appl.fanout; + + if (gbl_args->appl.mode == APPL_MODE_PKT_BURST) { + pktio = burst_mode_init_params(&gbl_args->thread[i], pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" for thread:%02i\n", i); exit(EXIT_FAILURE); } } else { /* APPL_MODE_PKT_QUEUE */ - pktio = queue_mode_init_params(&args->thread[i], pool); + pktio = queue_mode_init_params(&gbl_args->thread[i], pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" for thread:%02i\n", i); exit(EXIT_FAILURE); } } - args->thread[i].srcpktio = pktio; + gbl_args->thread[i].srcpktio = pktio; } for (i = 0; i < num_workers; ++i) { if (i % 2 == 0) - args->thread[i].dstpktio = args->thread[i+1].srcpktio; + gbl_args->thread[i].dstpktio = gbl_args->thread[i+1].srcpktio; else - args->thread[i].dstpktio = args->thread[i-1].srcpktio; + gbl_args->thread[i].dstpktio = gbl_args->thread[i-1].srcpktio; } /* Create worker threads */ for (i = 0; i < num_workers; ++i) { @@ -407,12 +407,12 @@ int main(int argc, char *argv[]) core = (first_core + i) % core_count; - if (args->appl.mode == APPL_MODE_PKT_BURST) + if (gbl_args->appl.mode == APPL_MODE_PKT_BURST) thr_run_func = pktio_ifburst_thread; else /* APPL_MODE_PKT_QUEUE */ thr_run_func = pktio_queue_thread; odp_linux_pthread_create(thread_tbl, 1, core, thr_run_func, - &args->thread[i]); + &gbl_args->thread[i]); } /* Master thread waits for other threads to exit */