Fix some compile-time warnings

Fix all warnings generated by GCC -Wall -Wextra flags.
develop
Damien Goutte-Gattat 8 years ago
parent fd83c5fa32
commit c649fe73c7
  1. 16
      src/gpg-util.c
  2. 9
      src/scdrand.c
  3. 20
      src/scdtotp.c

@ -143,6 +143,8 @@ socket_name_cb(void *arg, const void *line, size_t len)
{
char **socket_name = (char **)arg;
(void)len;
if ( ! (*socket_name = strdup(line)) )
return gcry_error_from_errno(errno);
@ -231,17 +233,17 @@ init_agent_environment(assuan_context_t ctx)
const char *name;
const char *option;
} *var, env_vars[] = {
"GPG_TTY", "ttyname",
"TERM", "ttytype",
"DISPLAY", "display",
"XAUTHORITY", "xauthority",
"PINENTRY_USER_DATA", "pinentry-user-data",
NULL, NULL
{ "GPG_TTY", "ttyname" },
{ "TERM", "ttytype" },
{ "DISPLAY", "display" },
{ "XAUTHORITY", "xauthority" },
{ "PINENTRY_USER_DATA", "pinentry-user-data" },
{ NULL, NULL }
};
for ( var = env_vars, e = 0; var->name && e == 0; var++ ) {
if ( (value = getenv(var->name)) ) {
if ( snprintf(command, sizeof(command), "OPTION %s=%s",
if ( (unsigned) snprintf(command, sizeof(command), "OPTION %s=%s",
var->option, value) >= sizeof(command) )
e = gcry_error(GPG_ERR_TOO_LARGE);

@ -35,6 +35,8 @@
#include <linux/random.h>
#include <gcrypt.h>
#include "xmem.h"
#include "gpg-util.h"
@ -105,7 +107,7 @@ gpg_error_t
get_challenge_data_cb(void *arg, const void *line, size_t len)
{
struct challenge *c;
int i;
unsigned i;
c = (struct challenge *)arg;
@ -135,7 +137,7 @@ get_challenge(assuan_context_t ctx, unsigned char *buffer, size_t len)
gpg_error_t ge;
struct challenge c;
snprintf(command, sizeof(command), "RANDOM %d", len);
snprintf(command, sizeof(command), "RANDOM %lu", len);
c.len = len;
c.data = buffer;
@ -154,7 +156,8 @@ get_challenge(assuan_context_t ctx, unsigned char *buffer, size_t len)
static void
wait_for_threshold(unsigned threshold, unsigned interval)
{
int entropy, random_fd, loop = 1;
int random_fd, loop = 1;
unsigned entropy;
if ( (random_fd = open("/dev/random", O_RDONLY)) == -1 )
err(EXIT_FAILURE, "Cannot open /dev/random");

@ -106,6 +106,8 @@ time2factor(time_t time, int step, unsigned char *buffer, size_t len)
unsigned n_steps;
int i, j;
(void)len;
n_steps = time / step;
for ( i = 0, j = 7; i < 8; i++, j-- )
@ -127,8 +129,8 @@ time2factor(time_t time, int step, unsigned char *buffer, size_t len)
static int
hexstring2bytes(const char *hexstring, unsigned char *buffer, size_t len)
{
int high_nibble, n;
unsigned val;
int high_nibble;
unsigned val, n;
high_nibble = 1;
n = 0;
@ -221,7 +223,7 @@ generate_totp(int algo,
static int modulo[] = { 0, 0, 0, 0, 0, 0, 1000000, 10000000, 100000000 };
if ( (len = hexstring2bytes(key, buffer, sizeof(buffer))) == -1 )
if ( (int) (len = hexstring2bytes(key, buffer, sizeof(buffer))) == -1 )
return gcry_error(GPG_ERR_INV_KEYLEN);
if ( ! (e = gcry_mac_open(&mac, algo, 0, NULL)) ) {
@ -254,9 +256,9 @@ generate_totp(int algo,
}
struct key_data_t {
unsigned char *buffer;
size_t len;
int found;
char * buffer;
size_t len;
int found;
};
/*
@ -296,7 +298,7 @@ get_otp_key_cb(void *arg, const char *line)
* @return 0 if successful, or a gpg_error_t error code.
*/
static gpg_error_t
get_otp_key(unsigned privatedo, unsigned char *buffer, size_t len)
get_otp_key(unsigned privatedo, char *buffer, size_t len)
{
assuan_context_t ctx;
gpg_error_t e;
@ -347,8 +349,6 @@ verify_pin(int admin)
assuan_context_t ctx;
gpg_error_t e;
char command[64], serial[64];
char *line;
size_t len;
if ( ! (e = connect_to_agent(&ctx, 1)) ) {
@ -395,7 +395,7 @@ int
main(int argc, char **argv)
{
int c, algo;
unsigned char key[MAX_KEY_SIZE * 2 + 1];
char key[MAX_KEY_SIZE * 2 + 1];
unsigned otp, step, digits, privatedo;
time_t secs;
gcry_error_t e;

Loading…
Cancel
Save