cert_create: merge successive i2d_ASN1_INTEGER() calls
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 6 Feb 2017 10:00:11 +0000 (19:00 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sat, 11 Feb 2017 03:59:25 +0000 (12:59 +0900)
The ext_new_nvcounter() function calls i2d_ASN1_INTEGER() twice;
the first call to get the return value "sz", and the second one
for writing data into the buffer.  This is actually redundant.
We can do both by one function call.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
tools/cert_create/src/ext.c

index 3f56edb756c25f910b19f9ed35b90e1003c93f9e..b261951e2c817fa3774a2225bbbdb742fb3321eb 100644 (file)
@@ -262,8 +262,7 @@ X509_EXTENSION *ext_new_nvcounter(int nid, int crit, int value)
        /* Encode counter */
        counter = ASN1_INTEGER_new();
        ASN1_INTEGER_set(counter, value);
-       sz = i2d_ASN1_INTEGER(counter, NULL);
-       i2d_ASN1_INTEGER(counter, &p);
+       sz = i2d_ASN1_INTEGER(counter, &p);
 
        /* Create the extension */
        ex = ext_new(nid, crit, p, sz);