]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: use _cleanup_free_ type buffer for get-feature command
authorTokunori Ikegami <ikegami.t@gmail.com>
Sat, 6 Jul 2024 11:35:25 +0000 (20:35 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 9 Jul 2024 10:12:27 +0000 (12:12 +0200)
Reduce the buffer free calls.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 0dbc20905681432f3865c43caef78b30b26b26be..49d11e5e466cfdbf39f585f626b58508f024cbc6 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -4642,8 +4642,8 @@ static int get_feature_id_changed(struct nvme_dev *dev, struct feat_cfg cfg,
        int err_def = 0;
        __u32 result;
        __u32 result_def;
-       void *buf = NULL;
-       void *buf_def = NULL;
+       _cleanup_free_ void *buf = NULL;
+       _cleanup_free_ void *buf_def = NULL;
 
        if (changed)
                cfg.sel = 0;
@@ -4662,9 +4662,6 @@ static int get_feature_id_changed(struct nvme_dev *dev, struct feat_cfg cfg,
            (buf && buf_def && !strcmp(buf, buf_def)))
                get_feature_id_print(cfg, err, result, buf);
 
-       free(buf);
-       free(buf_def);
-
        return err;
 }