eina_safepointer: Fix coverity warning

I guess the overflow was badly handled. Fixing it by using
explicit int intermediate value.

Fixes CID 1356616 and 1356619:

Operands don't affect result
Logically dead code
This commit is contained in:
Jean-Philippe Andre 2016-07-13 16:22:00 +09:00
parent 9cf72fe80a
commit 4d9de121d1
1 changed files with 3 additions and 3 deletions

View File

@ -239,6 +239,7 @@ eina_safepointer_register(const void *target)
Eina_Memory_Table *table;
Eina_Memory_Entry *entry = NULL;
Eina_Sp_Id id = 0;
unsigned int gen;
// We silently handle NULL
if (!target) return NULL;
@ -254,9 +255,8 @@ eina_safepointer_register(const void *target)
entry->ptr = (void*) target;
entry->active = 1;
entry->generation++;
if (entry->generation == EINA_MAX_GENERATIONS)
entry->generation = 1;
gen = entry->generation + 1;
entry->generation = (gen == EINA_MAX_GENERATIONS) ? 1 : gen;
id = SP_COMPOSE_FINAL_ID(table->partial_id,
(entry - table->entries),