Mailing List Archive

[PATCH 1/2] spfquery: Fail with an appropriate error message when checking arguments.
From: Florian Forster <ff@octo.it>

It's very annoying to be shown the "usage" output and not know *why*.

This patch prints an explanation to STDERR before the usage information,
so it's easier for users to recognize typos and misconceptions.
---
src/spfquery/spfquery.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/spfquery/spfquery.c b/src/spfquery/spfquery.c
index c4dc5bb..1904c8a 100644
--- a/src/spfquery/spfquery.c
+++ b/src/spfquery/spfquery.c
@@ -547,8 +547,13 @@ int main( int argc, char *argv[] )
else {
fin = NULL;

- if ((req->ip == NULL) ||
- (req->sender == NULL && req->helo == NULL) ) {
+ if (req->ip == NULL) {
+ fprintf( stderr, "The required \"-ip\" option is missing.\n" );
+ usage();
+ FAIL_ERROR;
+ }
+ else if (req->sender == NULL && req->helo == NULL) {
+ fprintf( stderr, "Either the \"-sender\" or \"-helo\" option is required.\n" );
usage();
FAIL_ERROR;
}
--
1.7.2.3



-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/1007/=now
RSS Feed: https://www.listbox.com/member/archive/rss/1007/1311533-9e42a648
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311533&id_secret=1311533-d322f1f1
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311533&id_secret=1311533-d59c80a0&post_id=20110123095118:5707DB8A-2700-11E0-8226-E72410376A25
Powered by Listbox: http://www.listbox.com