[ofw] patch: opensm - better handle bad command line parameters

Smith, Stan stan.smith at intel.com
Thu Aug 19 08:31:29 PDT 2010



________________________________
From: ofw-bounces at lists.openfabrics.org [mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Tzachi Dar
Sent: Thursday, August 19, 2010 8:08 AM
To: ofw at lists.openfabrics.org
Subject: [ofw] patch: opensm - better handle bad command line parameters

The following patch helps opensm handle bad parameters, such as:

"opensm -"

K:\Users\Administrator>opensm -/
-------------------------------------------------
OpenSM 3.3.3
^C
K:\Users\Administrator>opensm -/\\
-------------------------------------------------
OpenSM 3.3.3
^C
K:\Users\Administrator>opensm -/\\jjj -h

Thanks
Tzachi

You want to be using the latest getopt() version.

Index: main.c
===================================================================
--- main.c             (revision 6291)
+++ main.c          (revision 6292)
@@ -723,9 +723,9 @@
                                default:
                                                break;
                                }
-              } while (next_option != -1);
+             } while (next_option != -1 && next_option != '?');

Adding
    case '?':
to
  case 'h':
  case ':':
   show_usage();
   break;

Removes the need for "next_option != '?'" plus the standard windows help request '/?' is supported.

                if (config_file && osm_subn_parse_conf_file(config_file, &opt) < 0)
                                printf("\nFail to parse config file \'%s\'\n", config_file);
@@ -1077,7 +1077,8 @@
                                case -1:
                                                break;   /* done with option */
                                default:                /* something wrong */
-                                              abort();
+                                             show_usage();
+                                             exit(1);
                                }
                } while (next_option != -1);

Yes, this makes sense.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100819/8e024115/attachment.html>


More information about the ofw mailing list