[ofa-general] [PATCH] opensm: osm_opensm.c - changed load_plugins() arg to const

Timothy A. Meier meier3 at llnl.gov
Thu Aug 28 15:36:20 PDT 2008


Sasha,
   I am doing some plugin work, and ran into both of the cases this patch addresses.

 From 680195f393a8c3a5036fc1c8afe76ae7bac5d3cb Mon Sep 17 00:00:00 2001
From: Tim Meier <meier3 at llnl.gov>
Date: Thu, 28 Aug 2008 15:10:35 -0700
Subject: [PATCH] opensm: osm_opensm.c - changed load_plugins() arg to const

Made a copy of the list of plugin names, so the parser would
not destroy the original copy.  Also now supports passing in
pointers to string constants.

Signed-off-by: Tim Meier <meier3 at llnl.gov>
---
  opensm/opensm/osm_opensm.c |    8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index 6cf4726..65fd632 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -244,12 +244,13 @@ void osm_opensm_destroy(IN osm_opensm_t * const p_osm)
  	osm_log_destroy(&p_osm->log);
  }

-static void load_plugins(osm_opensm_t *osm, char *plugin_names)
+static void load_plugins(osm_opensm_t *osm, const char *plugin_names)
  {
  	osm_epi_plugin_t *epi;
-	char *name, *p;
+	char *p_names, *name, *p;

-	name = strtok_r(plugin_names, " \t\n", &p);
+	p_names = strdup(plugin_names);
+	name = strtok_r(p_names, " \t\n", &p);
  	while (name && *name) {
  		epi = osm_epi_construct(osm, name);
  		if (!epi)
@@ -259,6 +260,7 @@ static void load_plugins(osm_opensm_t *osm, char *plugin_names)
  			cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
  		name = strtok_r(NULL, " \t\n", &p);
  	}
+	free(p_names);
  }

  /**********************************************************************
-- 
1.5.4.5


-- 
Timothy A. Meier
Computer Scientist
ICCD/High Performance Computing
925.422.3341
meier3 at llnl.gov
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0002-opensm-osm_opensm.c-changed-load_plugins-arg-to.patch
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080828/398816d3/attachment.ksh>


More information about the general mailing list