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

Reply via email to