This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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 v2 1/5] mips: Do not malloc on getdents64 fallback



On 08/10/2019 16:59, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>>> +      memcpy (DP_MEMBER (dp, struct dirent64, d_reclen), &new_reclen,
>>>> +	      sizeof ((struct dirent64){0}.d_reclen));
>>>
>>> That looks wrong.  DP_MEMBER (dp, struct dirent64, d_reclen) is a
>>> temporary object, so the outer memcpy is dead.
>>
>> Sigh, indeed. I changed to:
>>
>>    memcpy (((char *)(dp) + offsetof (struct dirent64, d_reclen)),
>>            &new_reclen, sizeof ((struct dirent64){0}.d_reclen));
> 
> sizeof ((struct dirent64){0}.d_reclen) could just be
> sizeof (new_reclen).  After all, this only works if they are the same.

Ack.

> 
> I guess -fno-strict-aliasing looks more attractive now. 8-/
> 
> You probably should write ((char *) dp) instead of (char *)(dp) if you
> want to make the operator precedence explicit, or at least drop the
> parentheses around dp.  (I think the cast binds tighter than the +,
> but I can't really remember.  I tend to write the paranetheses.)
> 

Ack.


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