Skip to content

Commit

Permalink
global: start relying on str_free(NULL) being a no-op
Browse files Browse the repository at this point in the history
Cleanup performed with the following semantic patch:

	@@
	expression E;
	@@

	- if (E != NULL) {
	- 	str_free(&E);
	- }
	+ str_free(&E);
  • Loading branch information
Josef 'Jeff' Sipek authored and sirainen committed Mar 12, 2018
1 parent a7e32ba commit e741abe
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/imap/imap-fetch.c
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/lib-fs/fs-metawrap.c
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/lib-fts/fts-filter.c
Expand Up @@ -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);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib-http/http-client-request.c
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/lib-storage/index/cydir/cydir-sync.c
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib-storage/index/index-search-mime.c
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib/istream.c
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/login-common/client-common.c
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/acl/acl-attributes.c
Expand Up @@ -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;
}
6 changes: 2 additions & 4 deletions src/plugins/fts-solr/fts-backend-solr.c
Expand Up @@ -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);
Expand Down

0 comments on commit e741abe

Please sign in to comment.