]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on str_free(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Thu, 9 Nov 2017 15:30:51 +0000 (10:30 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 31 Jan 2018 11:58:34 +0000 (13:58 +0200)
Cleanup performed with the following semantic patch:

@@
expression E;
@@

- if (E != NULL) {
-  str_free(&E);
- }
+ str_free(&E);

src/imap-login/imap-login-cmd-id.c
src/imap/imap-fetch.c
src/lib-fs/fs-metawrap.c
src/lib-fts/fts-filter.c
src/lib-http/http-client-request.c
src/lib-storage/index/cydir/cydir-sync.c
src/lib-storage/index/index-search-mime.c
src/lib/istream.c
src/login-common/client-common.c
src/plugins/acl/acl-attributes.c
src/plugins/fts-solr/fts-backend-solr.c

index b361b2613933615152c6e24343319f69e47dc4e3..cde640efe6b1fc4321ad4a76c76ad46a0c672fee 100644 (file)
@@ -214,8 +214,7 @@ static void cmd_id_free(struct imap_client *client)
 {
        struct imap_client_cmd_id *id = client->cmd_id;
 
-       if (id->log_reply != NULL)
-               str_free(&id->log_reply);
+       str_free(&id->log_reply);
        if (id->log_keys != NULL)
                p_strsplit_free(default_pool, id->log_keys);
        imap_parser_unref(&id->parser);
index 4063bda20b79cf31398d260d02f76b408d649482..e21212258233fc0a0db8253c910a35e47722a356 100644 (file)
@@ -666,8 +666,7 @@ int imap_fetch_end(struct imap_fetch_context *ctx)
        }
        ctx->client->output_cmd_lock = NULL;
 
-       if (state->cur_str != NULL)
-               str_free(&state->cur_str);
+       str_free(&state->cur_str);
 
        i_stream_unref(&state->cur_input);
 
index dbd8355ffbf1c1aef8a4db1198be789ba18e8c58..1757e22eb89636c21e3f193c159766b87f08aade 100644 (file)
@@ -135,8 +135,7 @@ static void fs_metawrap_file_deinit(struct fs_file *_file)
 
        if (file->super_read != _file->parent && file->super_read != NULL)
                fs_file_deinit(&file->super_read);
-       if (file->metadata_header != NULL)
-               str_free(&file->metadata_header);
+       str_free(&file->metadata_header);
        fs_file_deinit(&_file->parent);
        i_free(file->file.path);
        i_free(file);
index d67d4729bdc6d3981b8ebe2b0727846ee8b7a61e..4c9b48962e36ba2f55b4efe7ff76d88b2e52a011 100644 (file)
@@ -110,8 +110,7 @@ void fts_filter_unref(struct fts_filter **_fpp)
                fp->v.destroy(fp);
        else {
                /* default destroy implementation */
-               if (fp->token != NULL)
-                       str_free(&fp->token);
+               str_free(&fp->token);
                i_free(fp);
        }
 }
index fe314594c6eee03d616d3639eccd8c79ce4025c2..d6dca2d89d0a66bb1846857a09030792b694ae3d 100644 (file)
@@ -280,8 +280,7 @@ bool http_client_request_unref(struct http_client_request **_req)
        }
        i_stream_unref(&req->payload_input);
        o_stream_unref(&req->payload_output);
-       if (req->headers != NULL)
-               str_free(&req->headers);
+       str_free(&req->headers);
        event_unref(&req->event);
        pool_unref(&req->pool);
        return FALSE;
index af52cf4b9bc0ded2473cf24a14411aa5829d0d34..b26ed3bc63372e8472f90e2989aefbdc52ce7436 100644 (file)
@@ -143,8 +143,7 @@ int cydir_sync_finish(struct cydir_sync_context **_ctx, bool success)
        } else {
                mail_index_sync_rollback(&ctx->index_sync_ctx);
        }
-       if (ctx->path != NULL)
-               str_free(&ctx->path);
+       str_free(&ctx->path);
        i_free(ctx);
        return ret;
 }
index d9a15d56c618ba2324e57d16b26fa6752918b40e..847a4ab7a787e9ad5f9920ad9555e9510ba9783d 100644 (file)
@@ -587,8 +587,7 @@ int index_search_mime_arg_match(struct mail_search_arg *args,
                                       search_mimepart_arg, &mpctx);
 
        pool_unref(&mpctx.pool);
-       if (mpctx.buf != NULL)
-               str_free(&mpctx.buf);
+       str_free(&mpctx.buf);
        return ret;
 }
 
index 57a295cd460f59bfc4d0c9b9d8e59d403012954a..5befd9ebdb52e9fcca8f1b9cf1c5427fb6dbf884 100644 (file)
@@ -58,8 +58,7 @@ void i_stream_unref(struct istream **stream)
        _stream = (*stream)->real_stream;
 
        if (!io_stream_unref(&_stream->iostream)) {
-               if (_stream->line_str != NULL)
-                       str_free(&_stream->line_str);
+               str_free(&_stream->line_str);
                i_stream_snapshot_free(&_stream->prev_snapshot);
                i_stream_unref(&_stream->parent);
                io_stream_free(&_stream->iostream);
index a60ab27ff62d3c2fe63da1a9c5aa49ba6597cef3..cac6c316ff69b6b28ba62a229b12a26df79ac6f1 100644 (file)
@@ -303,8 +303,7 @@ void client_destroy(struct client *client, const char *reason)
 
        timeout_remove(&client->to_disconnect);
        timeout_remove(&client->to_auth_waiting);
-       if (client->auth_response != NULL)
-               str_free(&client->auth_response);
+       str_free(&client->auth_response);
 
        if (client->proxy_password != NULL) {
                safe_memset(client->proxy_password, 0,
index 7b44451fce8144081118e37af82af2725831f69b..8d2458e72a0aa31184cdf9389d295c861731d1f7 100644 (file)
@@ -241,8 +241,7 @@ int acl_attribute_iter_deinit(struct mailbox_attribute_iter *iter)
                mail_storage_set_internal_error(aiter->iter.box->storage);
                ret = -1;
        }
-       if (aiter->acl_name != NULL)
-               str_free(&aiter->acl_name);
+       str_free(&aiter->acl_name);
        i_free(aiter);
        return ret;
 }
index c4b4b9a8c1a0f6cba38c0c07bb327e13bfe8d4a7..2db0bdde3092eeb1de9773aaa2acfe89772f05be 100644 (file)
@@ -410,10 +410,8 @@ fts_backend_solr_update_deinit(struct fts_backend_update_context *_ctx)
                        ret = -1;
        }
 
-       if (ctx->cmd != NULL)
-               str_free(&ctx->cmd);
-       if (ctx->cmd_expunge != NULL)
-               str_free(&ctx->cmd_expunge);
+       str_free(&ctx->cmd);
+       str_free(&ctx->cmd_expunge);
        array_foreach_modifiable(&ctx->fields, field) {
                str_free(&field->value);
                i_free(field->key);