From patchwork Mon Nov 12 19:51:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1730201 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 70499E00DD for ; Mon, 12 Nov 2012 19:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888Ab2KLTvK (ORCPT ); Mon, 12 Nov 2012 14:51:10 -0500 Received: from prdiron-3.llnl.gov ([128.15.143.173]:54984 "EHLO prdiron-3.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752577Ab2KLTvK (ORCPT ); Mon, 12 Nov 2012 14:51:10 -0500 X-Attachments: Received: from eris.llnl.gov (HELO trebuchet.chaos) ([128.115.7.7]) by prdiron-3.llnl.gov with SMTP; 12 Nov 2012 11:51:10 -0800 Date: Mon, 12 Nov 2012 11:51:10 -0800 From: Ira Weiny To: "linux-rdma@vger.kernel.org" Cc: Alex Netes Subject: [PATCH 2/2] opensm: fix missing newline on DR path log messages Message-Id: <20121112115110.b72a88a6412859038bbad664@llnl.gov> X-Mailer: Sylpheed 3.2.0 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Ira Weiny --- opensm/osm_helper.c | 46 ++++++++++++++++++++++++++++++---------------- 1 files changed, 30 insertions(+), 16 deletions(-) diff --git a/opensm/osm_helper.c b/opensm/osm_helper.c index 578f54a..78286a2 100644 --- a/opensm/osm_helper.c +++ b/opensm/osm_helper.c @@ -2791,20 +2791,21 @@ void osm_dump_sa_mad_v2(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad, } } -static void osm_dump_dr_path_to_buf(IN const osm_dr_path_t * p_path, +static int osm_dump_dr_path_to_buf(IN const osm_dr_path_t * p_path, OUT char * buf, IN size_t buf_size) { + unsigned n = 0; + if (!buf || !p_path) - return; + return 0; else { - unsigned n = 0; - - n = sprintf(buf, "Directed Path Dump of %u hop path: " + n = snprintf(buf, buf_size, "Directed Path Dump of %u hop path: " "Path = ", p_path->hop_count); - sprint_uint8_arr(buf + n, buf_size - n, p_path->path, + n += sprint_uint8_arr(buf + n, buf_size - n, p_path->path, p_path->hop_count + 1); } + return n; } void osm_dump_dr_path(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path, @@ -2813,7 +2814,10 @@ void osm_dump_dr_path(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path, if (osm_log_is_active(p_log, log_level)) { char buf[BUF_SIZE]; - osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE); + int n = osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE); + if (n == BUF_SIZE) + n--; + buf[n] = '\n'; osm_log(p_log, log_level, buf); } @@ -2825,30 +2829,34 @@ void osm_dump_dr_path_v2(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path, if (osm_log_is_active_v2(p_log, log_level, file_id)) { char buf[BUF_SIZE]; - osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE); + int n = osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE); + if (n == BUF_SIZE) + n--; + buf[n] = '\n'; osm_log_v2(p_log, log_level, file_id, buf); } } -static void osm_dump_smp_dr_path_to_buf(IN const ib_smp_t * p_smp, +static int osm_dump_smp_dr_path_to_buf(IN const ib_smp_t * p_smp, OUT char * buf, IN size_t buf_size) { + unsigned n = 0; + if (!buf || !p_smp) - return; + return 0; else { - unsigned n; - - n = sprintf(buf, "Received SMP on a %u hop path: " + n = snprintf(buf, buf_size, "Received SMP on a %u hop path: " "Initial path = ", p_smp->hop_count); n += sprint_uint8_arr(buf + n, buf_size - n, p_smp->initial_path, p_smp->hop_count + 1); - n += snprintf(buf + n, ", Return path = "); + n += snprintf(buf + n, buf_size - n, ", Return path = "); n += sprint_uint8_arr(buf + n, buf_size - n, p_smp->return_path, p_smp->hop_count + 1); } + return n; } void osm_dump_smp_dr_path(IN osm_log_t * p_log, IN const ib_smp_t * p_smp, @@ -2857,7 +2865,10 @@ void osm_dump_smp_dr_path(IN osm_log_t * p_log, IN const ib_smp_t * p_smp, if (osm_log_is_active(p_log, log_level)) { char buf[BUF_SIZE]; - osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE); + int n = osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE); + if (n == BUF_SIZE) + n--; + buf[n] = '\n'; osm_log(p_log, log_level, buf); } @@ -2869,7 +2880,10 @@ void osm_dump_smp_dr_path_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp, if (osm_log_is_active_v2(p_log, log_level, file_id)) { char buf[BUF_SIZE]; - osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE); + int n = osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE); + if (n == BUF_SIZE) + n--; + buf[n] = '\n'; osm_log_v2(p_log, log_level, file_id, buf); }