Skip to content

Commit 4cc727d

Browse files
dwsuseigaw
authored andcommitted
linux: reorder variable declarations
Use the inverse x-mas tree pattern for variable declarations. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 5f0eb7f commit 4cc727d

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/nvme/linux.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,9 @@ static int derive_retained_key(int hmac, const char *hostnqn,
600600
unsigned char *retained,
601601
size_t key_len)
602602
{
603-
const EVP_MD *md;
604603
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ctx = NULL;
605604
uint16_t length = key_len & 0xFFFF;
605+
const EVP_MD *md;
606606
size_t hmac_len;
607607

608608
md = select_hmac(hmac, &hmac_len);
@@ -662,10 +662,10 @@ static int derive_tls_key(int version, int hmac, const char *context,
662662
unsigned char *retained,
663663
unsigned char *psk, size_t key_len)
664664
{
665-
const EVP_MD *md;
666665
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ctx = NULL;
667-
size_t hmac_len;
668666
uint16_t length = key_len & 0xFFFF;
667+
const EVP_MD *md;
668+
size_t hmac_len;
669669

670670
md = select_hmac(hmac, &hmac_len);
671671
if (!md || hmac_len > key_len) {
@@ -805,10 +805,10 @@ static int derive_psk_digest(const char *hostnqn, const char *subsysnqn,
805805
char *digest, size_t digest_len)
806806
{
807807
static const char hmac_seed[] = "NVMe-over-Fabrics";
808-
size_t hmac_len;
809808
const EVP_MD *md = select_hmac(hmac, &hmac_len);
810809
_cleanup_hmac_ctx_ HMAC_CTX *hmac_ctx = NULL;
811810
_cleanup_free_ unsigned char *psk_ctx = NULL;
811+
size_t hmac_len;
812812
size_t len;
813813

814814
hmac_ctx = HMAC_CTX_new();
@@ -886,10 +886,10 @@ int nvme_gen_dhchap_key(char *hostnqn, enum nvme_hmac_alg hmac,
886886
unsigned char *key)
887887
{
888888
const char hmac_seed[] = "NVMe-over-Fabrics";
889-
OSSL_PARAM params[2], *p = params;
890889
_cleanup_ossl_lib_ctx_ OSSL_LIB_CTX *lib_ctx = NULL;
891890
_cleanup_evp_mac_ctx_ EVP_MAC_CTX *mac_ctx = NULL;
892891
_cleanup_evp_mac_ EVP_MAC *mac = NULL;
892+
OSSL_PARAM params[2], *p = params;
893893
char *progq = NULL;
894894
char *digest;
895895
size_t len;
@@ -970,14 +970,14 @@ static int derive_psk_digest(const char *hostnqn, const char *subsysnqn,
970970
char *digest, size_t digest_len)
971971
{
972972
static const char hmac_seed[] = "NVMe-over-Fabrics";
973-
size_t hmac_len;
974-
OSSL_PARAM params[2], *p = params;
975973
_cleanup_ossl_lib_ctx_ OSSL_LIB_CTX *lib_ctx = NULL;
976974
_cleanup_evp_mac_ctx_ EVP_MAC_CTX *mac_ctx = NULL;
975+
_cleanup_free_ unsigned char *psk_ctx = NULL;
977976
_cleanup_evp_mac_ EVP_MAC *mac = NULL;
977+
OSSL_PARAM params[2], *p = params;
978+
size_t hmac_len;
978979
char *progq = NULL;
979980
char *dig = NULL;
980-
_cleanup_free_ unsigned char *psk_ctx = NULL;
981981
size_t len;
982982

983983
lib_ctx = OSSL_LIB_CTX_new();
@@ -1160,9 +1160,9 @@ char *nvme_generate_tls_key_identity(const char *hostnqn, const char *subsysnqn,
11601160
int version, int hmac,
11611161
unsigned char *configured_key, int key_len)
11621162
{
1163+
_cleanup_free_ unsigned char *psk = NULL;
11631164
char *identity;
11641165
size_t identity_len;
1165-
_cleanup_free_ unsigned char *psk = NULL;
11661166
int ret = -1;
11671167

11681168
identity_len = nvme_identity_len(hmac, version, hostnqn, subsysnqn);
@@ -1342,10 +1342,10 @@ long nvme_insert_tls_key_versioned(const char *keyring, const char *key_type,
13421342
int version, int hmac,
13431343
unsigned char *configured_key, int key_len)
13441344
{
1345-
key_serial_t keyring_id, key;
1345+
_cleanup_free_ unsigned char *psk = NULL;
13461346
_cleanup_free_ char *identity = NULL;
1347+
key_serial_t keyring_id, key;
13471348
size_t identity_len;
1348-
_cleanup_free_ unsigned char *psk = NULL;
13491349
int ret;
13501350

13511351
keyring_id = nvme_lookup_keyring(keyring);
@@ -1491,10 +1491,10 @@ long nvme_insert_tls_key(const char *keyring, const char *key_type,
14911491

14921492
char *nvme_export_tls_key(const unsigned char *key_data, int key_len)
14931493
{
1494-
unsigned char raw_secret[52];
1495-
char *encoded_key;
14961494
unsigned int raw_len, encoded_len, len;
14971495
unsigned long crc = crc32(0L, NULL, 0);
1496+
unsigned char raw_secret[52];
1497+
char *encoded_key;
14981498

14991499
if (key_len == 32) {
15001500
raw_len = 32;

0 commit comments

Comments
 (0)