IOT-2539 Fixed incompatible-pointer-types warning 05/22205/3
authorGeorge Nash <george.nash@intel.com>
Tue, 15 Aug 2017 19:50:20 +0000 (12:50 -0700)
committerRick Bell <richard.s.bell@intel.com>
Mon, 18 Sep 2017 17:38:45 +0000 (17:38 +0000)
commit7c0aa196aaa1236b3b351a8fb7a06f73028156ad
treef32d4cc8c8c1b1beb31e9eb9c4ef90492475216a
parenta686d2177fefb7c092b8cb09a9350a084ff6b85f
IOT-2539 Fixed incompatible-pointer-types warning

The function GetResourceFromHandle was returning a PIResource**. When
the actual code was inspected it was returning a PIResourceBase** that
was being cast to a PIResource**. That value was then used as a
PIResource**. The only reason this code worked is because the way C
lays out structs in memory is sequential Since the first element of the
PIResoruceBase is a PIResource treating the the PIResourceBase like
a PIResource worked only by virtue of the memory layout rules for C
structs.

Later in the zigbee_wapper.c it relies again on the memory layout
rules for structs to assign PIResource** to a PIResource_Zigbee**.

This relies too much on internal knowledge of memory layout and is
a potential management problem. The code tied 3 structs together
based on there memory layout.

To fix the issue. The GetResourceFromHandle now returns PIResourceBase**
which was the actual type returned. In the cleanup code the pointer
is change from PIResource* to PIResourceBase*. Now when the value is
passed into the DeleteResource function it no longer generates the
incompatible-pointer-types warning.

In zigbee_wrapper.c we no longer cast the PIResource_Zigbee* to
PIResource* we now pass in the part of the PIResource_Zigbee that is
actually the PIResourceBase.

Bug: https://jira.iotivity.org/browse/IOT-2539
Change-Id: I6b147a52c522d036d016e2cd15e2900e6fc06249
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21927
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mats Wichmann <mats@linux.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
(cherry picked from commit 25898d822bea23ec7f19b6858026de493031c70e)
plugins/include/internal/pluginlist.h
plugins/src/plugininterface.c
plugins/src/pluginlist.c
plugins/zigbee_wrapper/src/zigbee_wrapper.c