From 49cf38ab98c9c222ed4f26b60f0463e9865ebbbf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 4 Sep 2014 18:00:53 -0700 Subject: [PATCH] Fix warnings about diff and base possibly not initialized This is a bogus warning by GCC, but it's easy to fix by having an "else" case with no extra conditions. Change-Id: I0f99527065138ff96c0613a57b0462613139900c Signed-off-by: Thiago Macieira --- csdk/ocrandom/src/ocrandom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csdk/ocrandom/src/ocrandom.c b/csdk/ocrandom/src/ocrandom.c index 836887d..8c2d0a4 100644 --- a/csdk/ocrandom/src/ocrandom.c +++ b/csdk/ocrandom/src/ocrandom.c @@ -120,14 +120,14 @@ uint32_t OCGetRandomRange(uint32_t firstBound, uint32_t secondBound){ uint32_t base; uint32_t diff; uint32_t result; - if(firstBound == secondBound){ - return secondBound; - }else if(firstBound > secondBound){ + if(firstBound > secondBound){ base = secondBound; diff = firstBound - secondBound; }else if(firstBound < secondBound){ base = firstBound; diff = secondBound - firstBound; + }else{ + return secondBound; } result = ((float)OCGetRandom()/((float)(0xFFFFFFFF))*(float)diff) + (float) base; return result; -- 2.7.4