From: jsing Date: Sat, 19 Apr 2014 12:51:01 +0000 (+0000) Subject: More KNF. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e64646704e6e72e5866c94c69622a4ce415cbc57;p=openbsd More KNF. --- diff --git a/lib/libcrypto/asn1/a_int.c b/lib/libcrypto/asn1/a_int.c index ef47eb106bb..05776f572c6 100644 --- a/lib/libcrypto/asn1/a_int.c +++ b/lib/libcrypto/asn1/a_int.c @@ -175,7 +175,7 @@ i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) *(p--) = ((*(n--)) ^ 0xff) + 1; i--; /* Complement any octets left */ - for(; i > 0; i--) + for (; i > 0; i--) *(p--) = *(n--) ^ 0xff; } @@ -244,7 +244,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) } else { *(to--) = (*(p--) ^ 0xff) + 1; i--; - for(; i > 0; i--) + for (; i > 0; i--) *(to--) = *(p--) ^ 0xff; } } else { diff --git a/lib/libcrypto/asn1/a_mbstr.c b/lib/libcrypto/asn1/a_mbstr.c index 6528161c41a..b59d84910f6 100644 --- a/lib/libcrypto/asn1/a_mbstr.c +++ b/lib/libcrypto/asn1/a_mbstr.c @@ -89,8 +89,7 @@ ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, - long minsize, long maxsize) + int inform, unsigned long mask, long minsize, long maxsize) { int str_type; int ret; @@ -109,7 +108,6 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, /* First do a string check and work out the number of characters */ switch (inform) { - case MBSTRING_BMP: if (len & 1) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, @@ -264,6 +262,7 @@ traverse_string(const unsigned char *p, int len, int inform, { unsigned long value; int ret; + while (len) { if (inform == MBSTRING_ASC) { value = *p++; @@ -280,8 +279,9 @@ traverse_string(const unsigned char *p, int len, int inform, len -= 4; } else { ret = UTF8_getc(p, len, &value); - if (ret < 0) return -1; - len -= ret; + if (ret < 0) + return -1; + len -= ret; p += ret; } if (rfunc) { @@ -301,6 +301,7 @@ static int in_utf8(unsigned long value, void *arg) { int *nchar; + nchar = arg; (*nchar)++; return 1; @@ -312,6 +313,7 @@ static int out_utf8(unsigned long value, void *arg) { int *outlen; + outlen = arg; *outlen += UTF8_putc(NULL, -1, value); return 1; @@ -408,8 +410,10 @@ is_printable(unsigned long value) { int ch; - if (value > 0x7f) return 0; - ch = (int)value; + if (value > 0x7f) + return 0; + ch = (int)value; + /* Note: we can't use 'isalnum' because certain accented * characters may count as alphanumeric in some environments. */ diff --git a/lib/libcrypto/asn1/a_object.c b/lib/libcrypto/asn1/a_object.c index 293b269c218..93c755228a2 100644 --- a/lib/libcrypto/asn1/a_object.c +++ b/lib/libcrypto/asn1/a_object.c @@ -78,7 +78,7 @@ i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) return objsize; p = *pp; - ASN1_put_object(&p, 0,a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); + ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); memcpy(p, a->data, a->length); p += a->length; diff --git a/lib/libssl/src/crypto/asn1/a_int.c b/lib/libssl/src/crypto/asn1/a_int.c index ef47eb106bb..05776f572c6 100644 --- a/lib/libssl/src/crypto/asn1/a_int.c +++ b/lib/libssl/src/crypto/asn1/a_int.c @@ -175,7 +175,7 @@ i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) *(p--) = ((*(n--)) ^ 0xff) + 1; i--; /* Complement any octets left */ - for(; i > 0; i--) + for (; i > 0; i--) *(p--) = *(n--) ^ 0xff; } @@ -244,7 +244,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) } else { *(to--) = (*(p--) ^ 0xff) + 1; i--; - for(; i > 0; i--) + for (; i > 0; i--) *(to--) = *(p--) ^ 0xff; } } else { diff --git a/lib/libssl/src/crypto/asn1/a_mbstr.c b/lib/libssl/src/crypto/asn1/a_mbstr.c index 6528161c41a..b59d84910f6 100644 --- a/lib/libssl/src/crypto/asn1/a_mbstr.c +++ b/lib/libssl/src/crypto/asn1/a_mbstr.c @@ -89,8 +89,7 @@ ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, - long minsize, long maxsize) + int inform, unsigned long mask, long minsize, long maxsize) { int str_type; int ret; @@ -109,7 +108,6 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, /* First do a string check and work out the number of characters */ switch (inform) { - case MBSTRING_BMP: if (len & 1) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, @@ -264,6 +262,7 @@ traverse_string(const unsigned char *p, int len, int inform, { unsigned long value; int ret; + while (len) { if (inform == MBSTRING_ASC) { value = *p++; @@ -280,8 +279,9 @@ traverse_string(const unsigned char *p, int len, int inform, len -= 4; } else { ret = UTF8_getc(p, len, &value); - if (ret < 0) return -1; - len -= ret; + if (ret < 0) + return -1; + len -= ret; p += ret; } if (rfunc) { @@ -301,6 +301,7 @@ static int in_utf8(unsigned long value, void *arg) { int *nchar; + nchar = arg; (*nchar)++; return 1; @@ -312,6 +313,7 @@ static int out_utf8(unsigned long value, void *arg) { int *outlen; + outlen = arg; *outlen += UTF8_putc(NULL, -1, value); return 1; @@ -408,8 +410,10 @@ is_printable(unsigned long value) { int ch; - if (value > 0x7f) return 0; - ch = (int)value; + if (value > 0x7f) + return 0; + ch = (int)value; + /* Note: we can't use 'isalnum' because certain accented * characters may count as alphanumeric in some environments. */ diff --git a/lib/libssl/src/crypto/asn1/a_object.c b/lib/libssl/src/crypto/asn1/a_object.c index 293b269c218..93c755228a2 100644 --- a/lib/libssl/src/crypto/asn1/a_object.c +++ b/lib/libssl/src/crypto/asn1/a_object.c @@ -78,7 +78,7 @@ i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) return objsize; p = *pp; - ASN1_put_object(&p, 0,a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); + ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); memcpy(p, a->data, a->length); p += a->length;