From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <Juhamatti.Kuusisaari@coriant.com>
Received: from EUR01-VE1-obe.outbound.protection.outlook.com
 (mail-ve1eur01on0083.outbound.protection.outlook.com [104.47.1.83])
 by dpdk.org (Postfix) with ESMTP id A984A8E5F
 for <dev@dpdk.org>; Wed, 18 Apr 2018 12:49:08 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=coriant.onmicrosoft.com; s=selector1-coriant-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;
 bh=qUO5/SgIiB33IDNpem+zPQKSgXK5c6TGK/lRUkOizVc=;
 b=RwAMAFlFqB5o5yjlwuQIVi3ZCrsPzWq6dJv174IiCDhRNSaL/8hFWXRI4qNo9qwMy1LndNq4/2Ho0NTg7P1P7eRw4+nzuRl6FcZB15nmRtHwQALsVTJvr2hW38ogJDvkvQG0KAKmoesCsNY8KldjatzbklOrLltLMCeQZe4vxy4=
Received: from AM0PR04MB4291.eurprd04.prod.outlook.com (52.134.126.146) by
 AM0PR04MB4324.eurprd04.prod.outlook.com (52.134.126.155) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id
 15.20.696.13; Wed, 18 Apr 2018 10:49:07 +0000
Received: from AM0PR04MB4291.eurprd04.prod.outlook.com
 ([fe80::814a:81f9:1d80:bdd7]) by AM0PR04MB4291.eurprd04.prod.outlook.com
 ([fe80::814a:81f9:1d80:bdd7%13]) with mapi id 15.20.0675.015; Wed, 18 Apr
 2018 10:49:07 +0000
From: "Kuusisaari, Juhamatti" <Juhamatti.Kuusisaari@coriant.com>
To: Bruce Richardson <bruce.richardson@intel.com>, Thomas Monjalon
 <thomas@monjalon.net>
CC: Scott Branden <scott.branden@broadcom.com>, Stephen Hemminger
 <stephen@networkplumber.org>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [RFC] checkpatch: don't complain about SPDX tag format
Thread-Index: AQHT1pheqjEP+rWz8UK2vUMHq8GrrKQFhPGAgAACEYCAALH4gIAAAE9A
Date: Wed, 18 Apr 2018 10:49:07 +0000
Message-ID: <AM0PR04MB429115D47C2A69F0C499BAFD9DB60@AM0PR04MB4291.eurprd04.prod.outlook.com>
References: <20180417214919.8246-1-stephen@networkplumber.org>
 <2994859.WyYqfpDCHC@xps> <f4743db9-8e33-550d-0456-4f932e72f96c@broadcom.com>
 <4245883.kl7A9e8lPX@xps>
 <20180418085605.GA111744@bricha3-MOBL.ger.corp.intel.com>
In-Reply-To: <20180418085605.GA111744@bricha3-MOBL.ger.corp.intel.com>
Accept-Language: fi-FI, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: intel.com; dkim=none (message not signed)
 header.d=none;intel.com; dmarc=none action=none header.from=coriant.com;
x-originating-ip: [138.111.134.175]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; AM0PR04MB4324;
 7:M6UjoWV0ous7mGWTQmnTzFWswPl2Apgp7MD9tR962WmmNfTSuZDdwc3daXNsL6fcVg11no+YCFzqmkXTpagwSsw3QE+rkNQUhTTcO2eAz7jfXUh3eQ9D3inVgYg2H2lTyJFV4cwNZiY9t3e9/Qph8EDR/JkvPoD+t9YK8cR1C4xT67WSRIvB/Mu9gpduWuHecABo7Dmh1hGkm1tgzWmlFjCwUCftC8cm0i5ybRtqoj/zY1/goOhMyPNa2BYdsO4h
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
 RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020);
 SRVR:AM0PR04MB4324; 
x-ms-traffictypediagnostic: AM0PR04MB4324:
x-microsoft-antispam-prvs: <AM0PR04MB4324F14B18B37A4803F38AE19DB60@AM0PR04MB4324.eurprd04.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(788757137089);
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231232)(944501327)(52105095)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011);
 SRVR:AM0PR04MB4324; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4324; 
