-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Avoiding conditional directives that split up parts of statements. #1480
base: master
Are you sure you want to change the base?
Changes from 6 commits
30fa7c7
dc5881d
68ca982
4dcfa8b
4e2c2df
e4c075f
10ad117
2bc8074
b094268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,12 +239,12 @@ escrypt_kdf_nosse(escrypt_local_t * local, | |
uint32_t i; | ||
|
||
/* Sanity-check parameters. */ | ||
#if SIZE_MAX > UINT32_MAX | ||
#if SIZE_MAX > UINT32_MAX | ||
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { | ||
errno = EFBIG; | ||
return -1; | ||
} | ||
#endif | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And undo this. |
||
if ((uint64_t)(r) * (uint64_t)(p) >= (1 << 30)) { | ||
errno = EFBIG; | ||
return -1; | ||
|
@@ -257,11 +257,11 @@ escrypt_kdf_nosse(escrypt_local_t * local, | |
errno = EINVAL; | ||
return -1; | ||
} | ||
if ((r > SIZE_MAX / 128 / p) || | ||
#if SIZE_MAX / 256 <= UINT32_MAX | ||
(r > SIZE_MAX / 256) || | ||
#endif | ||
(N > SIZE_MAX / 128 / r)) { | ||
int test = (r > SIZE_MAX / 128 / p) || (N > SIZE_MAX / 128 / r); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
#if SIZE_MAX / 256 <= UINT32_MAX | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to column 0. |
||
test = test || (r > SIZE_MAX / 256); | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to column 0. |
||
if (test) { | ||
errno = ENOMEM; | ||
return -1; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,29 +40,29 @@ void * | |
alloc_region(escrypt_region_t * region, size_t size) | ||
{ | ||
uint8_t * base, * aligned; | ||
#ifdef MAP_ANON | ||
if ((base = (uint8_t *) mmap(NULL, size, PROT_READ | PROT_WRITE, | ||
#ifdef MAP_NOCORE | ||
MAP_ANON | MAP_PRIVATE | MAP_NOCORE, | ||
#else | ||
MAP_ANON | MAP_PRIVATE, | ||
#endif | ||
-1, 0)) == MAP_FAILED) | ||
#ifdef MAP_ANON | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move all of these back to column 0. |
||
int flags; | ||
#ifdef MAP_NOCORE | ||
flags = MAP_ANON | MAP_PRIVATE | MAP_NOCORE; | ||
#else | ||
flags = MAP_ANON | MAP_PRIVATE; | ||
#endif | ||
if ((base = (uint8_t *) mmap(NULL, size, PROT_READ | PROT_WRITE, flags, -1, 0)) == MAP_FAILED) | ||
base = NULL; | ||
aligned = base; | ||
#elif defined(HAVE_POSIX_MEMALIGN) | ||
#elif defined(HAVE_POSIX_MEMALIGN) | ||
if ((errno = posix_memalign((void **) &base, 64, size)) != 0) | ||
base = NULL; | ||
aligned = base; | ||
#else | ||
#else | ||
base = aligned = NULL; | ||
if (size + 63 < size) | ||
errno = ENOMEM; | ||
else if ((base = (uint8_t *) malloc(size + 63)) != NULL) { | ||
aligned = base + 63; | ||
aligned -= (uintptr_t)aligned & 63; | ||
} | ||
#endif | ||
#endif | ||
region->base = base; | ||
region->aligned = aligned; | ||
region->size = base ? size : 0; | ||
|
@@ -80,12 +80,12 @@ int | |
free_region(escrypt_region_t * region) | ||
{ | ||
if (region->base) { | ||
#ifdef MAP_ANON | ||
#ifdef MAP_ANON | ||
if (munmap(region->base, region->size)) | ||
return -1; | ||
#else | ||
#else | ||
free(region->base); | ||
#endif | ||
#endif | ||
} | ||
init_region(region); | ||
return 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,16 +319,16 @@ escrypt_kdf_sse(escrypt_local_t * local, | |
size_t B_size, V_size, XY_size, need; | ||
uint8_t * B; | ||
uint32_t * V, * XY; | ||
size_t r = _r, p = _p; | ||
size_t r = _r, p = _p; | ||
uint32_t i; | ||
|
||
/* Sanity-check parameters. */ | ||
#if SIZE_MAX > UINT32_MAX | ||
#if SIZE_MAX > UINT32_MAX | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing in this file: revert the style change. |
||
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { | ||
errno = EFBIG; | ||
return -1; | ||
} | ||
#endif | ||
#endif | ||
if ((uint64_t)(r) * (uint64_t)(p) >= (1 << 30)) { | ||
errno = EFBIG; | ||
return -1; | ||
|
@@ -345,11 +345,11 @@ escrypt_kdf_sse(escrypt_local_t * local, | |
errno = EINVAL; | ||
return -1; | ||
} | ||
if ((r > SIZE_MAX / 128 / p) || | ||
#if SIZE_MAX / 256 <= UINT32_MAX | ||
(r > SIZE_MAX / 256) || | ||
#endif | ||
(N > SIZE_MAX / 128 / r)) { | ||
int test = (r > SIZE_MAX / 128 / p) || (N > SIZE_MAX / 128 / r); | ||
#if SIZE_MAX / 256 <= UINT32_MAX | ||
test = test || (r > SIZE_MAX / 256); | ||
#endif | ||
if (test) { | ||
errno = ENOMEM; | ||
return -1; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marciomribeiro please undo this formatting change.