From: Stephan Bosch Date: Wed, 2 Oct 2019 10:58:01 +0000 (+0200) Subject: lib-smtp: smtp-address - Change return values of parse functions to be either 0 or -1. X-Git-Tag: 2.3.9~133 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ce96a2f86289b133c8ebec1b8d43f86ff7dea9b;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-address - Change return values of parse functions to be either 0 or -1. Before it used 1 and -1, which does not match other parts of Dovecot. --- diff --git a/src/lib-smtp/smtp-address.c b/src/lib-smtp/smtp-address.c index 95e4cd5dcb..637331cb76 100644 --- a/src/lib-smtp/smtp-address.c +++ b/src/lib-smtp/smtp-address.c @@ -318,7 +318,7 @@ int smtp_address_parse_mailbox(pool_t pool, const char *mailbox, if (address_r != NULL) *address_r = p_new(pool, struct smtp_address, 1); - return 1; + return 0; } i_zero(&aparser); @@ -340,7 +340,7 @@ int smtp_address_parse_mailbox(pool_t pool, const char *mailbox, if (address_r != NULL) *address_r = smtp_address_clone(pool, &aparser.address); - return 1; + return 0; } int smtp_address_parse_path_full(pool_t pool, const char *path, @@ -365,7 +365,7 @@ int smtp_address_parse_path_full(pool_t pool, const char *path, } if (address_r != NULL) *address_r = p_new(pool, struct smtp_address, 1); - return 1; + return 0; } i_zero(&aparser); @@ -389,7 +389,7 @@ int smtp_address_parse_path_full(pool_t pool, const char *path, if (address_r != NULL) *address_r = smtp_address_clone(pool, &aparser.address); - return 1; + return 0; } int smtp_address_parse_path(pool_t pool, const char *path, @@ -438,7 +438,7 @@ int smtp_address_parse_username(pool_t pool, const char *username, if (address_r != NULL) *address_r = smtp_address_clone(pool, &aparser.address); - return 1; + return 0; } void smtp_address_detail_parse(pool_t pool, const char *delimiters, diff --git a/src/lib-smtp/smtp-address.h b/src/lib-smtp/smtp-address.h index a7e7105598..f539fc4433 100644 --- a/src/lib-smtp/smtp-address.h +++ b/src/lib-smtp/smtp-address.h @@ -29,7 +29,7 @@ ARRAY_DEFINE_TYPE(smtp_address_const, const struct smtp_address *); */ -/* Parse the RFC 5321 address from the provided mailbox string. Returns 1 when +/* Parse the RFC 5321 address from the provided mailbox string. Returns 0 when the address was parsed successfully and -1 upon error. The address is returned in address_r. When address_r is NULL, the provided string will be verified for validity as a mailbox only. */ @@ -37,7 +37,7 @@ int smtp_address_parse_mailbox(pool_t pool, const char *mailbox, enum smtp_address_parse_flags flags, struct smtp_address **address_r, const char **error_r) ATTR_NULL(4, 5); -/* Parse the RFC 5321 address from the provided path string. Returns 1 when +/* Parse the RFC 5321 address from the provided path string. Returns 0 when the address was parsed successfully and -1 upon error. The address is returned in address_r. When address_r is NULL, the provided string will be verified for validity as a path only. The endp_r parameter is used to @@ -48,7 +48,7 @@ int smtp_address_parse_path_full(pool_t pool, const char *path, struct smtp_address **address_r, const char **error_r, const char **endp_r) ATTR_NULL(4, 5, 6); -/* Parse the RFC 5321 address from the provided path string. Returns 1 when +/* Parse the RFC 5321 address from the provided path string. Returns 0 when the address was parsed successfully and -1 upon error. The address is returned in address_r. When address_r is NULL, the provided string will be verified for validity as a path only. */ @@ -60,7 +60,7 @@ int smtp_address_parse_path(pool_t pool, const char *path, string is not strictly parsed as an RFC 5321 mailbox; it allows a more lenient syntax. If the address obtained from splitting the string at the last `@' can be encoded back into a valid RFC 5321 mailbox string, parsing the - username will succeeded. Returns 1 when the address was parsed successfully + username will succeeded. Returns 0 when the address was parsed successfully and -1 upon error. The address is returned in address_r. When address_r is NULL, the provided string will be verified for validity as a username only. */ diff --git a/src/lib-smtp/test-smtp-address.c b/src/lib-smtp/test-smtp-address.c index 3d1efa27bf..0623f5f77b 100644 --- a/src/lib-smtp/test-smtp-address.c +++ b/src/lib-smtp/test-smtp-address.c @@ -140,9 +140,9 @@ static void test_smtp_mailbox_parse_valid(void) test_begin(t_strdup_printf("smtp mailbox valid [%d]", i)); test_out_reason(t_strdup_printf("parse(\"%s\")", test->input), - ret > 0, error); + ret == 0, error); - if (ret > 0) { + if (!test_has_failed()) { if (address->localpart == NULL || test->address.localpart == NULL) { test_out(t_strdup_printf("address->localpart = %s", @@ -234,9 +234,9 @@ static void test_smtp_path_parse_valid(void) test_begin(t_strdup_printf("smtp path valid [%d]", i)); test_out_reason(t_strdup_printf("parse(\"%s\")", test->input), - ret > 0, error); + ret == 0, error); - if (ret > 0) { + if (!test_has_failed()) { if (smtp_address_isnull(address) || smtp_address_isnull(&test->address)) { test_out("address = <>", @@ -385,9 +385,9 @@ static void test_smtp_username_parse_valid(void) test_begin(t_strdup_printf("smtp username valid [%d]", i)); test_out_reason(t_strdup_printf("parse(\"%s\")", test->input), - ret > 0, error); + ret == 0, error); - if (ret > 0) { + if (!test_has_failed()) { if (smtp_address_isnull(address) || smtp_address_isnull(&test->address)) { test_out("address = <>", @@ -962,7 +962,7 @@ static void test_smtp_address_detail_parse(void) SMTP_ADDRESS_PARSE_FLAG_ALLOW_LOCALPART | SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL, &address, &error); - test_out_reason("address parse", ret > 0, error); + test_out_reason("address parse", ret == 0, error); if (!test_has_failed()) { smtp_address_detail_parse_temp(test->delimiters,