[ofa-general] [PATCH 4/5] infiniband-diags/saquery: allow empty src and/or dst with --src-to-dst option

Sasha Khapyorsky sashak at voltaire.com
Mon Dec 3 14:59:40 PST 2007


Allow to use empty source and/or destination fields with --src-to-dst
option, in this case empty field will not be marked in comp_mask.
Examples: '--src-to-dst :48', '--src-to-dst 4:', '--src-to-dst :'.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 infiniband-diags/src/saquery.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/infiniband-diags/src/saquery.c b/infiniband-diags/src/saquery.c
index db6ba11..1442902 100644
--- a/infiniband-diags/src/saquery.c
+++ b/infiniband-diags/src/saquery.c
@@ -1239,17 +1239,17 @@ main(int argc, char **argv)
 		case 1:
 		{
 			char *opt  = strdup(optarg);
-			char *tok1 = strtok(opt, ":");
-			char *tok2 = strtok(NULL, "\0");
-
-			if (tok1 && tok2) {
-				src = strdup(tok1);
-				dst = strdup(tok2);
-			} else {
+			char *ch = strchr(opt, ':');
+			if (!ch) {
 				fprintf(stderr,
 					"ERROR: --src-to-dst <node>:<node>\n");
 				usage();
 			}
+			*ch++ = '\0';
+			if (*opt)
+				src = strdup(opt);
+			if (*ch)
+				dst = strdup(ch);
 			free(opt);
 			query_type = IB_MAD_ATTR_PATH_RECORD;
 			break;
-- 
1.5.3.4.206.g58ba4




More information about the general mailing list