quic: clean setup_cipher function 75/30975/2
authorMathias Raoul <mathias.raoul@gmail.com>
Wed, 27 Jan 2021 15:35:54 +0000 (15:35 +0000)
committerDave Wallace <dwallacelf@gmail.com>
Mon, 1 Feb 2021 19:40:06 +0000 (19:40 +0000)
Type: fix

Change-Id: I02e473440a8732ddfb1a13ad6552779adaa67f60
Signed-off-by: Mathias Raoul <mathias.raoul@gmail.com>
src/plugins/quic/quic_crypto.c

index 5e90563..15e5f0d 100644 (file)
@@ -55,18 +55,18 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn,
   int ret;
 
   *packet_protect_ctx = NULL;
-
   /* generate new header protection key */
   if (header_protect_ctx != NULL)
     {
       *header_protect_ctx = NULL;
-      if ((ret = ptls_hkdf_expand_label (
-            hash, hpkey, aead->ctr_cipher->key_size,
-            ptls_iovec_init (secret, hash->digest_size), "quic hp",
-            ptls_iovec_init (NULL, 0), NULL)) != 0)
+      ret =
+       ptls_hkdf_expand_label (hash, hpkey, aead->ctr_cipher->key_size,
+                               ptls_iovec_init (secret, hash->digest_size),
+                               "quic hp", ptls_iovec_init (NULL, 0), NULL);
+      if (ret)
        goto Exit;
-      if ((*header_protect_ctx =
-            ptls_cipher_new (aead->ctr_cipher, is_enc, hpkey)) == NULL)
+      *header_protect_ctx = ptls_cipher_new (aead->ctr_cipher, is_enc, hpkey);
+      if (NULL == *header_protect_ctx)
        {
          ret = PTLS_ERROR_NO_MEMORY;
          goto Exit;
@@ -74,8 +74,9 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn,
     }
 
   /* generate new AEAD context */
-  if ((*packet_protect_ctx = ptls_aead_new (aead, hash, is_enc, secret,
-                                           QUICLY_AEAD_BASE_LABEL)) == NULL)
+  *packet_protect_ctx =
+    ptls_aead_new (aead, hash, is_enc, secret, QUICLY_AEAD_BASE_LABEL);
+  if (NULL == *packet_protect_ctx)
     {
       ret = PTLS_ERROR_NO_MEMORY;
       goto Exit;
@@ -97,7 +98,7 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn,
 Exit:
   if (ret)
     {
-      if (packet_protect_ctx && *packet_protect_ctx != NULL)
+      if (*packet_protect_ctx != NULL)
        {
          ptls_aead_free (*packet_protect_ctx);
          *packet_protect_ctx = NULL;