From: Erich Keane Date: Thu, 11 Sep 2014 17:57:44 +0000 (-0700) Subject: Fix use of uninitialized variable X-Git-Tag: 1.2.0+RC1~2248 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47306784d04a2d90bf02e121f5166d2f7c6b8740;p=platform%2Fupstream%2Fiotivity.git Fix use of uninitialized variable If ctx == NULL, then VERIFY_NON_NULL would goto exit, which would then OCFree the uninitialized variables. Found by Clang: occoap.c:274:5: warning: variable 'rcvObserveOption' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] occoap.c:44:36: note: expanded from macro 'VERIFY_NON_NULL' #define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG_V(FATAL, TAG, "%s is NULL", #arg); goto exit;} } ^~~~ occoap.c:459:16: note: uninitialized use occurs here --Erich: rebase on master Change-Id: Ie829c6ac284dfd988eeeffad446d9872424e604a Signed-off-by: Thiago Macieira --- diff --git a/csdk/occoap/src/occoap.c b/csdk/occoap/src/occoap.c index 9e952b7..19dfa3f 100644 --- a/csdk/occoap/src/occoap.c +++ b/csdk/occoap/src/occoap.c @@ -255,8 +255,8 @@ static void HandleCoAPResponses(struct coap_context_t *ctx, OCClientResponse * clientResponse = NULL; ClientCB * cbNode = NULL; unsigned char * bufRes = NULL; - uint8_t * rcvObserveOption; - uint8_t * rcvMaxAgeOption; + uint8_t * rcvObserveOption = NULL; + uint8_t * rcvMaxAgeOption = NULL; uint32_t sequenceNumber = 0; uint32_t maxAge = 0; OCStackResult result = OC_STACK_ERROR;