From 6924ac0d1c39cfc2ff29a21b3a32ba9378973b02 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sun, 5 Mar 2023 17:35:16 +0100 Subject: [PATCH] Sonar smells. --- examples/sthread/pthread-producer-consumer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/sthread/pthread-producer-consumer.c b/examples/sthread/pthread-producer-consumer.c index 8073105582..52a0080256 100644 --- a/examples/sthread/pthread-producer-consumer.c +++ b/examples/sthread/pthread-producer-consumer.c @@ -57,7 +57,7 @@ static void* consumer(void* id) int main(int argc, char** argv) { - char opt; + int opt; while ((opt = getopt(argc, argv, "c:C:p:P:q")) != -1) { switch (opt) { case 'q': @@ -75,7 +75,7 @@ int main(int argc, char** argv) case 'P': ProducerCount = atoi(optarg); break; - case '?': + default: /* '?' */ printf("unknown option: %c\n", optopt); break; } @@ -87,7 +87,7 @@ int main(int argc, char** argv) sem_init(&empty, 0, BufferSize); sem_init(&full, 0, 0); - int* ids = malloc(sizeof(int) * ((ProducerCount + ConsumerCount))); + int* ids = malloc(sizeof(int) * (ProducerCount + ConsumerCount)); for (int i = 0; i < ProducerCount + ConsumerCount; i++) ids[i] = i + 1; // The identity of each thread (for debug messages) -- 2.20.1