summaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-05 09:34:25 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-05 10:05:24 +0300
commite0ae31fcce3bd57b24751ff3c82cba820e493c3a (patch)
treea8676136e5690eef1f4702eb6dea2507a624dd8f /src/misc.c
parent50ec983666f0ca9d50c84aa1afad0d7bd5810779 (diff)
downloadlibgcrypt-e0ae31fcce3bd57b24751ff3c82cba820e493c3a.tar.gz
Change _gcry_burn_stack take burn depth as unsigned integer
* src/misc.c (_gcry_burn_stack): Change to handle 'unsigned int' bytes. -- Unsigned integer is better here for code generation because we can now avoid possible branching caused by (bytes <= 0) check. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/misc.c b/src/misc.c
index 135aeb4c..dece1d04 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -288,10 +288,11 @@ _gcry_log_printhex (const char *text, const void *buffer, size_t length)
void
-_gcry_burn_stack (int bytes)
+_gcry_burn_stack (unsigned int bytes)
{
#ifdef HAVE_VLA
- int buflen = (((bytes <= 0) ? 1 : bytes) + 63) & ~63;
+ /* (bytes == 0 ? 1 : bytes) == (!bytes + bytes) */
+ unsigned int buflen = ((!bytes + bytes) + 63) & ~63;
volatile char buf[buflen];
wipememory (buf, sizeof buf);
@@ -300,9 +301,8 @@ _gcry_burn_stack (int bytes)
wipememory (buf, sizeof buf);
- bytes -= sizeof buf;
- if (bytes > 0)
- _gcry_burn_stack (bytes);
+ if (bytes > sizeof buf)
+ _gcry_burn_stack (bytes - sizeof buf);
#endif
}