]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-address - Change return values of parse functions to be either 0 or -1.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 2 Oct 2019 10:58:01 +0000 (12:58 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 2 Oct 2019 12:32:11 +0000 (14:32 +0200)
Before it used 1 and -1, which does not match other parts of Dovecot.

src/lib-smtp/smtp-address.c
src/lib-smtp/smtp-address.h
src/lib-smtp/test-smtp-address.c

index 95e4cd5dcb8f57b2461cc9aa9bcecbd9d00145f6..637331cb7618a98cb6c5c2620aef9b029ddfaab9 100644 (file)
@@ -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,
index a7e710559866c56b1163c6f4d9507ba0432b8709..f539fc443313e7e7671b7554d4f18592fe5f42db 100644 (file)
@@ -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.
  */
index 3d1efa27bf8a17ebabfb8c1a0559f291963e37c8..0623f5f77b8a8b8ea843015df38391827e5db562 100644 (file)
@@ -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,