[Mesa-dev] [PATCH 4/4] glx: use memcmp instead of strncmp

Vlad Golovkin vlad.golovkin.mail at gmail.com
Wed May 31 02:31:16 UTC 2017


2017-05-31 2:42 GMT+03:00 Ian Romanick <idr at freedesktop.org>:
> Same comment here as on patch 3.
>

The size of glxextensions.o is decreased by 8 bytes in debug build (I
am not sure why),
so in that regard there is next to no benefit.
But the main reason behind this change was not the size but the fact
that string lengths
were already being compared beforehand so why not avoid redundant checks in
strncmp?

> On 05/30/2017 03:45 PM, Vlad Golovkin wrote:
>> ---
>>  src/glx/glxextensions.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
>> index 22b078ce48..c0640d0b73 100644
>> --- a/src/glx/glxextensions.c
>> +++ b/src/glx/glxextensions.c
>> @@ -366,7 +366,7 @@ set_glx_extension(const struct extension_info *ext,
>>
>>     for (i = 0; ext[i].name != NULL; i++) {
>>        if ((name_len == ext[i].name_len)
>> -          && (strncmp(ext[i].name, name, name_len) == 0)) {
>> +          && (memcmp(ext[i].name, name, name_len) == 0)) {
>>           if (state) {
>>              SET_BIT(supported, ext[i].bit);
>>           }
>>
>


More information about the mesa-dev mailing list