From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BD961A0565; Mon, 23 Mar 2020 14:41:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9982A1C067; Mon, 23 Mar 2020 14:41:03 +0100 (CET) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by dpdk.org (Postfix) with ESMTP id A03D21C044 for ; Mon, 23 Mar 2020 14:41:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584970861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Sfu2nogs28z4avIa9N3mHOILgufiOjZ5S/uh1d8OLs=; b=Zb+0GvLdSZk+JX/WK7BKMIX43VaTemTqLY/t+SSqpeW6oW/LhpFvkM3Ny5m4UHJYqEzEl+ mstQ3k0kwBcU6LSj6oy6Avk55INh/L+gQOEz/dHTEkRnmMmY8FZGuGmjXUPQKqtKjZzEIz +qZdX8EXCODAeFrQEWKg6DEY/9nTCJI= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-kCALWvV8M5yo5ew8VJz6iQ-1; Mon, 23 Mar 2020 09:40:57 -0400 X-MC-Unique: kCALWvV8M5yo5ew8VJz6iQ-1 Received: by mail-vk1-f198.google.com with SMTP id b136so5115029vkf.20 for ; Mon, 23 Mar 2020 06:40:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=41gQ5pJTxqn4AHaMsHJtujAWAvIDWxgSgnLpQwEMHFg=; b=OxZlYAexNABh28b9obfWL6rwl5T21ttcvb8m/O1AqqePoDzA8UPLFV8DawFmEBwFPI XEPcXM2G1xcfz3+glveAz5AhaIFR0YMT5wIc978OWWgVcOouahPA0l9uv92qd5mz8Ka6 1N93gHyRZ4virOAHYv0fkYgHnE8j+EJKr2DL7WXoKilOBpeEFWzS6XP2X6t5gxkRo9cw PNoh+E5BiI9+MyJyoBIYGKPo1jfWM/RPQAh/pBPD9pFKU5YR5JXZNRYnDIEhKwCoIWYG NqFxNRTReDxW62ZkFeZ9uotx8LDNrjiraPGp01nZN8nMMbB341Eyp2HLTGOPKVp/CIxD fRmg== X-Gm-Message-State: ANhLgQ3Lt1tsD0Dq4AU5s/je8c3CEDDFLfzPddkzUig7gFCSvoQMmro5 GDeq06g2RsxQAzPSqI1ZPEMztJ8MJB9fdFoPMoxRlki0sDlutuvkC77uWwsLzB6ODH+StDgYcPm UR4ytxcEkUb0uWnWzx7k= X-Received: by 2002:a05:6102:7c7:: with SMTP id y7mr15742849vsg.198.1584970856689; Mon, 23 Mar 2020 06:40:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv3ndqcJsjuOJNSfzwgQhBAcPfpingBL8kEnTwyKq4vrgtdsd5YBTImqTSD8YHyZiq3uDFcVq0rcLk5eI//7wY= X-Received: by 2002:a05:6102:7c7:: with SMTP id y7mr15742820vsg.198.1584970856341; Mon, 23 Mar 2020 06:40:56 -0700 (PDT) MIME-Version: 1.0 References: <20200217222654.2218926-1-thomas@monjalon.net> In-Reply-To: <20200217222654.2218926-1-thomas@monjalon.net> From: David Marchand Date: Mon, 23 Mar 2020 14:40:45 +0100 Message-ID: To: Thomas Monjalon Cc: dev , Vladimir Medvedkin , John McNamara , Marko Kovacevic , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Gagandeep Singh , Hemant Agrawal , Sachin Saxena , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH] devtools: forbid variable declaration inside for X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Feb 17, 2020 at 11:27 PM Thomas Monjalon wrot= e: > > Some compilers raise an error when declaring a variable > in the middle of a function. This is a C99 allowance. > Even if DPDK switches globally to C99 or C11 standard, > the coding rules are for declarations at the beginning > of a block: > http://doc.dpdk.org/guides/contributing/coding_style.html#local-variables > > This coding style is enforced by adding a check of > the common patterns like "for (int i;" > > The occurrences of the checked pattern are fixed: > 'for *(\(char\|u\?int\|unsigned\)' You missed size_t: drivers/common/mlx5/mlx5_glue.c: for (size_t i =3D 0; i < num_action= s; i++) > In the file dpaa2_sparser.c, the fix is to remove the unused macros. > > Signed-off-by: Thomas Monjalon > --- > app/test-fib/main.c | 3 ++- > devtools/checkpatches.sh | 8 +++++++ > doc/guides/prog_guide/eventdev.rst | 6 ++++-- > drivers/common/mlx5/mlx5_devx_cmds.c | 4 ++-- > drivers/crypto/caam_jr/caam_jr.c | 5 ++++- > drivers/net/dpaa2/dpaa2_sparser.c | 30 -------------------------- > lib/librte_eal/windows/eal/eal_lcore.c | 9 ++++---- > 7 files changed, 25 insertions(+), 40 deletions(-) > > diff --git a/app/test-fib/main.c b/app/test-fib/main.c > index 3c29ca461e..16d40a6a02 100644 > --- a/app/test-fib/main.c > +++ b/app/test-fib/main.c > @@ -363,6 +363,7 @@ static void > gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz) > { > uint32_t i, j, k =3D 0; > + int a; > > if (config.nb_routes_per_depth[0] !=3D 0) { > memset(rt[k].addr, 0, 16); > @@ -370,7 +371,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz) > rt[k++].nh =3D rte_rand() & get_max_nh(nh_sz); > } > > - for (int a =3D 0; a < 4; a++) { > + for (a =3D 0; a < 4; a++) { > for (i =3D 1; i <=3D 32; i++) { > uint32_t rnd; > double edge =3D 0; > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh > index b16bace927..55e7ba05a0 100755 > --- a/devtools/checkpatches.sh > +++ b/devtools/checkpatches.sh > @@ -61,6 +61,14 @@ check_forbidden_additions() { # > -f $(dirname $(readlink -f $0))/check-forbidden-tokens.aw= k \ > "$1" || res=3D1 > > + # forbid variable declaration inside "for" loop > + awk -v FOLDERS=3D'.' \ > + -v EXPRESSIONS=3D'for *\\((char|u?int|unsigned)' \ + s?size_t > + -v RET_ON_FAIL=3D1 \ > + -v MESSAGE=3D'Declaring a variable inside for()' \ > + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.aw= k \ > + "$1" || res=3D1 > + Just a note, base drivers imported "as is" will probably trigger warnings. > # svg figures must be included with wildcard extension > # because of png conversion for pdf docs > awk -v FOLDERS=3D'doc' \ > diff --git a/doc/guides/prog_guide/eventdev.rst b/doc/guides/prog_guide/e= ventdev.rst > index 7bcd7603b1..ccde086f63 100644 > --- a/doc/guides/prog_guide/eventdev.rst > +++ b/doc/guides/prog_guide/eventdev.rst > @@ -242,9 +242,10 @@ Once queues are set up successfully, create the port= s as required. > }; > int dev_id =3D 0; > int rx_port_id =3D 0; > + int worker_port_id; > int err =3D rte_event_port_setup(dev_id, rx_port_id, &rx_conf); > > - for(int worker_port_id =3D 1; worker_port_id <=3D 4; worker_port= _id++) { > + for (worker_port_id =3D 1; worker_port_id <=3D 4; worker_port_id= ++) { > int err =3D rte_event_port_setup(dev_id, worker_port_id, = &worker_conf); > } > > @@ -277,8 +278,9 @@ can be achieved like this: > uint8_t atomic_qs[] =3D {0, 1}; > uint8_t single_link_q =3D 2; > uint8_t priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL; > + int worker_port_id; > > - for(int worker_port_id =3D 1; worker_port_id <=3D 4; worker_port= _id++) { > + for (worker_port_id =3D 1; worker_port_id <=3D 4; worker_port_id= ++) { > int links_made =3D rte_event_port_link(dev_id, worker_po= rt_id, atomic_qs, NULL, 2); > } > int links_made =3D rte_event_port_link(dev_id, tx_port_id, &sing= le_link_q, &priority, 1); > diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/m= lx5_devx_cmds.c > index d960bc93de..ae9dba2e0c 100644 > --- a/drivers/common/mlx5/mlx5_devx_cmds.c > +++ b/drivers/common/mlx5/mlx5_devx_cmds.c > @@ -412,7 +412,7 @@ mlx5_devx_cmd_query_hca_attr(struct ibv_context *ctx, > uint32_t in[MLX5_ST_SZ_DW(query_hca_cap_in)] =3D {0}; > uint32_t out[MLX5_ST_SZ_DW(query_hca_cap_out)] =3D {0}; > void *hcattr; > - int status, syndrome, rc; > + int status, syndrome, rc, i; > > MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP)= ; > MLX5_SET(query_hca_cap_in, in, op_mod, > @@ -521,7 +521,7 @@ mlx5_devx_cmd_query_hca_attr(struct ibv_context *ctx, > attr->lro_max_msg_sz_mode =3D MLX5_GET > (per_protocol_networking_offload_= caps, > hcattr, lro_max_msg_sz_mode); > - for (int i =3D 0 ; i < MLX5_LRO_NUM_SUPP_PERIODS ; i++) { > + for (i =3D 0 ; i < MLX5_LRO_NUM_SUPP_PERIODS ; i++) { > attr->lro_timer_supported_periods[i] =3D > MLX5_GET(per_protocol_networking_offload_caps, hc= attr, > lro_timer_supported_periods[i]); > diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/ca= am_jr.c > index 8aaa3d45f6..9aa64ab23f 100644 > --- a/drivers/crypto/caam_jr/caam_jr.c > +++ b/drivers/crypto/caam_jr/caam_jr.c > @@ -1353,6 +1353,9 @@ caam_jr_enqueue_op(struct rte_crypto_op *op, struct= caam_jr_qp *qp) > struct caam_jr_session *ses; > struct caam_jr_op_ctx *ctx =3D NULL; > struct sec_job_descriptor_t *jobdescr __rte_unused; > +#if CAAM_JR_DBG > + int i; > +#endif > > switch (op->sess_type) { > case RTE_CRYPTO_OP_WITH_SESSION: > @@ -1415,7 +1418,7 @@ caam_jr_enqueue_op(struct rte_crypto_op *op, struct= caam_jr_qp *qp) > rte_pktmbuf_data_len(op->sym->m_src)); > > printf("\n JD before conversion\n"); > - for (int i =3D 0; i < 12; i++) > + for (i =3D 0; i < 12; i++) > printf("\n 0x%08x", ctx->jobdes.desc[i]); > #endif > > diff --git a/drivers/net/dpaa2/dpaa2_sparser.c b/drivers/net/dpaa2/dpaa2_= sparser.c > index 7e8fedd818..ba0d500f74 100644 > --- a/drivers/net/dpaa2/dpaa2_sparser.c > +++ b/drivers/net/dpaa2/dpaa2_sparser.c > @@ -145,36 +145,6 @@ struct frame_attr_ext frame_attr_ext_arr[] =3D { > /* 112 */ {NULL, 0, 0x0000} > }; > > -#define SWAP_WORD(pr) \ > -do { \ > - for (int i =3D 0; i < 4 ; i++) { \ > - pr[i] =3D pr[i] ^ pr[6 - i + 1]; \ > - pr[6 - i + 1] =3D pr[6 - i + 1] ^ pr[i]; \ > - pr[i] =3D pr[i] ^ pr[6 - i + 1]; \ > - } \ > -} while (0) > - > -#define fa_print_sb() \ > -do { \ > - if (rte_cpu_to_be_32(*pdw) & frm_attr->fld_mask) \ > - DPAA2_PMD_DP_DEBUG("t %s : Yes", frm_attr->fld_name); \ > -} while (0) > - > -#define fa_print_sb_ext() \ > -do { \ > - if (rte_cpu_to_be_16(*pw) & frm_attr_ext->fld_mask) \ > - DPAA2_PMD_DP_DEBUG("\t %s : Yes", \ > - frm_attr_ext->fld_name); \ > -} while (0) > - > -#define fa_print_mb_ext() \ > -do { \ > - if (rte_cpu_to_be_16(*pw) & frm_attr_ext->fld_mask) \ > - DPAA2_PMD_DP_DEBUG("\t %s : 0x%02x", \ > - frm_attr_ext->fld_name, \ > - rte_cpu_to_be_16(*pw) & frm_attr_ext->fld_mask)= ;\ > -} while (0) > - > int dpaa2_eth_load_wriop_soft_parser(struct dpaa2_dev_priv *priv, > enum dpni_soft_sequence_dest dest) > { > diff --git a/lib/librte_eal/windows/eal/eal_lcore.c b/lib/librte_eal/wind= ows/eal/eal_lcore.c > index b3a6c63afa..8ee1d6fb78 100644 > --- a/lib/librte_eal/windows/eal/eal_lcore.c > +++ b/lib/librte_eal/windows/eal/eal_lcore.c > @@ -27,6 +27,8 @@ static struct _wcpu_map { > void > eal_create_cpu_map() > { > + unsigned int socket, core, lcore; > + > wcpu_map.total_procs =3D > GetActiveProcessorCount(ALL_PROCESSOR_GROUPS); > > @@ -53,10 +55,9 @@ eal_create_cpu_map() > * across the logical cores. For now, split the cores > * equally across the sockets. > */ > - unsigned int lcore =3D 0; > - for (unsigned int socket =3D 0; socket < > - wcpu_map.proc_sockets; ++socket) { > - for (unsigned int core =3D 0; > + lcore =3D 0; > + for (socket =3D 0; socket < wcpu_map.proc_sockets; ++socket) { > + for (core =3D 0; > core < (wcpu_map.proc_cores / wcpu_map.proc_socke= ts); > ++core) { > wcpu_map.wlcore_map[lcore] > -- > 2.25.0 > LGTM once size_t is fixed. --=20 David Marchand