[ofa-general] [PATCH] parse_node_map: print parse errors

Bernd Schubert bs at q-leap.de
Fri Apr 4 02:23:59 PDT 2008


Hello,

could you please add the patch below, without it I probably never would have 
realized why my node name map was not accepted. 

Btw, I'm a bit surprised there don't seem to be any default wrappers, for 
fopen(), fclose(), malloc(), fprintf(), etc.

diff -rup opensm-3.2.1.old/complib/cl_nodenamemap.c 
opensm-3.2.1/complib/cl_nodenamemap.c
--- opensm-3.2.1.old/complib/cl_nodenamemap.c	2008-04-03 13:17:35.000000000 
+0200
+++ opensm-3.2.1/complib/cl_nodenamemap.c	2008-04-04 11:09:42.000000000 +0200
@@ -55,8 +55,11 @@ static int map_name(void *cxt, uint64_t 
 		return 0;
 
 	item = malloc(sizeof(*item));
-	if (!item)
+	if (!item) {
+		fprintf(stderr, "Malloc failed, sizeof(*item) = %d.\n", sizeof(*item));
 		return -1;
+	}
+	
 	item->guid = guid;
 	item->name = strdup(p);
 	cl_qmap_insert(map, item->guid, (cl_map_item_t *)item);
@@ -169,6 +172,8 @@ int parse_node_map(const char *file_name
 		guid = strtoull(p, &e, 0);
 		if (e == p || (!isspace(*e) && *e != '#' && *e != '\0')) {
 			fclose(f);
+			fprintf (stderr, "%s: Parse error in line: %s\n",
+			         __func__, line);
 			return -1;
 		}
 

Thanks,
Bernd

-- 
Bernd Schubert
Q-Leap Networks GmbH



More information about the general mailing list