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

Tzachi Dar tzachid at mellanox.co.il
Thu Aug 19 08:37:37 PDT 2010


Please note that I have tried using the last opensm, and latest getopt and I still get this problem.

Please also note that while (next_option != -1 && next_option != '?');  was added to the first place where we call getopt_long_only. On this place there is only case 'F':

Thanks
Tzachi

From: Smith, Stan [mailto:stan.smith at intel.com]
Sent: Thursday, August 19, 2010 6:31 PM
To: Tzachi Dar; ofw at lists.openfabrics.org
Subject: RE: patch: opensm - better handle bad command line parameters



________________________________
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/aca49350/attachment.html>


More information about the ofw mailing list