]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: imap_envelope_parse() - Refactor to avoid LTO warnings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 1 Apr 2021 09:33:33 +0000 (12:33 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 13 Apr 2021 11:52:27 +0000 (11:52 +0000)
The original code was correct, but gcc with LTO still gave warnings about
potentially uninitialized envlp_r and error_r.

src/lib-imap/imap-envelope.c

index d107d66665592df9e26da57645aea6a6a622bf84..87297f4f691a739a4b2ad2f5e2c25617987482bc 100644 (file)
@@ -223,6 +223,7 @@ bool imap_envelope_parse(const char *envelope,
        struct imap_parser *parser;
        const struct imap_arg *args;
        int ret;
+       bool success;
 
        input = i_stream_create_from_data(envelope, strlen(envelope));
        (void)i_stream_read(input);
@@ -233,15 +234,15 @@ bool imap_envelope_parse(const char *envelope,
        if (ret < 0) {
                *error_r = t_strdup_printf("IMAP parser failed: %s",
                                           imap_parser_get_error(parser, NULL));
+               success = FALSE;
        } else if (ret == 0) {
                *error_r = "Empty envelope";
-               ret = -1;
+               success = FALSE;
        } else {
-               if (!imap_envelope_parse_args(args, pool, envlp_r, error_r))
-                       ret = -1;
+               success = imap_envelope_parse_args(args, pool, envlp_r, error_r);
        }
 
        imap_parser_unref(&parser);
        i_stream_destroy(&input);
-       return (ret >= 0);
+       return success;
 }