]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: simplify cleanup_nvme_dev()
authorCaleb Sander <csander@purestorage.com>
Wed, 29 Nov 2023 03:59:09 +0000 (20:59 -0700)
committerDaniel Wagner <wagi@monom.org>
Fri, 1 Dec 2023 13:53:34 +0000 (14:53 +0100)
Use DEFINE_CLEANUP_FUNC() to simplify cleanup_nvme_dev().

Signed-off-by: Caleb Sander <csander@purestorage.com>
nvme.h

diff --git a/nvme.h b/nvme.h
index a634664e5163927ff02a0c5d65839d661a3778b1..9c2a406930168b8f4917f718c866a8ed23d01aff 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -102,11 +102,8 @@ int parse_and_open(struct nvme_dev **dev, int argc, char **argv, const char *des
 
 void dev_close(struct nvme_dev *dev);
 
-static inline void cleanup_nvme_dev(struct nvme_dev **dev)
-{
-       if (*dev)
-               dev_close(*dev);
-}
+static inline DEFINE_CLEANUP_FUNC(
+       cleanup_nvme_dev, struct nvme_dev *, dev_close)
 #define _cleanup_nvme_dev_ __cleanup__(cleanup_nvme_dev)
 
 extern const char *output_format;