From: Martin Quinson Date: Mon, 20 Nov 2023 07:49:27 +0000 (+0100) Subject: Fix a dead store reported by infer X-Git-Tag: v3.35~16 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/244ffce80a9e2390e24b9788114de037e4ccc0ae Fix a dead store reported by infer --- diff --git a/examples/sthread/pthread-producer-consumer.c b/examples/sthread/pthread-producer-consumer.c index 52a0080256..fe3fe5d960 100644 --- a/examples/sthread/pthread-producer-consumer.c +++ b/examples/sthread/pthread-producer-consumer.c @@ -45,9 +45,10 @@ static void* consumer(void* id) for (int i = 0; i < AmountConsumed; i++) { sem_wait(&full); pthread_mutex_lock(&mutex); - int item = buffer[out]; - if (do_output) + if (do_output) { + int item = buffer[out]; fprintf(stderr, "Consumer %d: Remove Item %d from %d\n", *((int*)id), item, out); + } out = (out + 1) % BufferSize; pthread_mutex_unlock(&mutex); sem_post(&empty);