From: Josef 'Jeff' Sipek Date: Thu, 9 Nov 2017 15:30:51 +0000 (-0500) Subject: global: start relying on str_free(NULL) being a no-op X-Git-Tag: 2.3.1~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e741abe858d91892415833da1ee9c64388097fdc;p=thirdparty%2Fdovecot%2Fcore.git global: start relying on str_free(NULL) being a no-op Cleanup performed with the following semantic patch: @@ expression E; @@ - if (E != NULL) { - str_free(&E); - } + str_free(&E); --- diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index 4063bda20b..e212122582 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -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); diff --git a/src/lib-fs/fs-metawrap.c b/src/lib-fs/fs-metawrap.c index dbd8355ffb..1757e22eb8 100644 --- a/src/lib-fs/fs-metawrap.c +++ b/src/lib-fs/fs-metawrap.c @@ -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); diff --git a/src/lib-fts/fts-filter.c b/src/lib-fts/fts-filter.c index d67d4729bd..4c9b48962e 100644 --- a/src/lib-fts/fts-filter.c +++ b/src/lib-fts/fts-filter.c @@ -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); } } diff --git a/src/lib-http/http-client-request.c b/src/lib-http/http-client-request.c index 1f271e1cde..e43bf116cd 100644 --- a/src/lib-http/http-client-request.c +++ b/src/lib-http/http-client-request.c @@ -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; diff --git a/src/lib-storage/index/cydir/cydir-sync.c b/src/lib-storage/index/cydir/cydir-sync.c index af52cf4b9b..b26ed3bc63 100644 --- a/src/lib-storage/index/cydir/cydir-sync.c +++ b/src/lib-storage/index/cydir/cydir-sync.c @@ -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; } diff --git a/src/lib-storage/index/index-search-mime.c b/src/lib-storage/index/index-search-mime.c index d9a15d56c6..847a4ab7a7 100644 --- a/src/lib-storage/index/index-search-mime.c +++ b/src/lib-storage/index/index-search-mime.c @@ -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; } diff --git a/src/lib/istream.c b/src/lib/istream.c index bb77280479..4310b15743 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -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); diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index a3c6d7a54c..ef917823cc 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -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, diff --git a/src/plugins/acl/acl-attributes.c b/src/plugins/acl/acl-attributes.c index 7b44451fce..8d2458e72a 100644 --- a/src/plugins/acl/acl-attributes.c +++ b/src/plugins/acl/acl-attributes.c @@ -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; } diff --git a/src/plugins/fts-solr/fts-backend-solr.c b/src/plugins/fts-solr/fts-backend-solr.c index c4b4b9a8c1..2db0bdde30 100644 --- a/src/plugins/fts-solr/fts-backend-solr.c +++ b/src/plugins/fts-solr/fts-backend-solr.c @@ -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);