From patchwork Wed Jul 31 06:04:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Domke X-Patchwork-Id: 2836084 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8369FC0319 for ; Wed, 31 Jul 2013 06:17:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88046201CB for ; Wed, 31 Jul 2013 06:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9D61201B8 for ; Wed, 31 Jul 2013 06:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754699Ab3GaGRa (ORCPT ); Wed, 31 Jul 2013 02:17:30 -0400 Received: from mail03.nap.gsic.titech.ac.jp ([131.112.13.22]:42623 "HELO mail03.nap.gsic.titech.ac.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754899Ab3GaGR3 (ORCPT ); Wed, 31 Jul 2013 02:17:29 -0400 X-Greylist: delayed 796 seconds by postgrey-1.27 at vger.kernel.org; Wed, 31 Jul 2013 02:17:29 EDT Received: from 131.112.13.37 by mail03.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(4347:0:AUTH_RELAY) (envelope-from ); Wed, 31 Jul 2013 15:04:11 +0900 (JST) Received: from [131.112.13.21] (mail02.nap.gsic.titech.ac.jp) by drweb2.nap.gsic.titech.ac.jp (Dr.Web MailD 6.0.2.0) with SMTP id 02DC062C; Wed, 31 Jul 2013 15:04:10 Received: from 131.112.29.200 by mail02.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(7403:0:AUTH_LOGIN) (envelope-from ); Wed, 31 Jul 2013 15:04:10 +0900 (JST) From: Jens Domke To: linux-rdma@vger.kernel.org Cc: Hal Rosenstock , Torsten Hoefler Subject: [PATCH 1/1] OpenSM: dfsssp - add missing and change existing return values Date: Wed, 31 Jul 2013 15:04:06 +0900 Message-Id: <1375250646-22892-1-git-send-email-domke.j.aa@m.titech.ac.jp> X-Mailer: git-send-email 1.7.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP a) this patch sets the 'err' variable correclty for the function dfsssp_remove_deadlocks() for the case, that the error occurs within the function and not within a subroutine b) the functions dfsssp_build_graph() and dfsssp_do_dijkstra_routing() now return -1 instead of 1 to indicate an error to be in compliance with the implementation of ucast_mgr_route() in osm_ucast_mgr.c Signed-off-by: Jens Domke --- opensm/osm_ucast_dfsssp.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/opensm/osm_ucast_dfsssp.c b/opensm/osm_ucast_dfsssp.c index a08e44b..321fffd 100644 --- a/opensm/osm_ucast_dfsssp.c +++ b/opensm/osm_ucast_dfsssp.c @@ -1158,7 +1158,7 @@ static int dfsssp_build_graph(void *context) if (!adj_list) { OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD02: cannot allocate memory for adj_list\n"); - return 1; + goto ERROR; } for (i = 0; i < adj_list_size; i++) set_default_vertex(&adj_list[i]); @@ -1198,7 +1198,7 @@ static int dfsssp_build_graph(void *context) OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD03: cannot allocate memory for a link\n"); dfsssp_context_destroy(context); - return 1; + goto ERROR; } head = link; head->next = NULL; @@ -1243,7 +1243,7 @@ static int dfsssp_build_graph(void *context) head = head->next; free(link); } - return 1; + goto ERROR; } link = link->next; set_default_link(link); @@ -1277,6 +1277,9 @@ static int dfsssp_build_graph(void *context) OSM_LOG_EXIT(p_mgr->p_log); return 0; + +ERROR: + return -1; } static void print_routes(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list, @@ -1891,6 +1894,7 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) if (!weakest_link) { OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD27: something went wrong in get_weakest_link_in_cycle(...)\n"); + err = 1; goto ERROR; } @@ -2012,6 +2016,7 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) if (!split_count) { OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD24: cannot allocate memory for split_count, skip balancing\n"); + err = 1; goto ERROR; } /* initial state: paths for VLs won't be separated */ @@ -2060,6 +2065,7 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD25: Not enough VL available (avail=%d, needed=%d); Stop dfsssp routing!\n", vl_avail, vl_needed); + err = 1; goto ERROR; } /* else { no balancing } */ @@ -2161,7 +2167,7 @@ static int dfsssp_do_dijkstra_routing(void *context) if (!sw_list) { OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD29: cannot allocate memory for sw_list in dfsssp_do_dijkstra_routing\n"); - return 1; + goto ERROR; } memset(sw_list, 0, sw_list_size * sizeof(vertex_t *)); @@ -2197,7 +2203,7 @@ static int dfsssp_do_dijkstra_routing(void *context) OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD31: corrupted sw_list array in dfsssp_do_dijkstra_routing\n"); free(sw_list); - return 1; + goto ERROR; } } @@ -2240,7 +2246,7 @@ static int dfsssp_do_dijkstra_routing(void *context) err = dijkstra(p_mgr, adj_list, adj_list_size, port, lid); if (err) - return err; + goto ERROR; if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG)) print_routes(p_mgr, adj_list, adj_list_size, port); @@ -2249,7 +2255,7 @@ static int dfsssp_do_dijkstra_routing(void *context) err = update_lft(p_mgr, adj_list, adj_list_size, port, lid); if (err) - return err; + goto ERROR; /* add weights for calculated routes to adjust the weights for the next cycle */ update_weights(p_mgr, adj_list, adj_list_size); @@ -2268,14 +2274,14 @@ static int dfsssp_do_dijkstra_routing(void *context) /* remove potential deadlocks by assigning different virtual lanes to src/dest paths and balance the lanes */ err = dfsssp_remove_deadlocks(dfsssp_ctx); if (err) - return err; + goto ERROR; } else if (dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_SSSP) { OSM_LOG(p_mgr->p_log, OSM_LOG_INFO, "SSSP routing specified -> skipping deadlock removal thru dfsssp_remove_deadlocks(...)\n"); } else { OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR AD28: wrong routing engine specified in dfsssp_ctx\n"); - return 1; + goto ERROR; } /* print the new_lft for each switch after routing is done */ @@ -2300,6 +2306,9 @@ static int dfsssp_do_dijkstra_routing(void *context) OSM_LOG_EXIT(p_mgr->p_log); return 0; + +ERROR: + return -1; } /* meta function which calls subfunctions for finding the optimal switch