osaf/tools/safntf/ntfread/ntfread.c           |   7 +++++++
 osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c |  13 ++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)


ntfread/ntfsubscribe do not check invalid options.

Add code to show invalid options to user.

diff --git a/osaf/tools/safntf/ntfread/ntfread.c 
b/osaf/tools/safntf/ntfread/ntfread.c
--- a/osaf/tools/safntf/ntfread/ntfread.c
+++ b/osaf/tools/safntf/ntfread/ntfread.c
@@ -357,6 +357,13 @@ int main(int argc, char *argv[]) {
                }
        }
 
+       if (optind < argc){
+               fprintf(stderr, "Invalid non-option: \n");
+               while (optind < argc)
+                       fprintf(stderr, "%s \n", argv[optind++]);
+               fprintf(stderr, "Try '%s -h' for more information. \n", 
argv[0]);
+               exit(EXIT_FAILURE);
+       }
        rc = saNtfInitialize(&ntfHandle, &ntfCallbacks, &version);
        if (SA_AIS_OK != rc) {
                fprintf(stderr, "saNtfInitialize failed - %s\n",
diff --git a/osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c 
b/osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c
--- a/osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c
+++ b/osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c
@@ -198,7 +198,6 @@ static void usage(void)
        printf("  -y or --securityAlarm                     subscribe for only 
securityAlarm notifications\n");
        printf("  -h or --help                              this help\n");
        printf("  -v or --verbose                           print even more\n");
-       exit((int)SA_AIS_ERR_INVALID_PARAM);
 }
 
 static void freeNtfFilter(SaNtfNotificationFilterHandleT *fh_ptr)
@@ -403,13 +402,25 @@ int main(int argc, char *argv[])
                        verbose = 1;
                        break;
                case 'h':
+                       usage();
+                       exit(EXIT_SUCCESS);
+                       break;
                case '?':
                default:
                        usage();
+                       exit(EXIT_FAILURE);
                        break;
                }
        }
 
+       if (optind < argc){
+               fprintf(stderr, "Invalid non-option: \n");
+               while (optind < argc)
+                       fprintf(stderr, "%s \n", argv[optind++]);
+               fprintf(stderr, "Try '%s -h' for more information. \n", 
argv[0]);
+               exit(EXIT_FAILURE);
+       }
+
        error = saNtfInitialize(&ntfHandle, &ntfCallbacks, &version);
        if (SA_AIS_OK != error) {
                fprintf(stderr, "saNtfInitialize failed - %s\n", 
error_output(error));

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to