added -Wextra -Werror and fixed everything it had to mecker about

This commit is contained in:
TLINDEN
2014-02-25 18:05:32 +01:00
parent 21b0ea38db
commit 8b955b5e92
19 changed files with 36 additions and 81 deletions

View File

@@ -24,7 +24,7 @@ static char de85[256];
static void prep_base85(void)
{
int i;
size_t i;
if (de85['Z'])
return;
for (i = 0; i < ARRAY_SIZE(en85); i++) {

View File

@@ -165,10 +165,10 @@ size_t pcp_decrypt_stream(Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *sym
pcp_pubkey_t *cur = NULL;
pcp_pubkey_t *sender = NULL;
byte *reccipher = NULL;
int nrec, recmatch, self;
int recmatch, self;
uint32_t lenrec;
byte head[1];
size_t cur_bufsize, rec_size;
size_t cur_bufsize, rec_size, nrec;
byte rec_buf[PCP_ASYM_RECIPIENT_SIZE];

View File

@@ -205,7 +205,7 @@ pcp_pubkey_t *pcp_ed_verify_buffered(Pcpstream *in, pcp_pubkey_t *p) {
/* printf("offset: %ld, full: %ld, cur: %ld\n", offset, full_bufsize, cur_bufsize); */
if(offset >= 0 && offset <= PCP_BLOCK_SIZE/2) {
if(offset > 0 && offset <= PCP_BLOCK_SIZE/2) {
/* sig begins within the first half, adjust in_buf size */
/* printf("1st half\n"); */
next_bufsize = 0;

View File

@@ -467,7 +467,6 @@ Buffer *pcp_export_c_pub(pcp_key_t *sk) {
struct tm *c;
time_t t = time(0);
c = localtime(&t);
size_t i;
buffer_add_str(b, "/*\n * C export of public key\n");
buffer_add_str(b, " * Generated on: %04d-%02d-%02dT%02d:%02d:%02d\n",

View File

@@ -28,7 +28,7 @@ void pcp_pad_prepend(byte **padded, byte *unpadded,
byte *tmp = ucmalloc(unpadlen + padlen);
/* pcp_append orig */
int i;
size_t i;
for(i=0; i<unpadlen; ++i) {
tmp[i + padlen] = unpadded[i];
}
@@ -42,7 +42,7 @@ void pcp_pad_remove(byte **unpadded, byte *padded,
*unpadded = ucmalloc(unpadlen * sizeof(byte));
byte *tmp = ucmalloc(unpadlen);
int i;
size_t i;
for(i=0; i<unpadlen; ++i) {
tmp[i] = padded[padlen + i];
}

View File

@@ -144,7 +144,7 @@ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) {
size_t ps_read_next(Pcpstream *stream) {
if(stream->armor == 1) {
/* fetch next chunk and decode it */
return ps_read_decode(stream, stream->next, NULL, 0);
return ps_read_decode(stream, NULL, 0);
}
else {
/* unencoded source, fetch as is */
@@ -192,7 +192,7 @@ void ps_determine(Pcpstream *stream) {
if(_buffer_is_binary(buf, got) == 0) {
/* no, it's armored */
stream->armor = 1;
ps_read_decode(stream, stream->cache, buf, got);
ps_read_decode(stream, buf, got);
}
else {
/* just put the raw stuff into the cache */
@@ -200,8 +200,7 @@ void ps_determine(Pcpstream *stream) {
}
}
size_t ps_read_decode(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsize) {
size_t zdiff = 1;
size_t ps_read_decode(Pcpstream *stream, void *buf, size_t bufsize) {
size_t i = 0;
uint8_t is_comment = 0;
uint8_t c;
@@ -247,57 +246,6 @@ size_t ps_read_decode(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsiz
return outlen;
}
size_t ps_read_decodeOLD(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsize) {
size_t zdiff = 1;
size_t i = 0;
Buffer *z = buffer_new(32, "ztemp");
if(bufsize > 0) {
/* remove newlines, comments and headers, if any */
char *z85 = pcp_readz85string(buf, bufsize);
buffer_add(z, z85, strlen(z85));
/* check if we need to read more in order to get a full block */
zdiff = stream->blocksize - strlen(z85);
i = strlen(z85);
free(z85);
}
if(zdiff > 0) {
/* read in bytewise, ignore newlines and add until the block is full */
uint8_t c;
while (i < stream->blocksize) {
if (ps_read_raw(stream, &c, 1) == 1) {
if(c != '\r' && c != '\n') {
buffer_add8(z, c);
i++;
}
}
else
break;
}
}
/* finally, decode it and put into cache */
size_t binlen, outlen;
byte *bin = pcp_z85_decode(buffer_get_str(z), &binlen);
if(bin == NULL) {
/* it's not z85 encoded, so threat it as binary */
stream->armor = 1;
buffer_add_buf(stream->cache, z);
outlen = buffer_size(stream->cache);
}
else {
/* yes, successfully decoded it, put into cache */
buffer_add(stream->cache, bin, binlen);
outlen = binlen;
}
buffer_free(z);
return outlen;
}
size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes) {
Buffer *z = buffer_new(32, "Pcpwritetemp");

View File

@@ -30,7 +30,7 @@ byte* pcp_scrypt(char *passwd, size_t passwdlen, byte *nonce, size_t noncelen) {
uint32_t p = 1;
size_t buflen = 64;
if (crypto_scrypt(passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) {
if (crypto_scrypt((byte *)passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) {
return dk;
}
else {

View File

@@ -255,7 +255,7 @@ int pcpvault_writeall(vault_t *vault) {
}
void pcpvault_update_checksum(vault_t *vault) {
byte *checksum = pcpvault_create_checksum(vault);
byte *checksum = pcpvault_create_checksum();
vault_header_t *header = ucmalloc(sizeof(vault_header_t));
header->fileid = PCP_VAULT_ID;
@@ -270,7 +270,7 @@ void pcpvault_update_checksum(vault_t *vault) {
fseek(vault->fd, 0, SEEK_END);
}
byte *pcpvault_create_checksum(vault_t *vault) {
byte *pcpvault_create_checksum() {
int numskeys = pcphash_count();
int numpkeys = pcphash_countpub();

View File

@@ -255,7 +255,7 @@ char *pcp_readz85file(FILE *infile) {
}
char *pcp_readz85string(byte *input, size_t bufsize) {
int i;
size_t i;
size_t MAXLINE = 1024;
if(bufsize == 0) {