Skip to content

Commit

Permalink
nvme: Add nvme_root_t cleanup helpers
Browse files Browse the repository at this point in the history
Note: It should be used by the existing codes using nvme_root_t also.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Jan 30, 2024
1 parent 9e92a28 commit 244b66b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5430,7 +5430,7 @@ static int set_register(int argc, char **argv, struct command *cmd, struct plugi

_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
int err;
nvme_root_t r;
_cleanup_nvme_root_ nvme_root_t r = NULL;
void *bar;

struct config {
Expand Down Expand Up @@ -5474,7 +5474,6 @@ static int set_register(int argc, char **argv, struct command *cmd, struct plugi
nvme_register_to_string(cfg.offset), cfg.value);

munmap(bar, getpagesize());
nvme_free_tree(r);

return err;
}
Expand Down
4 changes: 4 additions & 0 deletions nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ static inline DEFINE_CLEANUP_FUNC(
cleanup_nvme_dev, struct nvme_dev *, dev_close)
#define _cleanup_nvme_dev_ __cleanup__(cleanup_nvme_dev)

static inline DEFINE_CLEANUP_FUNC(
cleanup_nvme_root, nvme_root_t, nvme_free_tree)
#define _cleanup_nvme_root_ __cleanup__(cleanup_nvme_root)

extern const char *output_format;

int validate_output_format(const char *format, enum nvme_print_flags *flags);
Expand Down

0 comments on commit 244b66b

Please sign in to comment.