summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-09-04 12:39:56 +0200
committerWerner Koch <wk@gnupg.org>2015-09-04 12:44:09 +0200
commite97c62a4a687b56d00a2d0a63e072a977f8eb81c (patch)
tree556069864fa6b38e6097486ffbabf05a8afddff8
parente2785a2268702312529521df3bd2f4e6b43cea3a (diff)
downloadlibgcrypt-e97c62a4a687b56d00a2d0a63e072a977f8eb81c.tar.gz
w32: Avoid a few compiler warnings.
* cipher/cipher-selftest.c (_gcry_selftest_helper_cbc) (_gcry_selftest_helper_cfb, _gcry_selftest_helper_ctr): Mark variable as unused. * random/rndw32.c (slow_gatherer): Avoid signed pointer mismatch warning. * src/secmem.c (init_pool): Avoid unused variable warning. * tests/random.c (writen, readn): Include on if needed. Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r--cipher/cipher-selftest.c6
-rw-r--r--random/rndw32.c2
-rw-r--r--src/secmem.c74
-rw-r--r--tests/fipsdrv.c4
-rw-r--r--tests/gchash.c2
-rw-r--r--tests/random.c7
6 files changed, 54 insertions, 41 deletions
diff --git a/cipher/cipher-selftest.c b/cipher/cipher-selftest.c
index 470499fc..cecbab75 100644
--- a/cipher/cipher-selftest.c
+++ b/cipher/cipher-selftest.c
@@ -131,6 +131,8 @@ _gcry_selftest_helper_cbc (const char *cipher, gcry_cipher_setkey_t setkey_func,
syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
"%s-CBC-%d test failed (plaintext mismatch)", cipher,
blocksize * 8);
+#else
+ (void)cipher; /* Not used. */
#endif
return "selftest for CBC failed - see syslog for details";
}
@@ -251,6 +253,8 @@ _gcry_selftest_helper_cfb (const char *cipher, gcry_cipher_setkey_t setkey_func,
syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
"%s-CFB-%d test failed (plaintext mismatch)", cipher,
blocksize * 8);
+#else
+ (void)cipher; /* Not used. */
#endif
return "selftest for CFB failed - see syslog for details";
}
@@ -379,6 +383,8 @@ _gcry_selftest_helper_ctr (const char *cipher, gcry_cipher_setkey_t setkey_func,
syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
"%s-CTR-%d test failed (plaintext mismatch)", cipher,
blocksize * 8);
+#else
+ (void)cipher; /* Not used. */
#endif
return "selftest for CTR failed - see syslog for details";
}
diff --git a/random/rndw32.c b/random/rndw32.c
index 4ab1bca3..1325b18b 100644
--- a/random/rndw32.c
+++ b/random/rndw32.c
@@ -513,7 +513,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
status = RegQueryValueEx (hKey, "ProductType", 0, NULL,
szValue, &dwSize);
- if (status == ERROR_SUCCESS && stricmp (szValue, "WinNT"))
+ if (status == ERROR_SUCCESS && stricmp ((char*)szValue, "WinNT"))
{
/* Note: There are (at least) three cases for ProductType:
WinNT = NT Workstation, ServerNT = NT Server, LanmanNT =
diff --git a/src/secmem.c b/src/secmem.c
index d75c14ce..2109bc2c 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -363,8 +363,6 @@ lock_pool (void *p, size_t n)
static void
init_pool (size_t n)
{
- size_t pgsize;
- long int pgsize_val;
memblock_t *mb;
pool_size = n;
@@ -372,48 +370,54 @@ init_pool (size_t n)
if (disable_secmem)
log_bug ("secure memory is disabled");
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
- pgsize_val = sysconf (_SC_PAGESIZE);
-#elif defined(HAVE_GETPAGESIZE)
- pgsize_val = getpagesize ();
-#else
- pgsize_val = -1;
-#endif
- pgsize = (pgsize_val != -1 && pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
-
#if HAVE_MMAP
- pool_size = (pool_size + pgsize - 1) & ~(pgsize - 1);
-#ifdef MAP_ANONYMOUS
- pool = mmap (0, pool_size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-#else /* map /dev/zero instead */
{
- int fd;
+ size_t pgsize;
+ long int pgsize_val;
+
+# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ pgsize_val = sysconf (_SC_PAGESIZE);
+# elif defined(HAVE_GETPAGESIZE)
+ pgsize_val = getpagesize ();
+# else
+ pgsize_val = -1;
+# endif
+ pgsize = (pgsize_val != -1 && pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
+
+ pool_size = (pool_size + pgsize - 1) & ~(pgsize - 1);
+# ifdef MAP_ANONYMOUS
+ pool = mmap (0, pool_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+# else /* map /dev/zero instead */
+ {
+ int fd;
- fd = open ("/dev/zero", O_RDWR);
- if (fd == -1)
- {
- log_error ("can't open /dev/zero: %s\n", strerror (errno));
- pool = (void *) -1;
- }
+ fd = open ("/dev/zero", O_RDWR);
+ if (fd == -1)
+ {
+ log_error ("can't open /dev/zero: %s\n", strerror (errno));
+ pool = (void *) -1;
+ }
+ else
+ {
+ pool = mmap (0, pool_size,
+ (PROT_READ | PROT_WRITE), MAP_PRIVATE, fd, 0);
+ close (fd);
+ }
+ }
+# endif
+ if (pool == (void *) -1)
+ log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
+ (unsigned) pool_size, strerror (errno));
else
{
- pool = mmap (0, pool_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
- close (fd);
+ pool_is_mmapped = 1;
+ pool_okay = 1;
}
}
-#endif
- if (pool == (void *) -1)
- log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
- (unsigned) pool_size, strerror (errno));
- else
- {
- pool_is_mmapped = 1;
- pool_okay = 1;
- }
+#endif /*HAVE_MMAP*/
-#endif
if (!pool_okay)
{
pool = malloc (pool_size);
diff --git a/tests/fipsdrv.c b/tests/fipsdrv.c
index eef2ddd1..b3da2a30 100644
--- a/tests/fipsdrv.c
+++ b/tests/fipsdrv.c
@@ -2358,14 +2358,14 @@ main (int argc, char **argv)
{
if (!(++count % 1000))
fprintf (stderr, PGM ": %lu random bytes so far\n",
- (unsigned long int)count * sizeof buffer);
+ (unsigned long int)(count * sizeof buffer));
}
}
while (loop_mode);
if (progress)
fprintf (stderr, PGM ": %lu random bytes\n",
- (unsigned long int)count * sizeof buffer);
+ (unsigned long int)(count * sizeof buffer));
deinit_external_rng_test (context);
}
diff --git a/tests/gchash.c b/tests/gchash.c
index 7a2aad68..7ff99e0c 100644
--- a/tests/gchash.c
+++ b/tests/gchash.c
@@ -109,7 +109,7 @@ main (int argc, char **argv)
h = gcry_md_read(hd, 0);
for (i = 0; i < gcry_md_get_algo_dlen (algo); i++)
- printf("%02hhx", h[i]);
+ printf("%02x", h[i]);
printf(" %s\n", *argv);
gcry_md_reset(hd);
diff --git a/tests/random.c b/tests/random.c
index 10bf6467..d7a624ad 100644
--- a/tests/random.c
+++ b/tests/random.c
@@ -87,7 +87,7 @@ progress_cb (void *cb_data, const char *what, int printchar,
}
-
+#ifndef HAVE_W32_SYSTEM
static int
writen (int fd, const void *buf, size_t nbytes)
{
@@ -110,7 +110,10 @@ writen (int fd, const void *buf, size_t nbytes)
return 0;
}
+#endif /*!HAVE_W32_SYSTEM*/
+
+#ifndef HAVE_W32_SYSTEM
static int
readn (int fd, void *buf, size_t buflen, size_t *ret_nread)
{
@@ -136,7 +139,7 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread)
*ret_nread = buflen - nleft;
return 0;
}
-
+#endif /*!HAVE_W32_SYSTEM*/
/* Check that forking won't return the same random. */