Skip to content

Commit

Permalink
fix some code with obvious wrong coding style
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#16918)
  • Loading branch information
x2018 authored and paulidale committed Oct 28, 2021
1 parent 0145172 commit 1287dab
Show file tree
Hide file tree
Showing 116 changed files with 229 additions and 230 deletions.
2 changes: 1 addition & 1 deletion apps/dgst.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static const char *newline_escape_filename(const char *file, int * backslash)
file_cpy = app_malloc(mem_len, file);
i = 0;

while(e < length) {
while (e < length) {
const char c = file[e];
if (c == '\n') {
file_cpy[i++] = '\\';
Expand Down
2 changes: 1 addition & 1 deletion apps/lib/app_libctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OSSL_LIB_CTX *app_create_libctx(void)
*/
if (app_libctx == NULL) {
if (!app_provider_load(NULL, "null")) {
opt_printf_stderr( "Failed to create null provider\n");
opt_printf_stderr("Failed to create null provider\n");
return NULL;
}
app_libctx = OSSL_LIB_CTX_new();
Expand Down
2 changes: 1 addition & 1 deletion apps/lib/app_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int loadfiles(char *name)
char *p;
int last, ret = 1;

for ( ; ; ) {
for (;;) {
last = 0;
for (p = name; *p != '\0' && *p != LIST_SEPARATOR_CHAR; p++)
continue;
Expand Down
8 changes: 4 additions & 4 deletions apps/lib/apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ int load_crls(const char *uri, STACK_OF(X509_CRL) **crls,

static const char *format2string(int format)
{
switch(format) {
switch (format) {
case FORMAT_PEM:
return "PEM";
case FORMAT_ASN1:
Expand Down Expand Up @@ -1942,7 +1942,7 @@ X509_NAME *parse_name(const char *cp, int chtype, int canmulti,
ERR_print_errors(bio_err);
BIO_printf(bio_err,
"%s: Error adding %s name attribute \"/%s=%s\"\n",
opt_getprog(), desc, typestr ,valstr);
opt_getprog(), desc, typestr, valstr);
goto err;
}
}
Expand Down Expand Up @@ -2845,9 +2845,9 @@ int raw_write_stdout(const void *buf, int siz)
# include <floss.h(floss_write)>
# endif
# endif
int raw_write_stdout(const void *buf,int siz)
int raw_write_stdout(const void *buf, int siz)
{
return write(fileno(stdout),(void*)buf,siz);
return write(fileno(stdout), (void*)buf, siz);
}
#else
# if defined(__TANDEM)
Expand Down
2 changes: 1 addition & 1 deletion apps/lib/cmp_mock_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <openssl/cmp.h>
#include <openssl/err.h>
#include <openssl/cmperr.h>

/* the context for the CMP mock server */
typedef struct
{
Expand Down
2 changes: 1 addition & 1 deletion apps/lib/s_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ void print_ca_names(BIO *bio, SSL *s)
return;
}

BIO_printf(bio, "---\nAcceptable %s certificate CA names\n",cs);
BIO_printf(bio, "---\nAcceptable %s certificate CA names\n", cs);
for (i = 0; i < sk_X509_NAME_num(sk); i++) {
X509_NAME_print_ex(bio, sk_X509_NAME_value(sk, i), 0, get_nameopt());
BIO_write(bio, "\n", 1);
Expand Down
14 changes: 7 additions & 7 deletions apps/lib/vms_term_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ typedef struct _SocketPairTimeoutBlock {
} SPTB;

# ifdef TERM_SOCK_TEST


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -160,7 +160,7 @@ int main (int argc, char *argv[], char *envp[])

}
# endif


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -275,7 +275,7 @@ int TerminalSocket (int FunctionCode, int *ReturnSocket)
return TERM_SOCK_SUCCESS;

}


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -441,7 +441,7 @@ static int CreateSocketPair (int SocketFamily,
sin.sin_port = LocalHostPort ;

status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof(sin));
if (status < 0 ) {
if (status < 0) {
LogMessage ("CreateSocketPair: connect () - %d", errno);
sys$cantim (&sptb, 0);
sys$cancel (TcpAcceptChan);
Expand Down Expand Up @@ -485,7 +485,7 @@ static int CreateSocketPair (int SocketFamily,
return (0) ;

}


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand All @@ -499,7 +499,7 @@ static void SocketPairTimeoutAst (int astparm)
return;

}


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -538,7 +538,7 @@ static int TerminalDeviceAst (int astparm)
return status;

}


/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion apps/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int mac_main(int argc, char **argv)
for (i = 0; i < (int)len; ++i)
BIO_printf(out, "%02X", buf[i]);
if (outfile == NULL)
BIO_printf(out,"\n");
BIO_printf(out, "\n");
}

ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion apps/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ static void make_ocsp_response(BIO *err, OCSP_RESPONSE **resp, OCSP_REQUEST *req
OCSP_copy_nonce(bs, req);

mctx = EVP_MD_CTX_new();
if ( mctx == NULL || !EVP_DigestSignInit(mctx, &pkctx, rmd, NULL, rkey)) {
if (mctx == NULL || !EVP_DigestSignInit(mctx, &pkctx, rmd, NULL, rkey)) {
*resp = OCSP_response_create(OCSP_RESPONSE_STATUS_INTERNALERROR, NULL);
goto end;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
OPENSSL_strlcat(out_buf, ascii_salt, sizeof(out_buf));

/* assert "$5$rounds=999999999$......salt......" */
if (strlen(out_buf) > 3 + 17 * rounds_custom + salt_len )
if (strlen(out_buf) > 3 + 17 * rounds_custom + salt_len)
goto err;

md = EVP_MD_CTX_new();
Expand Down
4 changes: 2 additions & 2 deletions apps/pkeyutl.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ static int do_raw_keyop(int pkey_op, EVP_MD_CTX *mctx,
goto end;
}
mbuf = app_malloc(filesize, "oneshot sign/verify buffer");
switch(pkey_op) {
switch (pkey_op) {
case EVP_PKEY_OP_VERIFY:
buf_len = BIO_read(in, mbuf, filesize);
if (buf_len != filesize) {
Expand All @@ -754,7 +754,7 @@ static int do_raw_keyop(int pkey_op, EVP_MD_CTX *mctx,
goto end;
}

switch(pkey_op) {
switch (pkey_op) {
case EVP_PKEY_OP_VERIFY:
for (;;) {
buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
Expand Down
2 changes: 1 addition & 1 deletion apps/req.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ int req_main(int argc, char **argv)
goto end;
}

if (!make_REQ(req, pkey, fsubj, multirdn, !gen_x509, chtype)){
if (!make_REQ(req, pkey, fsubj, multirdn, !gen_x509, chtype)) {
BIO_printf(bio_err, "Error making certificate request\n");
goto end;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/s_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ int s_client_main(int argc, char **argv)

if (!noservername && (servername != NULL || dane_tlsa_domain == NULL)) {
if (servername == NULL) {
if(host == NULL || is_dNS_name(host))
if (host == NULL || is_dNS_name(host))
servername = (host == NULL) ? "localhost" : host;
}
if (servername != NULL && !SSL_set_tlsext_host_name(con, servername)) {
Expand Down Expand Up @@ -2984,7 +2984,7 @@ int s_client_main(int argc, char **argv)
BIO_printf(bio_err, "RENEGOTIATING\n");
SSL_renegotiate(con);
cbuf_len = 0;
} else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k' )
} else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k')
&& cmdletters) {
BIO_printf(bio_err, "KEYUPDATE\n");
SSL_key_update(con,
Expand Down
2 changes: 1 addition & 1 deletion crypto/LPdir_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
if ((*ctx)->expect_file_generations) {
char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name);

while(p > (*ctx)->entry_name && isdigit(p[-1]))
while (p > (*ctx)->entry_name && isdigit(p[-1]))
p--;
if (p > (*ctx)->entry_name && p[-1] == ';')
p[-1] = '\0';
Expand Down
5 changes: 3 additions & 2 deletions crypto/aes/aes_x86core.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@
#if 1
static void prefetch256(const void *table)
{
volatile unsigned long *t=(void *)table,ret;
volatile unsigned long *t = (void *)table, ret;
unsigned long sum;
int i;

/* 32 is common least cache-line size */
for (sum=0,i=0;i<256/sizeof(t[0]);i+=32/sizeof(t[0])) sum ^= t[i];
for (sum = 0, i = 0; i < 256/sizeof(t[0]); i += 32/sizeof(t[0]))
sum ^= t[i];

ret = sum;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void ossl_aria_encrypt(const unsigned char *in, unsigned char *out,
ARIA_ADD_ROUND_KEY(rk, reg0, reg1, reg2, reg3);
rk++;

while(Nr -= 2){
while (Nr -= 2) {
ARIA_SUBST_DIFF_EVEN(reg0, reg1, reg2, reg3);
ARIA_ADD_ROUND_KEY(rk, reg0, reg1, reg2, reg3);
rk++;
Expand Down
12 changes: 6 additions & 6 deletions crypto/bio/bio_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
{
int ret = 0; /* Assume failure */

switch(family) {
switch (family) {
case AF_INET:
#ifdef AF_INET6
case AF_INET6:
Expand Down Expand Up @@ -789,7 +789,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
he_fallback_address = INADDR_ANY;
if (host == NULL) {
he = &he_fallback;
switch(lookup_type) {
switch (lookup_type) {
case BIO_LOOKUP_CLIENT:
he_fallback_address = INADDR_LOOPBACK;
break;
Expand Down Expand Up @@ -906,12 +906,12 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,

/* The easiest way to create a linked list from an
array is to start from the back */
for(addrlistp = he->h_addr_list; *addrlistp != NULL;
addrlistp++)
for (addrlistp = he->h_addr_list; *addrlistp != NULL;
addrlistp++)
;

for(addresses = addrlistp - he->h_addr_list;
addrlistp--, addresses-- > 0; ) {
for (addresses = addrlistp - he->h_addr_list;
addrlistp--, addresses-- > 0; ) {
if (!addrinfo_wrap(he->h_addrtype, socktype,
*addrlistp, he->h_length,
se->s_port, &tmp_bai))
Expand Down
8 changes: 4 additions & 4 deletions crypto/bn/asm/sparcv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ bn_add_words:
inc 16,%o1
addxcc %g3,%g4,%g3
st %g3,[%o0+4]

ld [%o1-4],%g3
ld [%o2+12],%g4
inc 16,%o2
Expand Down Expand Up @@ -469,7 +469,7 @@ bn_sub_words:
inc 16,%o1
subxcc %g3,%g4,%g4
st %g4,[%o0+4]

ld [%o1-4],%g3
ld [%o2+12],%g4
inc 16,%o2
Expand Down Expand Up @@ -1040,7 +1040,7 @@ bn_mul_comba4:
addxcc c_2,t_2,c_2 !=
st c_1,rp(6) !r[6]=c1;
st c_2,rp(7) !r[7]=c2;

ret
restore %g0,%g0,%o0

Expand Down Expand Up @@ -1448,7 +1448,7 @@ bn_sqr_comba4:
addxcc c_2,t_2,c_2 !=
st c_1,rp(6) !r[6]=c1;
st c_2,rp(7) !r[7]=c2;

ret
restore %g0,%g0,%o0

Expand Down
6 changes: 3 additions & 3 deletions crypto/bn/asm/sparcv8plus.S
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ bn_add_words:
inc 16,%o1
addccc %g1,%g2,%g1
stuw %g1,[%o0+4]

inc 16,%o2
addccc %g3,%g4,%g3
stuw %g3,[%o0+8]
Expand Down Expand Up @@ -1126,7 +1126,7 @@ bn_mul_comba4:
srlx t_1,32,c_12 !=
stuw t_1,rp(6) !r[6]=c1;
stuw c_12,rp(7) !r[7]=c2;

ret
restore %g0,%g0,%o0

Expand Down Expand Up @@ -1548,7 +1548,7 @@ bn_sqr_comba4:
srlx t_1,32,c_12
stuw t_1,rp(6) !r[6]=c1;
stuw c_12,rp(7) !r[7]=c2;

ret
restore %g0,%g0,%o0

Expand Down
2 changes: 1 addition & 1 deletion crypto/bn/bn_rsa_fips186_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1,
BN_set_flags(p1, BN_FLG_CONSTTIME);

/* Find the first odd number >= Xp1 that is probably prime */
for(;;) {
for (;;) {
i++;
BN_GENCB_call(cb, 0, i);
/* MR test with trial division */
Expand Down
2 changes: 1 addition & 1 deletion crypto/cmp/cmp_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx,
}

msg = OSSL_CMP_MSG_new(libctx, propq);
if (msg == NULL){
if (msg == NULL) {
ERR_raise(ERR_LIB_CMP, ERR_R_MALLOC_FAILURE);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/cms/cms_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ static EVP_CIPHER *cms_get_key_wrap_cipher(size_t keylen, const CMS_CTX *ctx)
{
const char *alg = NULL;

switch(keylen) {
switch (keylen) {
case 16:
alg = "AES-128-WRAP";
break;
Expand Down
4 changes: 2 additions & 2 deletions crypto/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static uint64_t ossl_strtouint64(const variant_char *str)
base = 16, str++;
}

while((digit = todigit(*str++)) < base)
while ((digit = todigit(*str++)) < base)
ret = ret * base + digit;

return ret;
Expand All @@ -80,7 +80,7 @@ static uint64_t ossl_strtouint64(const variant_char *str)
static variant_char *ossl_strchr(const variant_char *str, char srch)
{ variant_char c;

while((c = *str)) {
while ((c = *str)) {
if (c == srch)
return (variant_char *)str;
str++;
Expand Down
2 changes: 1 addition & 1 deletion crypto/ec/ec2_smpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ int ossl_ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point
* We have a curve defined by a Weierstrass equation
* y^2 + x*y = x^3 + a*x^2 + b.
* <=> x^3 + a*x^2 + x*y + b + y^2 = 0
* <=> ((x + a) * x + y ) * x + b + y^2 = 0
* <=> ((x + a) * x + y) * x + b + y^2 = 0
*/
if (!BN_GF2m_add(lh, point->X, group->a))
goto err;
Expand Down
Loading

0 comments on commit 1287dab

Please sign in to comment.