]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: use argconfig_parse_seen to check conditions
authorzhangxiaoyuan <zhangxiaoyuan@dapustor.com>
Fri, 19 Jul 2024 10:23:44 +0000 (18:23 +0800)
committerDaniel Wagner <wagi@monom.org>
Fri, 19 Jul 2024 15:08:45 +0000 (17:08 +0200)
The value of NVME_FEAT_FID_TIMESTAMP cannot be set
to 0 through 'set-feature /dev/nvmeX -f 0xe -v 0'.
using argconfig_parse_seen() can fix this issue.

Signed-off-by: Xiaoyuan Zhang <zhxiaoy@outlook.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index eddd617ea1971f1747427ad55c967a16ade60576..f866c58e574afa77e42e6592d369493fc4ae4297 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6415,7 +6415,8 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
                 * should use the buffer method if the value exceeds this
                 * length.
                 */
-               if (cfg.feature_id == NVME_FEAT_FID_TIMESTAMP && cfg.value) {
+               if (cfg.feature_id == NVME_FEAT_FID_TIMESTAMP &&
+                   argconfig_parse_seen(opts, "value")) {
                        memcpy(buf, &cfg.value, NVME_FEAT_TIMESTAMP_DATA_SIZE);
                } else {
                        if (strlen(cfg.file))