From: Sachin Agrawal Date: Fri, 20 Feb 2015 14:20:56 +0000 (-0800) Subject: Fixing errors reported by Klocwork tool X-Git-Tag: 0.9.1-alpha1~38^2~138 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c34ca53c74d2086a0800fc7d3db668976e1f7dc;p=contrib%2Fiotivity.git Fixing errors reported by Klocwork tool Error Report from Klocwork 1)FUNCRET.GEN: Non-void function does not return value : C and C++ : gen_sec_bin.cpp : Critical (1) : Analyze : Local 2)NPD.CHECK.MIGHT: Pointer 'fps' checked for NULL at line 123 may be dereferenced at line 132. : C and C++ : gen_sec_bin.cpp : Critical (1) : Analyze : Local 3)NPD.FUNC.MIGHT: Pointer 'fps' returned from call to function 'fopen' at line 123 may be NULL and may be dereferenced at line 132. : C and C++ : gen_sec_bin.cpp : Critical (1) : Analyze : Local 4)UNINIT.STACK.ARRAY.MIGHT: 'payload' array elements might be used uninitialized in this function. : C and C++ : ocserverbasicops.cpp : Critical (1) : Analyze : Local Change-Id: I970bc060191caf17b102b165bbe5656b079ad063 Signed-off-by: Sachin Agrawal Reviewed-on: https://gerrit.iotivity.org/gerrit/374 Tested-by: jenkins-iotivity Reviewed-by: Joseph Morrow Reviewed-by: Patrick Lankswert --- diff --git a/resource/csdk/stack/samples/linux/secure/gen_sec_bin.cpp b/resource/csdk/stack/samples/linux/secure/gen_sec_bin.cpp index 89b8369..e0a4e02 100644 --- a/resource/csdk/stack/samples/linux/secure/gen_sec_bin.cpp +++ b/resource/csdk/stack/samples/linux/secure/gen_sec_bin.cpp @@ -129,7 +129,7 @@ int main() if ((fpc = (FILE*) fopen("client_cred.bin", "wb")) != NULL) { - fwrite(oscd_c, SizeOfOCConfigData(oscd_c), 1, fps); + fwrite(oscd_c, SizeOfOCConfigData(oscd_c), 1, fpc); fclose(fpc); } @@ -165,5 +165,6 @@ int main() printStruct("Server", (OCSecConfigData*)buf_s); printStruct("Client", (OCSecConfigData*)buf_c); + return 1; } diff --git a/resource/csdk/stack/samples/linux/secure/ocserverbasicops.cpp b/resource/csdk/stack/samples/linux/secure/ocserverbasicops.cpp index acaa52b..4105740 100644 --- a/resource/csdk/stack/samples/linux/secure/ocserverbasicops.cpp +++ b/resource/csdk/stack/samples/linux/secure/ocserverbasicops.cpp @@ -225,7 +225,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerResult ehResult = OC_EH_ERROR; OCEntityHandlerResponse response; - char payload[MAX_RESPONSE_LENGTH]; + char payload[MAX_RESPONSE_LENGTH] = {0}; if (flag & OC_INIT_FLAG) { @@ -256,6 +256,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, { OC_LOG_V (INFO, TAG, "Received unsupported method %d from client", entityHandlerRequest->method); + ehResult = OC_EH_ERROR; } if (ehResult == OC_EH_OK)