1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

removed NULL-checks after malloc: they are not necessary, they were not consequently used and objects constructed by 3rd party libs are also unchecked

This commit is contained in:
Falk Werner
2020-03-21 21:22:22 +01:00
parent 220df4ad50
commit 214d6b738d
22 changed files with 101 additions and 168 deletions

View File

@@ -30,27 +30,24 @@ struct wfp_client * wfp_impl_client_create(
wf_lwslog_disable();
struct wfp_client * client = malloc(sizeof(struct wfp_client));
if (NULL != client)
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);
memset(client->protocols, 0, sizeof(struct lws_protocols) * WFP_CLIENT_PROTOCOL_COUNT);
wfp_impl_client_protocol_init_lws(&client->protocol, &client->protocols[0]);
memset(&client->info, 0, sizeof(struct lws_context_creation_info));
client->info.port = CONTEXT_PORT_NO_LISTEN;
client->info.protocols = client->protocols;
client->info.uid = -1;
client->info.gid = -1;
if ((NULL != config->cert_path) && (NULL != config->key_path))
{
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);
memset(client->protocols, 0, sizeof(struct lws_protocols) * WFP_CLIENT_PROTOCOL_COUNT);
wfp_impl_client_protocol_init_lws(&client->protocol, &client->protocols[0]);
memset(&client->info, 0, sizeof(struct lws_context_creation_info));
client->info.port = CONTEXT_PORT_NO_LISTEN;
client->info.protocols = client->protocols;
client->info.uid = -1;
client->info.gid = -1;
if ((NULL != config->cert_path) && (NULL != config->key_path))
{
}
client->context = lws_create_context(&client->info);
}
client->context = lws_create_context(&client->info);
return client;
}

View File

@@ -6,13 +6,10 @@
struct wfp_client_config * wfp_impl_client_config_create(void)
{
struct wfp_client_config * config = malloc(sizeof(struct wfp_client_config));
if (NULL != config)
{
wfp_impl_provider_init(&config->provider);
config->user_data = NULL;
config->key_path = NULL;
config->cert_path = NULL;
}
wfp_impl_provider_init(&config->provider);
config->user_data = NULL;
config->key_path = NULL;
config->cert_path = NULL;
return config;
}

View File

@@ -270,10 +270,7 @@ struct wfp_client_protocol * wfp_impl_client_protocol_create(
struct wfp_client_config const * config)
{
struct wfp_client_protocol * protocol = malloc(sizeof(struct wfp_client_protocol));
if (NULL != protocol)
{
wfp_impl_client_protocol_init(protocol, &config->provider, config->user_data);
}
wfp_impl_client_protocol_init(protocol, &config->provider, config->user_data);
return protocol;
}

View File

@@ -4,10 +4,7 @@
struct wfp_dirbuffer * wfp_impl_dirbuffer_create(void)
{
struct wfp_dirbuffer * buffer = malloc(sizeof(struct wfp_dirbuffer));
if (NULL != buffer)
{
buffer->entries = json_array();
}
buffer->entries = json_array();
return buffer;
}

View File

@@ -56,22 +56,15 @@ void wfp_impl_respond_read(
{
size_t const size = wf_base64_encoded_size(length) + 1;
char * buffer = malloc(size);
if (NULL != buffer)
{
wf_base64_encode((uint8_t const *) data, length, buffer, size);
wf_base64_encode((uint8_t const *) data, length, buffer, size);
json_t * result = json_object();
json_object_set_new(result, "data", json_string(buffer));
json_object_set_new(result, "format", json_string("base64"));
json_object_set_new(result, "count", json_integer((int) length));
json_t * result = json_object();
json_object_set_new(result, "data", json_string(buffer));
json_object_set_new(result, "format", json_string("base64"));
json_object_set_new(result, "count", json_integer((int) length));
wfp_impl_respond(request, result);
free(buffer);
}
else
{
wfp_impl_respond_error(request, WF_BAD);
}
wfp_impl_respond(request, result);
free(buffer);
}
else
{

View File

@@ -8,12 +8,9 @@ struct wfp_request * wfp_impl_request_create(
int id)
{
struct wfp_request * request = malloc(sizeof(struct wfp_request));
if (NULL != request)
{
request->respond = prototype->respond;
request->user_data = prototype->user_data;
request->id = id;
}
request->respond = prototype->respond;
request->user_data = prototype->user_data;
request->id = id;
return request;
}