x-forefront-prvs: 06469BCC91
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(396003)(376002)(366004)(346002)(39380400002)(39860400002)(377424004)(305945005)(86362001)(72206003)(6246003)(74316002)(110136005)(5250100002)(93886005)(66066001)(53936002)(54906003)(316002)(6116002)(102836004)(2906002)(6506007)(53546011)(55016002)(8936002)(9686003)(3846002)(6436002)(76176011)(476003)(59450400001)(25786009)(7696005)(81166006)(11346002)(446003)(186003)(4326008)(26005)(33656002)(478600001)(5660300001);
 DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4324;
 H:AM0PR04MB4291.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; MLV:sfv; 
x-microsoft-antispam-message-info: UuGEyc/QaV0u/UHvHr5C42MSekrbzqqQuvdF62rHL1gElX1eW6q/TMoJ4QzHEmUaXsfvv6wV4HieMJIxXVzgubkNkhaB52Vtff0yWj1E4Zy1+ad+adybeqwlzi7r+49VriJ3SpHsbGIWixEXIRgj+1fCeJsjMukmMoxmY+CgEx1rx0zn7NC6IMj5QL4fe+Ji
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Office365-Filtering-Correlation-Id: 3ea106ac-906c-4751-4bbe-08d5a51a02b1
X-OriginatorOrg: coriant.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 3ea106ac-906c-4751-4bbe-08d5a51a02b1
X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2018 10:49:07.5074 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 76595477-907e-4695-988b-a6b39087332d
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4324
Subject: Re: [dpdk-dev] [RFC] checkpatch: don't complain about SPDX
	tag	format
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 18 Apr 2018 10:49:08 -0000


Hello,

> On Wed, Apr 18, 2018 at 12:19:07AM +0200, Thomas Monjalon wrote:
> > 18/04/2018 00:11, Scott Branden:
> > > On 18-04-17 03:06 PM, Thomas Monjalon wrote:
> > > > 17/04/2018 23:49, Stephen Hemminger:
> > > >> IMHO would have been better to use the kernel SPDX style and keep
> > > >> the check but that appears to be a minority opinion.
> > > >
> > > > I think it is better to work on checkpatch itself.
> > > > When defining our SPDX style, Linux one was not definitive.
> > > > Do you think we can ask the Linux community to support our SPDX sty=
le?
> > > >
> > > I think it better to simply follow the Linux community defacto style
> > > rather than go your own way.
> >
> > But our way is better! :)
> > And it has been decided in the Technical Board.
> >
>=20
> As a general issue, I think we could do with having our own checkpatch-li=
ke
> script for performing addition DPDK-specific code-checks *after* Linux
> checkpatch ones. That is, reuse Linux check patch checks as much as possi=
ble,
> but have other checks too.
>=20
> For example, check for use of strcpy or strncpy (or snprintf with "%s") a=
nd
> suggest replacing with strlcpy. If we did have our own extension script, =
we
> could put our own SPDX format check there too.
>=20
> Thoughts, or any volunteers to look into this?

In addition, the checkpatches.sh could be improved so that it actually chec=
ks that a proper file is found behind the selected env variable. I am plann=
ing to add this check (as it bite me just yesterday).

Speaking of strlcpy, I do think that it has a caveat* that everybody should=
 be aware of: depending on implementation, it may read unintended memory re=
gions when the source is not properly null terminated (like in Unix domain =
sockets, or just by other mistake). It may be a bad idea just blindly repla=
ce everything with strlcpy, without making sure that copied buffers are rea=
lly null-terminated in the first place or making sure the strlcpy version i=
s really a one that does not have this problem. As it depends on dynamic li=
braries, making sure may be difficult.
=20
Some may argue that this is unlikely and thus irrelevant. Why do I know abo=
ut it then? :) Needless to say, strncpy or snprintf do not have _this_ prob=
lem, although they have their own issues. Internally without dynamic libs D=
PDK rte_strlcpy uses snprintf which should be safe, though.

> /Bruce

--
 Juhamatti

 * A caveat on some implementations:=20
 ...
        /* Not enough room in dst, add NUL and traverse rest of src */
        if (n =3D=3D 0) {
                if (siz !=3D 0)
                        *d =3D '\0';              /* NUL-terminate dst */
                while (*s++) <- what happens when s is not null-terminated?
                        ;
        }
...
  Another one:
...
    return n + strlen (src); <- what happens when src is not null-terminate=
d?
...