Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libnvme/libnvme/nvme.i
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ PyObject *read_hostid();
};

%typemap(newfree) struct nvmf_discovery_log * {
if ($1) free($1);
free($1);
}

%typemap(out) struct nvmf_discovery_log * {
Expand Down
9 changes: 7 additions & 2 deletions libnvme/src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const char *nvmf_dev = "/dev/nvme-fabrics";

static inline void free_uri(struct libnvmf_uri **uri)
{
if (*uri)
libnvmf_uri_free(*uri);
libnvmf_uri_free(*uri);
}
#define __cleanup_uri __cleanup(free_uri)

Expand Down Expand Up @@ -1517,6 +1516,9 @@ __public int libnvmf_discovery_args_create(struct libnvmf_discovery_args **argsp

__public void libnvmf_discovery_args_free(struct libnvmf_discovery_args *args)
{
if (!args)
return;

free(args);
}

Expand Down Expand Up @@ -2642,6 +2644,9 @@ __public int libnvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path,

__public void libnvmf_nbft_free(struct libnvme_global_ctx *ctx, struct nbft_file_entry *head)
{
if (!head)
return;

while (head) {
struct nbft_file_entry *next = head->next;

Expand Down
16 changes: 16 additions & 0 deletions libnvme/src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ static void __nvme_free_ns(struct libnvme_ns *n)
/* Stub for SWIG */
__public void libnvme_free_ns(struct libnvme_ns *n)
{
if (!n)
return;

__nvme_free_ns(n);
}

Expand Down Expand Up @@ -552,6 +555,10 @@ __public void libnvme_subsystem_release_fds(struct libnvme_subsystem *s)
*/
__public void libnvme_free_subsystem(libnvme_subsystem_t s)
{
if (!s)
return;

__nvme_free_subsystem(s);
}

struct libnvme_subsystem *nvme_alloc_subsystem(struct libnvme_host *h,
Expand Down Expand Up @@ -637,6 +644,9 @@ __public void libnvme_host_release_fds(struct libnvme_host *h)
/* Stub for SWIG */
__public void libnvme_free_host(struct libnvme_host *h)
{
if (!h)
return;

__libnvme_free_host(h);
}

Expand Down Expand Up @@ -831,6 +841,9 @@ __public int libnvme_path_get_queue_depth(libnvme_path_t p)

void nvme_free_path(struct libnvme_path *p)
{
if (!p)
return;

list_del_init(&p->entry);
list_del_init(&p->nentry);
free(p->name);
Expand Down Expand Up @@ -1043,6 +1056,9 @@ static void __libnvme_free_ctrl(libnvme_ctrl_t c)

__public void libnvme_free_ctrl(libnvme_ctrl_t c)
{
if (!c)
return;

__libnvme_free_ctrl(c);
}

Expand Down
8 changes: 5 additions & 3 deletions util/cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ static inline void cleanup_nvme_global_ctx(struct libnvme_global_ctx **ctx)
}
#define __cleanup_nvme_global_ctx __cleanup(cleanup_nvme_global_ctx)

static inline DEFINE_CLEANUP_FUNC(cleanup_nvme_ctrl, libnvme_ctrl_t, libnvme_free_ctrl)
static inline void cleanup_nvme_ctrl(libnvme_ctrl_t *__p)
{
libnvme_free_ctrl(*__p);
}
#define __cleanup_nvme_ctrl __cleanup(cleanup_nvme_ctrl)

#ifdef CONFIG_FABRICS
static inline void free_uri(struct libnvmf_uri **uri)
{
if (*uri)
libnvmf_uri_free(*uri);
libnvmf_uri_free(*uri);
}
#define __cleanup_uri __cleanup(free_uri)

Expand Down
Loading