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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user