#1535 closed defect (fixed)

doubts on test_posix_memalign

Reported by: Ralf Corsepius Owned by: Joel Sherrill
Priority: normal Milestone: 4.10
Component: unspecified Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

I am having several doubts on test_posix_memalign-test in
testsuites/libtests/malloctest/init.c

a) The maxShift-loop iterates over "sizeof(int)" to set up the 2nd arg of posix_memalign.

However, posix_memalign's 2nd arg is a size_t, not an int. Therefore, the loop should iterate over a sizeof(size_t), IMO.

b) The computation of maxShift can be improved.
Instead of an if sizeof(X) == Y cascade, it can be computed from
(sizeof(X) * CHAR_BIT)

c) SUSv4 says:
"The posix_memalign() function shall allocate size bytes aligned on a boundary specified by alignment, and shall return a pointer to the allocated memory in memptr. The value of alignment shall be a power of two multiple of
sizeof( void *)."

Linux's man posix_memalign says:
"... alignment, which must be a power of two and a multiple of sizeof(void *)."

AFAIU, test_posix_memalign does not take this consideration into account, instead it starts its checks at "2".

Attachments (2)

rtems-test_posix_memalign.diff (1.6 KB) - added by Ralf Corsepius on May 29, 2010 at 2:57:27 AM.
Address issues a) and b) from previous comment
pr1535.diff (1.7 KB) - added by Joel Sherrill on Jun 24, 2010 at 9:51:39 PM.
Patch with sizeof(void*) issue addressed V1

Download all attachments as: .zip

Change History (4)

Changed on May 29, 2010 at 2:57:27 AM by Ralf Corsepius

Address issues a) and b) from previous comment

Changed on Jun 24, 2010 at 9:51:39 PM by Joel Sherrill

Attachment: pr1535.diff added

Patch with sizeof(void*) issue addressed V1

comment:1 Changed on Jul 14, 2010 at 10:23:37 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

Attached patches committed since no comments since 24 June.

comment:2 Changed on Oct 10, 2017 at 6:46:55 AM by Sebastian Huber

Component: testingunspecified
Note: See TracTickets for help on using tickets.