From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesus Sanchez-Palencia Subject: Re: [PATCH v3 iproute2 2/3] tc: Add support for the ETF Qdisc Date: Mon, 9 Jul 2018 16:16:02 -0700 Message-ID: <4da66c36-9579-dc5c-b2cf-c56fe8d34a6a@intel.com> 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: David Ahern , netdev@vger.kernel.org Return-path: Received: from mga11.intel.com ([192.55.52.93]:20957 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754502AbeGIXVI (ORCPT ); Mon, 9 Jul 2018 19:21:08 -0400 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 07/09/2018 10:32 AM, David Ahern wrote: > 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. Ok, will fix. > >> >> >>> >>> 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. Lower case already works given the strncasecmp() usage but, fair enough, I will modify the implementation so it accepts both CLOCK_FOO or FOO (lower case included), and will make it print one of the two strings during print_opt(). Thanks, Jesus