return 0;
}
+ assert(count > 0);
+ assert(data->num_calls == 0);
+
/* trying to read more than maximum server read size, we has to chop it up into smaller
* reads and collect into a reassembly buffer.
* we send all reads in parallel so that performance is still good.
mdata = malloc(sizeof(struct nfs_mcb_data));
if (mdata == NULL) {
rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_mcb_data structure");
+ if (data->num_calls == 0)
+ free_nfs_cb_data(data);
return -1;
}
memset(mdata, 0, sizeof(struct nfs_mcb_data));
rpc_set_error(nfs->rpc, "RPC error: Failed to send READ call for %s", data->path);
data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
free(mdata);
+ if (data->num_calls == 0)
+ free_nfs_cb_data(data);
return -1;
}
return 0;
}
+ /* hello, clang-analyzer */
+ assert(count > 0);
+ assert(data->num_calls == 0);
+
/* trying to write more than maximum server write size, we has to chop it up into smaller
* chunks.
* we send all writes in parallel so that performance is still good.
mdata = malloc(sizeof(struct nfs_mcb_data));
if (mdata == NULL) {
rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_mcb_data structure");
+ if (data->num_calls == 0)
+ free_nfs_cb_data(data);
return -1;
}
memset(mdata, 0, sizeof(struct nfs_mcb_data));
rpc_set_error(nfs->rpc, "RPC error: Failed to send WRITE call for %s", data->path);
data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
free(mdata);
+ if (data->num_calls == 0)
+ free_nfs_cb_data(data);
+
return -1;
}
ptr = strrchr(new_path, '/');
if (ptr == NULL) {
+ free(new_path);
rpc_set_error(nfs->rpc, "Invalid path %s", path);
return -1;
}
ptr = strrchr(new_path, '/');
if (ptr == NULL) {
+ free(new_path);
rpc_set_error(nfs->rpc, "Invalid path %s", path);
return -1;
}
ptr = strrchr(new_path, '/');
if (ptr == NULL) {
+ free(new_path);
rpc_set_error(nfs->rpc, "Invalid path %s", path);
return -1;
}
/* data->path now points to the parent directory, and beyond the nul terminateor is the new directory to create */
if (nfs_lookuppath_async(nfs, cb_data->path, cb, private_data, nfs_mknod_continue_internal, cb_data, free_mknod_cb_data, 0) != 0) {
rpc_set_error(nfs->rpc, "Out of memory: failed to start parsing the path components");
- free_mknod_cb_data(cb_data);
return -1;
}
static int nfs_rename_continue_1_internal(struct nfs_context *nfs, struct nfs_cb_data *data)
{
struct nfs_rename_data *rename_data = data->continue_data;
+ char* newpath = strdup(rename_data->newpath);
+ if (!newpath) {
+ rpc_set_error(nfs->rpc, "Out of memory. Could not allocate memory to store target path for rename");
+ data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
+ free_nfs_cb_data(data);
+ return -1;
+ }
/* steal the filehandle */
rename_data->olddir = data->fh;
data->fh.data.data_val = NULL;
if (nfs_lookuppath_async(nfs, rename_data->newpath, data->cb, data->private_data, nfs_rename_continue_2_internal, rename_data, free_nfs_rename_data, 0) != 0) {
- rpc_set_error(nfs->rpc, "RPC error: Failed to send LOOKUP call for %s", rename_data->newpath);
+ rpc_set_error(nfs->rpc, "RPC error: Failed to send LOOKUP call for %s", newpath);
data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
free_nfs_cb_data(data);
+ free(newpath);
return -1;
}
data->continue_data = NULL;
free_nfs_cb_data(data);
+ free(newpath);
return 0;
}