kernel: umem: fix img_get macro

The img_get macro used to subtract 1 to the argument provided before
computing the porinter to the image. I can't remember why it did so.

However the expression was wrong.

Coverity found the issue:

	Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
	CID:	155616, 155606, 155598, 155597, 155596, 155587,
		155580, 155578, 155577, 155576, 155568, 155566

Simply removing the subtraction seems the obvious fix.
This commit is contained in:
Giacomo Tesio 2017-08-15 00:38:09 +02:00
parent b056df2da6
commit 0b8a66f877
1 changed files with 1 additions and 1 deletions

View File

@ -88,7 +88,7 @@ static RWlock pool_lock; /* to grow chunks or modify free list */
static ImagePool pool;
#define img_hash(path) ((uint8_t)((path*(PSTEP+1))&(PSTEP-1)))
#define img_get(ptr) (&(pool.chunks[(uint8_t)(ptr-1)>>8]->images[(uint8_t)(ptr-1)&(PSTEP-1)]))
#define img_get(ptr) (&(pool.chunks[(uint8_t)((ptr)>>8)]->images[(uint8_t)((ptr)&(PSTEP-1))]))
void
imagepool_init(short max_images)