[openib-general] [PATCH] OpenSM: Support configurable SL per partition

Sasha Khapyorsky sashak at voltaire.com
Wed Jul 12 17:45:37 PDT 2006


Hi Pat,

On 15:14 Tue 11 Jul     , Patrick Mullaney wrote:
> This will avoid an invalid warning about service level value if sl=0 is
> used in the partition config file.

Yes, this is wrong warning, but original goal of this check was to catch
non-numeric string. Think something like this may be better:


diff --git a/osm/opensm/osm_prtn_config.c b/osm/opensm/osm_prtn_config.c
index bd15513..5647ca8 100644
--- a/osm/opensm/osm_prtn_config.c
+++ b/osm/opensm/osm_prtn_config.c
@@ -150,7 +150,9 @@ static int partition_add_flag(unsigned l
 				" - skipped.\n");
 	} else if (!strncmp(flag, "sl", len)) {
 		unsigned sl;
-		if (!val || (sl = strtoul(val, NULL, 0)) == 0 || sl > 15)
+		char *end;
+		if (!val || !*val || (sl = strtoul(val, &end, 0)) > 15 ||
+		    (*end && !isspace(*end)))
 			PARSEWARN(conf->p_log, lineno,
 				"flag \'sl\' requires valid value"
 				" - skipped.\n");


The overflow case should be filtered by sl > 15 check.

Sasha

> Can you include something like it in
> your original patch?
> 
> Thanks.
> Pat
> 
> --------------------------------------------------------------------------------------------------
> 
> --- opensm.old/osm_prtn_config.c	2006-07-11 16:06:33.000000000
> -0400
> +++ opensm/osm_prtn_config.c	2006-07-11 16:08:00.000000000 -0400
> @@ -52,6 +52,7 @@
>  #include <string.h>
>  #include <errno.h>
>  #include <ctype.h>
> +#include <limits.h>
>  
>  #include <iba/ib_types.h>
>  #include <opensm/osm_base.h>
> @@ -159,7 +160,7 @@ static int partition_add_flag(unsigned l
>  	} else if (!strncmp(flag, "sl", len)) {
>  		unsigned sl;
>  
> -		if (!val || (sl = strtoul(val, NULL, 0)) == 0 || sl >
> 15)
> +		if (!val || (sl = strtoul(val, NULL, 0)) == UINT_MAX ||
> sl > 15)
>  			PARSEWARN(conf->p_log, lineno,
>  				"flag \'sl\' requires valid value"
>  				" - skipped.\n");
> 
> 
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
> 




More information about the general mailing list