From 4d9de121d174873ff254046f1eec17171197e5b3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 13 Jul 2016 16:22:00 +0900 Subject: [PATCH] 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 --- src/lib/eina/eina_safepointer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eina/eina_safepointer.c b/src/lib/eina/eina_safepointer.c index 42433ea882..94ec1ab557 100644 --- a/src/lib/eina/eina_safepointer.c +++ b/src/lib/eina/eina_safepointer.c @@ -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),