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: RFC: Aligning data in buffers with a macro?


On Sun, Apr 1, 2012 at 12:30 PM, Marek Polacek <polacek@redhat.com> wrote:
>> ?628 # elif _STACK_GROWS_UP
>> ?629 ? ? ? ? ? char *guard = (char *) ALIGN_DOWN((uintptr_t) pd -
>> guardsize, pagesize_m1);
>> ?630 #endif
>
> To be honest, that doesn't make much difference to me. ?The second
> variant is not shorter nor more readable I suspect. ?Also I have
> a qualm about these changes--they might be quite error-prone.

It is my opinion that using a macro with a clear purpose makes the
code more understandable e.g. Are you aligning up, or down, and to
what alignment?

We could shorten it to _ALIGND(...) or _ALIGNU().

I do *not* propose we go through and fixup everything.

I do propose using the alignment macros when writing new code or
fixing existing code to make the intent of the action clear.

I would rather learn to read through _ALIGND and _ALIGNU than have to
do the masking operations mentally to figure out what the author
intended.

Cheers,
Carlos.


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