Original Submission: In sps2lib.h:
FUNC:
static inline sps2Memory_t *sps2Allocate(
unsigned long ulSize,
int iMapOptions,
int iDeviceHandle
)
The variable iBlockOrder will never be set to 0, although there are multiple calculations involving the variable which show that this behavior is probably unexpected.
The code in question:
// we only have 8 bits maximum of map options
if (iMapOptions & (~0xff)) {
errno=-EINVAL;
return (sps2Memory_t *) -1;
}
iBlockOrder=iMapOptions & 7;
if (iBlockOrder > 0 || iBlockOrder<0) {
errno=-EINVAL;
return (sps2Memory_t *) -1;
}
iBlockSize=1 << (SPS2_PAGE_SHIFT+iBlockOrder);
while (iBlockOrder>0 && ulSize<=((unsigned int) iBlockSize >> 1)) {
iBlockSize>>=1;
iBlockOrder--;
}
iMapOptions &= ~7;
iMapOptions |= iBlockOrder; |