mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Fix coccinelle complaint in test-memwipe.c
This commit is contained in:
parent
1ee748e4ca
commit
2aa5e95f58
@ -30,8 +30,8 @@ const char *s = NULL;
|
|||||||
#define BUF_LEN 2048
|
#define BUF_LEN 2048
|
||||||
|
|
||||||
#define FILL_BUFFER_IMPL() \
|
#define FILL_BUFFER_IMPL() \
|
||||||
|
do { \
|
||||||
unsigned int i; \
|
unsigned int i; \
|
||||||
unsigned sum = 0; \
|
|
||||||
\
|
\
|
||||||
/* Fill up a 1k buffer with a recognizable pattern. */ \
|
/* Fill up a 1k buffer with a recognizable pattern. */ \
|
||||||
for (i = 0; i < BUF_LEN; i += strlen(s)) { \
|
for (i = 0; i < BUF_LEN; i += strlen(s)) { \
|
||||||
@ -42,7 +42,8 @@ const char *s = NULL;
|
|||||||
/* optimized away. */ \
|
/* optimized away. */ \
|
||||||
for (i = 0; i < BUF_LEN; ++i) { \
|
for (i = 0; i < BUF_LEN; ++i) { \
|
||||||
sum += (unsigned char)buf[i]; \
|
sum += (unsigned char)buf[i]; \
|
||||||
}
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#ifdef OpenBSD
|
#ifdef OpenBSD
|
||||||
/* Disable some of OpenBSD's malloc protections for this test. This helps
|
/* Disable some of OpenBSD's malloc protections for this test. This helps
|
||||||
@ -55,7 +56,8 @@ static unsigned
|
|||||||
fill_a_buffer_memset(void)
|
fill_a_buffer_memset(void)
|
||||||
{
|
{
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@ -64,7 +66,8 @@ static unsigned
|
|||||||
fill_a_buffer_memwipe(void)
|
fill_a_buffer_memwipe(void)
|
||||||
{
|
{
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
memwipe(buf, 0, sizeof(buf));
|
memwipe(buf, 0, sizeof(buf));
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@ -73,7 +76,8 @@ static unsigned
|
|||||||
fill_a_buffer_nothing(void)
|
fill_a_buffer_nothing(void)
|
||||||
{
|
{
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +120,8 @@ static unsigned
|
|||||||
fill_heap_buffer_memset(void)
|
fill_heap_buffer_memset(void)
|
||||||
{
|
{
|
||||||
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
memset(buf, 0, BUF_LEN);
|
memset(buf, 0, BUF_LEN);
|
||||||
raw_free(buf);
|
raw_free(buf);
|
||||||
return sum;
|
return sum;
|
||||||
@ -126,7 +131,8 @@ static unsigned
|
|||||||
fill_heap_buffer_memwipe(void)
|
fill_heap_buffer_memwipe(void)
|
||||||
{
|
{
|
||||||
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
memwipe(buf, 0, BUF_LEN);
|
memwipe(buf, 0, BUF_LEN);
|
||||||
raw_free(buf);
|
raw_free(buf);
|
||||||
return sum;
|
return sum;
|
||||||
@ -136,7 +142,8 @@ static unsigned
|
|||||||
fill_heap_buffer_nothing(void)
|
fill_heap_buffer_nothing(void)
|
||||||
{
|
{
|
||||||
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
char *buf = heap_buf = raw_malloc(BUF_LEN);
|
||||||
FILL_BUFFER_IMPL()
|
unsigned sum = 0;
|
||||||
|
FILL_BUFFER_IMPL();
|
||||||
raw_free(buf);
|
raw_free(buf);
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user