]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Mar 2018 09:58:53 +0000 (11:58 +0200)
Cleanup performed with the following semantic patch:

@@
expression E;
@@

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

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 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 1f271e1cde80601a3ed2aae2e36380c77ec62e9c..e43bf116cdbed2eb7bd878dffcb65a04f54eec08 100644 (file)
@@ -316,8 +316,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 bb772804799829fbeb02de3f9e2baa672bbc29f6..4310b15743feb0c8f60c4bec9ecb42b69b01f2a7 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 a3c6d7a54cc11ac32d359e3abec138cd6ab9b804..ef917823ccdc9d5d0859faecd48d64d1ed83eb62 100644 (file)
@@ -302,8 +302,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);