From patchwork Mon Dec 3 15:26:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 1834301 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 951F83FC5A for ; Mon, 3 Dec 2012 15:26:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754626Ab2LCP0L (ORCPT ); Mon, 3 Dec 2012 10:26:11 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:40738 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754613Ab2LCP0L (ORCPT ); Mon, 3 Dec 2012 10:26:11 -0500 Received: by mail-la0-f46.google.com with SMTP id p5so2365349lag.19 for ; Mon, 03 Dec 2012 07:26:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=6KtYHUVwu0RCMZ/7lrcU8s55wk+Jl8R71+HRqaDZUjM=; b=gA3H4Y0X/zI9dWYZOOpeQUT9iqplyBi2OIaaocNLVP4Vln+oMRN/NeyPHefmz2PQJ2 UM3Y0EpwnORSOFI306c/Dp253shKeXd/4QAFXBMcRCWPW6M7D9pHwi2FlxMxReDxfaIp vZdVdhGwM1sXc5GagfoUH1bHhLIICo+QtedQGPToTrvJNhvof8cfJjsB89bNCYo6a1sq fDK6eBVt19i2lLDrf+nhTE0hUrmROiAdSJZmkfKi03smaGhlWzG3+GV67Z8LKZTmetXF aYcXezVJMtAcqiax25v/4omGVatUEZTGEIG8sN1XxZ8kwQ/LkJIr4M40nxwdPj4CZc84 WgTA== Received: by 10.112.27.99 with SMTP id s3mr4431907lbg.81.1354548370311; Mon, 03 Dec 2012 07:26:10 -0800 (PST) Received: from [192.168.1.102] (c-71-192-10-85.hsd1.ma.comcast.net. [71.192.10.85]) by mx.google.com with ESMTPS id jk8sm5467732lab.7.2012.12.03.07.26.08 (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 07:26:09 -0800 (PST) Message-ID: <50BCC48F.4070705@dev.mellanox.co.il> Date: Mon, 03 Dec 2012 10:26:07 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Alex Netes CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH] opensm/osm_ucast_ftree.c: Eliminate unneeded NULL pointer checks prior to calls to free X-Gm-Message-State: ALoCoQkfQ08ElPkSJF/eIv4AGoXrdwDcnqUQV1avN1yhosl0BXLGJuQlELdLz0ucoOwZtnegkiEE Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Hal Rosenstock --- opensm/osm_ucast_ftree.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/opensm/osm_ucast_ftree.c b/opensm/osm_ucast_ftree.c index 133fd4f..d58fff1 100644 --- a/opensm/osm_ucast_ftree.c +++ b/opensm/osm_ucast_ftree.c @@ -341,8 +341,6 @@ static ftree_sw_tbl_element_t *sw_tbl_element_create(IN ftree_sw_t * p_sw) static void sw_tbl_element_destroy(IN ftree_sw_tbl_element_t * p_element) { - if (!p_element) - return; free(p_element); } @@ -370,8 +368,7 @@ static ftree_port_t *port_create(IN uint8_t port_num, static void port_destroy(IN ftree_port_t * p_port) { - if (p_port) - free(p_port); + free(p_port); } /*************************************************** @@ -609,12 +606,9 @@ static void sw_destroy(IN ftree_fabric_t * p_ftree, IN ftree_sw_t * p_sw) port_group_destroy(p_sw->sibling_port_groups[i]); for (i = 0; i < p_sw->up_port_groups_num; i++) port_group_destroy(p_sw->up_port_groups[i]); - if (p_sw->down_port_groups) - free(p_sw->down_port_groups); - if (p_sw->sibling_port_groups) - free(p_sw->sibling_port_groups); - if (p_sw->up_port_groups) - free(p_sw->up_port_groups); + free(p_sw->down_port_groups); + free(p_sw->sibling_port_groups); + free(p_sw->up_port_groups); free(p_sw); } /* sw_destroy() */ @@ -829,8 +823,7 @@ static void hca_destroy(IN ftree_hca_t * p_hca) for (i = 0; i < p_hca->up_port_groups_num; i++) port_group_destroy(p_hca->up_port_groups[i]); - if (p_hca->up_port_groups) - free(p_hca->up_port_groups); + free(p_hca->up_port_groups); free(p_hca); } @@ -1702,8 +1695,7 @@ static int fabric_create_leaf_switch_array(IN ftree_fabric_t * p_ftree) p_ftree->leaf_switches_num); Exit: - if (all_switches_at_leaf_level) - free(all_switches_at_leaf_level); + free(all_switches_at_leaf_level); OSM_LOG_EXIT(&p_ftree->p_osm->log); return res; } /* fabric_create_leaf_switch_array() */