From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH v3 iproute2 2/3] tc: Add support for the ETF Qdisc Date: Mon, 9 Jul 2018 11:32:35 -0600 Message-ID: References: <20180705224227.22843-1-jesus.sanchez-palencia@intel.com> <20180705224227.22843-3-jesus.sanchez-palencia@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Vinicius Costa Gomes To: Jesus Sanchez-Palencia , netdev@vger.kernel.org Return-path: Received: from mail-pl0-f68.google.com ([209.85.160.68]:35431 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933593AbeGIRci (ORCPT ); Mon, 9 Jul 2018 13:32:38 -0400 Received: by mail-pl0-f68.google.com with SMTP id k1-v6so6348606plt.2 for ; Mon, 09 Jul 2018 10:32:38 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 7/9/18 9:48 AM, Jesus Sanchez-Palencia wrote: > Hi David, > > > On 07/06/2018 08:58 AM, David Ahern wrote: >> On 7/5/18 4:42 PM, Jesus Sanchez-Palencia wrote: >> >>> +static int get_clockid(__s32 *val, const char *arg) >>> +{ >>> + const struct static_clockid { >>> + const char *name; >>> + clockid_t clockid; >>> + } clockids_sysv[] = { >>> + { "CLOCK_REALTIME", CLOCK_REALTIME }, >>> + { "CLOCK_TAI", CLOCK_TAI }, >>> + { "CLOCK_BOOTTIME", CLOCK_BOOTTIME }, >>> + { "CLOCK_MONOTONIC", CLOCK_MONOTONIC }, >>> + { NULL } >>> + }; >>> + >>> + const struct static_clockid *c; >>> + >>> + for (c = clockids_sysv; c->name; c++) { >>> + if (strncasecmp(c->name, arg, 25) == 0) { >> >> Why 25? > > > That was just an upper bound giving some room beyond the longest > clockid name we have today. Should I add a define MAX_CLOCK_NAME ? why not just strcasecmp? using the 'n' variant with n > strlen of either argument seems pointless. > > >> >> be nice to allow shortcuts -- e.g., just REALTIME or realtime. > > > I'd rather just keep it as is and use the names as they are defined for > everything else (i.e. CLOCK_REALTIME), unless there are some strong objections. An all caps argument is unnecessary work on the pinky finger and the CLOCK_ prefix is redundant to the keyword. Really, just a thought on making it easier for users. A CLI argument does not need to maintain a 1:1 with code names.