Re: [PATCH 3/3] git help: group common commands by theme

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 8, 2015 at 5:17 PM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> On Fri, May 8, 2015 at 2:08 PM, Sébastien Guimmara
> <sebastien.guimmara@xxxxxxxxx> wrote:
>> On 05/06/2015 05:16 AM, Eric Sunshine wrote:
>>> Do you also want to sort the commands alphabetically within group?
>>> That is, something like this?
>>>
>>>      struct cmdname_help *e1 = elem1;
>>>      struct cmdname_help *e2 = elem2;
>>>
>>>      if (e1->group < e2->group)
>>>          return -1;
>>>      if (e1->group > e2->group)
>>>          return 1;
>>>      return strcmp(e1->name, e2->name);
>>>
>>>> +}
>>
>> Your version raises:
>>
>> help.c:223:28: warning: initialization discards ‘const’ qualifier from
>> pointer target type [enabled by default]
>>   struct cmdname_help *e1 = elem1;
>>                             ^
>> With the cast:
>> struct cmdname_help *e1 = (struct cmdname_help*)elem1;
>> It compiles without a warning (gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2)
>
> I'd rather change the type of struct cmdname_help to be const, such
> that it reads:
>
>       const struct cmdname_help *e1 = elem1;
>       const struct cmdname_help *e2 = elem2;
>
>       if (e1->group < e2->group)
>           return -1;
>       if (e1->group > e2->group)
>           return 1;
>       return strcmp(e1->name, e2->name);
>
> instead of casting if possible.

Right. That was just a quickly typed example in the email. The "real"
code should use a 'const' pointer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]