On 21-May-15 8:48 AM, Vu Minh Nguyen wrote: > Hi Praveen, > > Thanks for your comments. > >> But `ntfread -g` prints whole usage also. > I will update the code to make it show following format for invalid options. > > E.g: > # ntfread -g > ntfread: invalid option -- 'g' > Try 'ntfread -h' for more information. > > Please let me know your opinions. This change will make it consistent for both the cases. After making this small change, please push the patch. Push #1352 also.
Thanks, Praveen > > Regards, > Vu > > >> -----Original Message----- >> From: praveen malviya [mailto:praveen.malv...@oracle.com] >> Sent: Wednesday, May 20, 2015 7:26 PM >> To: Vu Minh Nguyen; minh.c...@dektech.com.au; lennart.l...@ericsson.com >> Cc: opensaf-devel@lists.sourceforge.net >> Subject: Re: [PATCH 1 of 1] ntftool: ntfread and ntfsubscribe do not check >> invalid options [#1355] >> >> I think one minor change is still required as: >> >> `ntfread g` gives: >> >> Invalid non-option: >> g >> Try 'ntfread -h' for more information. >> >> But `ntfread -g` prints whole usage also. >> >> Please confirm. >> >> Thanks >> Praveen >> >> On 05-May-15 11:38 AM, Vu Minh Nguyen wrote: >>> 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