Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize syntax around sizeof(foo) #4875

Closed
wants to merge 2 commits into from
Closed

Standardize syntax around sizeof(foo) #4875

wants to merge 2 commits into from

Conversation

richsalz
Copy link
Contributor

@richsalz richsalz commented Dec 8, 2017

This is the #4872 done for 1.0.2

@richsalz richsalz added branch: 1.0.2 Merge to OpenSSL_1_0_2-stable branch approval: review pending This pull request needs review by a committer labels Dec 8, 2017
@richsalz richsalz self-assigned this Dec 8, 2017
@@ -317,7 +317,7 @@ static int CreateSocketPair (int SocketFamily,
/*
** Initialize the socket information
*/
slen = sizeof (sin);
slen = sizeof(sin);
memset ((char *) &sin, 0, slen);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as in #4876, but three occurrences here...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cross-compared to master, it might be more appropriate to dismiss this comment, even in #4876. I mean it's probably more appropriate to address it separately [if at all].

wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space
wsize = OPENSSL_malloc(totalnum * sizeof(wsize[0]));
wNAF_len = OPENSSL_malloc(totalnum * sizeof(wNAF_len[0]));
wNAF = OPENSSL_malloc((totalnum + 1) * sizeof(wNAF[0])); /* includes space
* for pivot */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jagged comment

test/igetest.c Outdated
@@ -200,16 +200,16 @@ static int run_test_vectors(void)
assert(v->length <= MAX_VECTOR_SIZE);

if (v->encrypt == AES_ENCRYPT)
AES_set_encrypt_key(v->key, 8 * sizeof v->key, &key);
AES_set_encrypt_key(v->key, 8 * sizeof(v)->key, &key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aint right. It's sizeof(v->key), not sizeof(v)->key.

test/igetest.c Outdated
else
AES_set_decrypt_key(v->key, 8 * sizeof v->key, &key);
memcpy(iv, v->iv, sizeof iv);
AES_set_decrypt_key(v->key, 8 * sizeof(v)->key, &key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@richsalz
Copy link
Contributor Author

richsalz commented Dec 8, 2017

I don't want to fix anything other than the sizeof uses here.
I did fix the two syntax errors in igetest and pushed an updated commit.

@richsalz
Copy link
Contributor Author

richsalz commented Dec 8, 2017

Also fixed the "jagged comment" in crypto/ec/ec_mult.c

@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
unsigned char c;
BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple, *a, *b, *m;

RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we
RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or BN_rand may fail, and we
* don't even check its return
* value (which we should) */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another jagged comment... Even in #4876...

@@ -252,15 +252,15 @@ int OpenSocket(int nPort)
}

if (setsockopt
(nSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof one) < 0) {
(nSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an incompliant formatting! Side note!

@richsalz
Copy link
Contributor Author

richsalz commented Dec 8, 2017

Added commit to fix the exptest comment-wrapping issue.

@dot-asm dot-asm added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Dec 8, 2017
levitte pushed a commit that referenced this pull request Dec 8, 2017
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #4875)
@richsalz
Copy link
Contributor Author

richsalz commented Dec 8, 2017

Thanks for the feedback; merged to 1.0.2

@richsalz richsalz closed this Dec 8, 2017
@richsalz richsalz deleted the sizeof-for-102 branch December 8, 2017 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: 1.0.2 Merge to OpenSSL_1_0_2-stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants