From 10f099228c96441e594d213ae4e797a9562d508b Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sat, 6 Jul 2024 20:35:25 +0900 Subject: [PATCH] nvme: use _cleanup_free_ type buffer for get-feature command Reduce the buffer free calls. Signed-off-by: Tokunori Ikegami --- nvme.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nvme.c b/nvme.c index 08553e5664..dd1f3b2ae9 100644 --- a/nvme.c +++ b/nvme.c @@ -4650,8 +4650,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; @@ -4670,9 +4670,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; }