From e4c605d4c575d9f56f44970fdf3bee567b8fac18 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Mon, 19 Mar 2012 10:14:19 +0100 Subject: [PATCH] Indent code. --- examples/CertificateExample.c | 8 ++-- lib/coding.c | 4 +- lib/decoding.c | 92 +++++++++++++++++++++---------------------- lib/errors.c | 2 +- lib/int.h | 4 +- lib/parser_aux.c | 3 +- lib/version.c | 2 +- src/asn1Coding.c | 7 ++-- src/asn1Decoding.c | 4 +- src/asn1Parser.c | 4 +- tests/Test_overflow.c | 6 ++- tests/Test_simple.c | 83 +++++++++++++++++++------------------- 12 files changed, 111 insertions(+), 108 deletions(-) diff --git a/examples/CertificateExample.c b/examples/CertificateExample.c index 9972467..cd45f97 100644 --- a/examples/CertificateExample.c +++ b/examples/CertificateExample.c @@ -447,11 +447,11 @@ create_certificate (ASN1_TYPE cert_def, unsigned char *der, int *der_len) str, 1); result = asn1_create_element (cert_def, "PKIX1Implicit88.Dss-Parms", ¶m); - str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ + str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ result = asn1_write_value (param, "p", str2, 128); - str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ + str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ result = asn1_write_value (param, "q", str2, 20); - str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ + str2 = (const unsigned char *) "\xd4\x38"; /* only an example */ result = asn1_write_value (param, "g", str2, 128); *der_len = max_len; result = asn1_der_coding (param, "", der, der_len, errorDescription); @@ -463,7 +463,7 @@ create_certificate (ASN1_TYPE cert_def, unsigned char *der, int *der_len) /* subjectPublicKey */ - str2 = (const unsigned char *) "\x02\x81"; /* only an example */ + str2 = (const unsigned char *) "\x02\x81"; /* only an example */ result = asn1_write_value (cert1, "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey", diff --git a/lib/coding.c b/lib/coding.c index 8b72eba..307dd40 100644 --- a/lib/coding.c +++ b/lib/coding.c @@ -256,7 +256,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) char *temp, *n_end, *n_start; unsigned char bit7; unsigned long val, val1 = 0; - int str_len = _asn1_strlen(str); + int str_len = _asn1_strlen (str); max_len = *der_len; @@ -266,7 +266,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) memcpy (temp, str, str_len); temp[str_len] = '.'; - temp[str_len+1] = 0; + temp[str_len + 1] = 0; counter = 0; n_start = temp; diff --git a/lib/decoding.c b/lib/decoding.c index 968fa96..eaca0d2 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -1031,10 +1031,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); counter += len3 + len2; @@ -1045,7 +1045,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, _asn1_get_objectid_der (der + counter, len - counter, &len2, temp, sizeof (temp)); if (result != ASN1_SUCCESS) - goto cleanup; + goto cleanup; tlen = strlen (temp); if (tlen > 0) @@ -1070,7 +1070,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, len3 = len - counter; result = _asn1_get_octet_string (der + counter, p, &len3); if (result != ASN1_SUCCESS) - goto cleanup; + goto cleanup; counter += len3; move = RIGHT; @@ -1079,10 +1079,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); counter += len3 + len2; @@ -1092,10 +1092,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); counter += len3 + len2; @@ -1118,10 +1118,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, } } else - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += 2; } else @@ -1142,7 +1142,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2; if (len3 > 0) { @@ -1183,10 +1183,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if (len2 == -1) { /* indefinite length method */ if ((counter + 2) > len) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if ((der[counter]) || der[counter + 1]) { @@ -1227,7 +1227,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2; if (len3) { @@ -1258,24 +1258,24 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if (asn1_get_tag_der (der + counter, len - counter, &class, &len2, &tag) != ASN1_SUCCESS) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (counter + len2 > len) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } len4 = asn1_get_length_der (der + counter + len2, len - counter - len2, &len3); if (len4 < -1) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (len4 != -1) { len2 += len4; @@ -1311,7 +1311,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { result = ASN1_DER_ERROR; goto cleanup; - } + } } } move = RIGHT; @@ -1657,10 +1657,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (state == FOUND) { @@ -1668,7 +1668,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); if (p == nodeFound) @@ -1702,7 +1702,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, { result = ASN1_DER_ERROR; goto cleanup; - } + } len2 += len3; } @@ -1733,7 +1733,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, { result = ASN1_DER_ERROR; goto cleanup; - } + } len2 += len3; } @@ -1761,10 +1761,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (state == FOUND) { @@ -1772,7 +1772,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); if (p == nodeFound) @@ -1785,17 +1785,17 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, len2 = asn1_get_length_der (der + counter, len - counter, &len3); if (len2 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (state == FOUND) { if (len3 + len2 > len - counter) { result = ASN1_DER_ERROR; goto cleanup; - } + } _asn1_set_value (p, der + counter, len3 + len2); if (p == nodeFound) @@ -1839,10 +1839,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_get_length_der (der + counter, len - counter, &len2); if (len3 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2 + len3; move = RIGHT; } @@ -1852,10 +1852,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_get_length_der (der + counter, len - counter, &len2); if (len3 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2; if (len3 > 0) { @@ -1922,10 +1922,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_get_length_der (der + counter, len - counter, &len2); if (len3 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2 + len3; move = RIGHT; } @@ -1935,10 +1935,10 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_get_length_der (der + counter, len - counter, &len2); if (len3 < 0) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } counter += len2; if (len3) { @@ -1964,25 +1964,25 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, if (asn1_get_tag_der (der + counter, len - counter, &class, &len2, &tag) != ASN1_SUCCESS) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (counter + len2 > len) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } len4 = asn1_get_length_der (der + counter + len2, len - counter - len2, &len3); if (len4 < -1) - { + { result = ASN1_DER_ERROR; goto cleanup; - } + } if (len4 != -1) { diff --git a/lib/errors.c b/lib/errors.c index 7878c50..76611d8 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -21,7 +21,7 @@ #include #ifdef STDC_HEADERS -# include +#include #endif #define LIBTASN1_ERROR_ENTRY(name) { #name, name } diff --git a/lib/int.h b/lib/int.h index fcaf0d8..82de579 100644 --- a/lib/int.h +++ b/lib/int.h @@ -23,7 +23,7 @@ #define INT_H #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -33,7 +33,7 @@ #include #ifdef HAVE_SYS_TYPES_H -# include +#include #endif #include diff --git a/lib/parser_aux.c b/lib/parser_aux.c index ce55253..2e1f7ee 100644 --- a/lib/parser_aux.c +++ b/lib/parser_aux.c @@ -718,7 +718,8 @@ _asn1_expand_object_id (ASN1_TYPE node) { _asn1_str_cpy (name2, sizeof (name2), name_root); _asn1_str_cat (name2, sizeof (name2), "."); - _asn1_str_cat (name2, sizeof (name2), (char *) p2->value); + _asn1_str_cat (name2, sizeof (name2), + (char *) p2->value); p3 = asn1_find_node (node, name2); if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || !(p3->type & CONST_ASSIGN)) diff --git a/lib/version.c b/lib/version.c index fb17223..83d70c9 100644 --- a/lib/version.c +++ b/lib/version.c @@ -20,7 +20,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include /* for strverscmp */ diff --git a/src/asn1Coding.c b/src/asn1Coding.c index 131db7b..9ddb0a4 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -33,9 +33,9 @@ /* This feature is available in gcc versions 2.5 and later. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define ATTR_NO_RETRUN +#define ATTR_NO_RETRUN #else -# define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) +#define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) #endif ATTR_NO_RETRUN static void @@ -319,7 +319,8 @@ main (int argc, char *argv[]) if (outputFile == NULL) { - printf ("asn1Coding: output file '%s' not available\n", outputFileName); + printf ("asn1Coding: output file '%s' not available\n", + outputFileName); free (der); free (inputFileAsnName); free (inputFileAssignmentName); diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index c1f0876..2fa97a9 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -34,9 +34,9 @@ /* This feature is available in gcc versions 2.5 and later. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define ATTR_NO_RETRUN +#define ATTR_NO_RETRUN #else -# define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) +#define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) #endif ATTR_NO_RETRUN static void diff --git a/src/asn1Parser.c b/src/asn1Parser.c index 37c9960..e14da83 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -33,9 +33,9 @@ /* This feature is available in gcc versions 2.5 and later. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define ATTR_NO_RETRUN +#define ATTR_NO_RETRUN #else -# define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) +#define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) #endif ATTR_NO_RETRUN static void diff --git a/tests/Test_overflow.c b/tests/Test_overflow.c index 2136899..747507f 100644 --- a/tests/Test_overflow.c +++ b/tests/Test_overflow.c @@ -66,7 +66,8 @@ main (void) puts ("OK: asn1_get_length_der intnum"); else { - printf ("ERROR: asn1_get_length_der intnum (l %ld len %d)\n", l, len); + printf ("ERROR: asn1_get_length_der intnum (l %ld len %d)\n", l, + len); return 1; } } @@ -84,7 +85,8 @@ main (void) puts ("OK: asn1_get_length_der overflow"); else { - printf ("ERROR: asn1_get_length_der overflow (l %ld len %d)\n", l, len); + printf ("ERROR: asn1_get_length_der overflow (l %ld len %d)\n", l, + len); return 1; } } diff --git a/tests/Test_simple.c b/tests/Test_simple.c index 73d5178..9224036 100644 --- a/tests/Test_simple.c +++ b/tests/Test_simple.c @@ -35,45 +35,45 @@ struct tv }; static const struct tv tv[] = { - { 0, "", 2, "\x01\x00" }, - { 1, "\x00", 3, "\x02\x07\x00" }, - { 2, "\x00", 3, "\x02\x06\x00" }, - { 3, "\x00", 3, "\x02\x05\x00" }, - { 4, "\x00", 3, "\x02\x04\x00" }, - { 5, "\x00", 3, "\x02\x03\x00" }, - { 6, "\x00", 3, "\x02\x02\x00" }, - { 7, "\x00", 3, "\x02\x01\x00" }, - { 8, "\x00\x00", 3, "\x02\x00\x00" }, - { 9, "\x00\x00", 4, "\x03\x07\x00\x00" }, - { 10, "\x00\x00", 4, "\x03\x06\x00\x00" }, - { 11, "\x00\x00", 4, "\x03\x05\x00\x00" }, - { 12, "\x00\x00", 4, "\x03\x04\x00\x00" }, - { 13, "\x00\x00", 4, "\x03\x03\x00\x00" }, - { 14, "\x00\x00", 4, "\x03\x02\x00\x00" }, - { 15, "\x00\x00", 4, "\x03\x01\x00\x00" }, - { 16, "\x00\x00", 4, "\x03\x00\x00\x00" }, - { 17, "\x00\x00\x00", 5, "\x04\x07\x00\x00\x00" }, - { 18, "\x00\x00\x00", 5, "\x04\x06\x00\x00\x00" }, - { 19, "\x00\x00\x00", 5, "\x04\x05\x00\x00\x00" }, - { 1, "\xFF", 3, "\x02\x07\x80" }, - { 2, "\xFF", 3, "\x02\x06\xc0" }, - { 3, "\xFF", 3, "\x02\x05\xe0" }, - { 4, "\xFF", 3, "\x02\x04\xf0" }, - { 5, "\xFF", 3, "\x02\x03\xf8" }, - { 6, "\xFF", 3, "\x02\x02\xfc" }, - { 7, "\xFF", 3, "\x02\x01\xfe" }, - { 8, "\xFF\xFF", 3, "\x02\x00\xff" }, - { 9, "\xFF\xFF", 4, "\x03\x07\xff\x80" }, - { 10, "\xFF\xFF", 4, "\x03\x06\xff\xc0" }, - { 11, "\xFF\xFF", 4, "\x03\x05\xff\xe0" }, - { 12, "\xFF\xFF", 4, "\x03\x04\xff\xf0" }, - { 13, "\xFF\xFF", 4, "\x03\x03\xff\xf8" }, - { 14, "\xFF\xFF", 4, "\x03\x02\xff\xfc" }, - { 15, "\xFF\xFF", 4, "\x03\x01\xff\xfe" }, - { 16, "\xFF\xFF", 4, "\x03\x00\xff\xff" }, - { 17, "\xFF\xFF\xFF", 5, "\x04\x07\xff\xff\x80" }, - { 18, "\xFF\xFF\xFF", 5, "\x04\x06\xff\xff\xc0" }, - { 19, "\xFF\xFF\xFF", 5, "\x04\x05\xff\xff\xe0" }, + {0, "", 2, "\x01\x00"}, + {1, "\x00", 3, "\x02\x07\x00"}, + {2, "\x00", 3, "\x02\x06\x00"}, + {3, "\x00", 3, "\x02\x05\x00"}, + {4, "\x00", 3, "\x02\x04\x00"}, + {5, "\x00", 3, "\x02\x03\x00"}, + {6, "\x00", 3, "\x02\x02\x00"}, + {7, "\x00", 3, "\x02\x01\x00"}, + {8, "\x00\x00", 3, "\x02\x00\x00"}, + {9, "\x00\x00", 4, "\x03\x07\x00\x00"}, + {10, "\x00\x00", 4, "\x03\x06\x00\x00"}, + {11, "\x00\x00", 4, "\x03\x05\x00\x00"}, + {12, "\x00\x00", 4, "\x03\x04\x00\x00"}, + {13, "\x00\x00", 4, "\x03\x03\x00\x00"}, + {14, "\x00\x00", 4, "\x03\x02\x00\x00"}, + {15, "\x00\x00", 4, "\x03\x01\x00\x00"}, + {16, "\x00\x00", 4, "\x03\x00\x00\x00"}, + {17, "\x00\x00\x00", 5, "\x04\x07\x00\x00\x00"}, + {18, "\x00\x00\x00", 5, "\x04\x06\x00\x00\x00"}, + {19, "\x00\x00\x00", 5, "\x04\x05\x00\x00\x00"}, + {1, "\xFF", 3, "\x02\x07\x80"}, + {2, "\xFF", 3, "\x02\x06\xc0"}, + {3, "\xFF", 3, "\x02\x05\xe0"}, + {4, "\xFF", 3, "\x02\x04\xf0"}, + {5, "\xFF", 3, "\x02\x03\xf8"}, + {6, "\xFF", 3, "\x02\x02\xfc"}, + {7, "\xFF", 3, "\x02\x01\xfe"}, + {8, "\xFF\xFF", 3, "\x02\x00\xff"}, + {9, "\xFF\xFF", 4, "\x03\x07\xff\x80"}, + {10, "\xFF\xFF", 4, "\x03\x06\xff\xc0"}, + {11, "\xFF\xFF", 4, "\x03\x05\xff\xe0"}, + {12, "\xFF\xFF", 4, "\x03\x04\xff\xf0"}, + {13, "\xFF\xFF", 4, "\x03\x03\xff\xf8"}, + {14, "\xFF\xFF", 4, "\x03\x02\xff\xfc"}, + {15, "\xFF\xFF", 4, "\x03\x01\xff\xfe"}, + {16, "\xFF\xFF", 4, "\x03\x00\xff\xff"}, + {17, "\xFF\xFF\xFF", 5, "\x04\x07\xff\xff\x80"}, + {18, "\xFF\xFF\xFF", 5, "\x04\x06\xff\xff\xc0"}, + {19, "\xFF\xFF\xFF", 5, "\x04\x05\xff\xff\xe0"}, }; int @@ -115,8 +115,7 @@ main (int argc, char *argv[]) } #endif - if (der_len != tv[i].derlen - || memcmp (der, tv[i].der, der_len) != 0) + if (der_len != tv[i].derlen || memcmp (der, tv[i].der, der_len) != 0) { fprintf (stderr, "asn1_bit_der iter %ld\n", i); return 1; @@ -140,7 +139,7 @@ main (int argc, char *argv[]) STRING value "011011100101110111" can be any of the following, among others, depending on the choice of padding bits, the form of length octets [...]". - */ + */ /* 03 04 06 6e 5d c0 DER encoding */ -- 2.7.4