[ofa-general] [PATCH 6/6] Allow for a special value of "(null)" in the opts file.

Ira Weiny weiny2 at llnl.gov
Thu Oct 25 11:43:46 PDT 2007


>From 3df0056cce46e521dc9f0ab07c55a41cef6f340c Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 25 Oct 2007 10:09:54 -0700
Subject: [PATCH] Allow for a special value of "(null)" in the opts file.

   Some string values are valid if they are "(null)".  Special case this string
   so that it sets the pointer to NULL when read.

Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 opensm/opensm/osm_subnet.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index 9bc6940..32af508 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -630,12 +630,17 @@ opts_unpack_charp(IN char *p_req_key,
 			printf(buff);
 			cl_log_event("OpenSM", CL_LOG_INFO, buff, NULL, 0);
 
-			/*
-			   Ignore the possible memory leak here;
-			   the pointer may be to a static default.
-			 */
-			*p_val = (char *)malloc(strlen(p_val_str) + 1);
-			strcpy(*p_val, p_val_str);
+			/* special case the "(null)" string */
+			if (strcmp("(null)", p_val_str) == 0) {
+				*p_val = NULL;
+			} else {
+				/*
+				  Ignore the possible memory leak here;
+				  the pointer may be to a static default.
+				*/
+				*p_val = (char *)malloc(strlen(p_val_str) + 1);
+				strcpy(*p_val, p_val_str);
+			}
 		}
 	}
 }
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Allow-for-a-special-value-of-null-in-the-opts-fi.patch
Type: application/octet-stream
Size: 1339 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071025/8e6b4219/attachment.obj>


More information about the general mailing list