Message ID | 20170920042734.13574-1-stewart@linux.vnet.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | hdat: logically dead code, assert instead | expand |
Stewart Smith <stewart@linux.vnet.ibm.com> writes: > Since we already assert that base != NULL, the if() > condition on hdif can never be NULL. Instead, we should > just assert (if even that) if it is. > > Found by Coverity > > Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> > --- > hdata/spira.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Merged to master as of 8599e8ad69052e5dfcc2625dab1211302fb45f9a
diff --git a/hdata/spira.c b/hdata/spira.c index 525376809f55..7be53b9b088b 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -313,8 +313,7 @@ static const void *xscom_to_pcrd(struct dt_node *xscom, int idata_index) assert(i < be16_to_cpu(t->act_cnt)); hdif = base + i * be32_to_cpu(t->alloc_len); - if (!hdif) - return NULL; + assert(hdif); if (idata_index == GET_HDIF_HDR) return hdif;
Since we already assert that base != NULL, the if() condition on hdif can never be NULL. Instead, we should just assert (if even that) if it is. Found by Coverity Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> --- hdata/spira.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)