]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: use unsigned char for hmac and identity
authorDaniel Wagner <dwagner@suse.de>
Thu, 10 Oct 2024 07:02:16 +0000 (09:02 +0200)
committerDaniel Wagner <wagi@monom.org>
Mon, 28 Oct 2024 18:38:51 +0000 (19:38 +0100)
The spec is limiting the size of both variables to one byte, thus there
is no need to use wider types.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index 0433c2cd157c7914f64baee3f725712254465768..5559a8b9dfbe9ec44202e0042c1670035a99e353 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -9201,8 +9201,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
                char            *hostnqn;
                char            *subsysnqn;
                char            *secret;
-               unsigned int    hmac;
-               unsigned int    identity;
+               unsigned char   hmac;
+               unsigned char   identity;
                bool            insert;
        };
 
@@ -9223,8 +9223,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
                  OPT_STR("hostnqn",    'n', &cfg.hostnqn,      hostnqn),
                  OPT_STR("subsysnqn",  'c', &cfg.subsysnqn,    subsysnqn),
                  OPT_STR("secret",     's', &cfg.secret,       secret),
-                 OPT_UINT("hmac",      'm', &cfg.hmac,         hmac),
-                 OPT_UINT("identity",  'I', &cfg.identity,     identity),
+                 OPT_BYTE("hmac",      'm', &cfg.hmac,         hmac),
+                 OPT_BYTE("identity",  'I', &cfg.identity,     identity),
                  OPT_FLAG("insert",    'i', &cfg.insert,       insert));
 
        err = parse_args(argc, argv, desc, opts);
@@ -9322,7 +9322,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
                char            *hostnqn;
                char            *subsysnqn;
                char            *keydata;
-               unsigned int    identity;
+               unsigned char   identity;
                bool            insert;
        };
 
@@ -9342,7 +9342,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
                  OPT_STR("hostnqn",    'n', &cfg.hostnqn,      hostnqn),
                  OPT_STR("subsysnqn",  'c', &cfg.subsysnqn,    subsysnqn),
                  OPT_STR("keydata",    'd', &cfg.keydata,      keydata),
-                 OPT_UINT("identity",  'I', &cfg.identity,     identity),
+                 OPT_BYTE("identity",  'I', &cfg.identity,     identity),
                  OPT_FLAG("insert",    'i', &cfg.insert,       insert));
 
        err = parse_args(argc, argv, desc, opts);