[PATCH 13/20] rtems: Move _Partition_Is_buffer_area_aligned()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Nov 20 16:24:20 UTC 2020


On 20/11/2020 17:18, Gedare Bloom wrote:

> On Fri, Nov 20, 2020 at 6:34 AM Sebastian Huber
> <sebastian.huber at embedded-brains.de>  wrote:
>> On 20/11/2020 14:31, Joel Sherrill wrote:
>>
>>> Wasn't there Doxygen above it?
>> No.
>>> Needs comments
>> I think a one liner function with a very descriptive name needs no
>> comments if it is placed in a source file:
>>
>> static bool _Partition_Is_buffer_area_aligned( const void
>> *starting_address )
>> {
>>     return ( ( (uintptr_t) starting_address ) % CPU_SIZEOF_POINTER ) == 0;
>> }
> I disagree, this is worth one line to remind that buffers need to be
> aligned to a multiple of the pointer size (and are a multiple of the
> pointer size).
>
> Just because we can put the code in one line doesn't mean that its
> context is clear.

This function is no longer in a header file. It is in a source file 
right next to the code which calls this function. The function name 
_Partition_Is_buffer_area_aligned() tells you that the function checks 
if the buffer area is aligned. The code

( ( (uintptr_t) starting_address ) % CPU_SIZEOF_POINTER ) == 0;

tells you exactly that the address is aligned if and only if it is an integral multiple of the pointer size. Which information is missing which justifies a comment?

-- 
embedded brains GmbH
Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
Phone: +49-89-18 94 741 - 16
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

embedded brains GmbH
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/



More information about the devel mailing list