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:
@@ -45,24 +45,21 @@ wf_path_create(
|
||||
char const * value)
|
||||
{
|
||||
struct wf_path * path = malloc(sizeof(struct wf_path));
|
||||
if (NULL != path)
|
||||
path->elements = malloc(sizeof(char*) * WF_PATH_DEFAULT_CAPACITY);
|
||||
path->capacity = WF_PATH_DEFAULT_CAPACITY;
|
||||
path->count = 0;
|
||||
|
||||
char const * remainder = value;
|
||||
char const * pos = strchr(remainder, '/');
|
||||
while (NULL != pos)
|
||||
{
|
||||
path->elements = malloc(sizeof(char*) * WF_PATH_DEFAULT_CAPACITY);
|
||||
path->capacity = WF_PATH_DEFAULT_CAPACITY;
|
||||
path->count = 0;
|
||||
|
||||
char const * remainder = value;
|
||||
char const * pos = strchr(remainder, '/');
|
||||
while (NULL != pos)
|
||||
{
|
||||
wf_path_add(path, remainder, (pos - remainder));
|
||||
remainder = pos + 1;
|
||||
pos = strchr(remainder, '/');
|
||||
}
|
||||
|
||||
wf_path_add(path, remainder, strlen(remainder));
|
||||
wf_path_add(path, remainder, (pos - remainder));
|
||||
remainder = pos + 1;
|
||||
pos = strchr(remainder, '/');
|
||||
}
|
||||
|
||||
wf_path_add(path, remainder, strlen(remainder));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@@ -332,21 +332,18 @@ wfp_static_filesystem_create(
|
||||
(void) config;
|
||||
|
||||
struct wfp_static_filesystem * filesystem = malloc(sizeof(struct wfp_static_filesystem));
|
||||
if (NULL != filesystem)
|
||||
{
|
||||
filesystem->entries = malloc(sizeof(struct wfp_static_filesystem_entry) * WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY);
|
||||
filesystem->size = 0;
|
||||
filesystem->capacity = WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY;
|
||||
filesystem->entries = malloc(sizeof(struct wfp_static_filesystem_entry) * WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY);
|
||||
filesystem->size = 0;
|
||||
filesystem->capacity = WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY;
|
||||
|
||||
wfp_static_filesystem_add_dir(filesystem, 0, "<root>");
|
||||
wfp_static_filesystem_add_dir(filesystem, 0, "<root>");
|
||||
|
||||
wfp_client_config_set_userdata(config, filesystem);
|
||||
wfp_client_config_set_onlookup(config, &wfp_static_filesystem_lookup);
|
||||
wfp_client_config_set_ongetattr(config, &wfp_static_filesystem_getattr);
|
||||
wfp_client_config_set_onreaddir(config, &wfp_static_filesystem_readdir);
|
||||
wfp_client_config_set_onopen(config, &wfp_static_filesystem_open);
|
||||
wfp_client_config_set_onread(config, &wfp_static_filesystem_read);
|
||||
}
|
||||
wfp_client_config_set_userdata(config, filesystem);
|
||||
wfp_client_config_set_onlookup(config, &wfp_static_filesystem_lookup);
|
||||
wfp_client_config_set_ongetattr(config, &wfp_static_filesystem_getattr);
|
||||
wfp_client_config_set_onreaddir(config, &wfp_static_filesystem_readdir);
|
||||
wfp_client_config_set_onopen(config, &wfp_static_filesystem_open);
|
||||
wfp_client_config_set_onread(config, &wfp_static_filesystem_read);
|
||||
|
||||
return filesystem;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user