This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, updated] Add support for setting disassembler-options in GDB for POWER, ARM and S390

On 02/16/2017 01:58 AM, Peter Bergner wrote:
> On 2/15/17 6:21 PM, Pedro Alves wrote:

>>> Easily done, as I've been doing just that internally.
>>> I'm frightened to say that I'm at v25 and counting. :-(
>> Internal revisions don't count, only public submissions.  :-)
> Well the number of public submissions isn't too far off my
> internal patches. :-)


>>>   Eg: "e500" & "e500mc", "ppc" & "ppc32" and "ppc64", etc.
>>> ...which strncmp cannot disambiguate, because it doesn't enforce the
>>> two strings have the same length.
>> You could handle that with:
>> if (optlen == strlen (valid_options->name[i])
>>     && strncmp (opt, optlen, valid_options->name[i]) == 0)
> Yes, but that involves two scans over the string, so...

This is far from performance critical code, but if you're
worried about the double-scan, then you could write it like this:

 if (strncmp (opt, valid_options->name[i], optlen) == 0
     && valid_options->name[optlen] == '\0')

Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]