Use -pedantic, fixed all warnings

This commit is contained in:
Erik Ekman 2007-02-11 13:54:40 +00:00
parent 92a791f430
commit ad07e40988
8 changed files with 52 additions and 51 deletions

View file

@ -8,7 +8,7 @@ OS = `uname | tr "a-z" "A-Z"`
ARCH = `uname -m`
LDFLAGS = -lz
CFLAGS = -c -g -Wall -D$(OS)
CFLAGS = -c -g -Wall -D$(OS) -pedantic
all: stateos $(CLIENT) $(SERVER) $(TESTSUITE)

View file

@ -83,13 +83,13 @@ dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_
putshort(&p, q->type);
putshort(&p, C_IN);
// EDNS0
putbyte(&p, 0x00); //Root
putshort(&p, 0x0029); // OPT
putshort(&p, 0x1000); // Payload size: 4096
putshort(&p, 0x0000); // Higher bits/edns version
putshort(&p, 0x8000); // Z
putshort(&p, 0x0000); // Data length
/* EDNS0 */
putbyte(&p, 0x00); /* Root */
putshort(&p, 0x0029); /* OPT */
putshort(&p, 0x1000); /* Payload size: 4096 */
putshort(&p, 0x0000); /* Higher bits/edns version */
putshort(&p, 0x8000); /* Z */
putshort(&p, 0x0000); /* Data length */
break;
}
@ -117,7 +117,7 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
rv = 0;
header = (HEADER*)packet;
// Reject short packets
/* Reject short packets */
if (packetlen < sizeof(HEADER))
return 0;

View file

@ -18,7 +18,7 @@
#include <strings.h>
#include <string.h>
// For FreeBSD
/* For FreeBSD */
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
@ -38,29 +38,29 @@ encode_chunk(char *dest, const char *src)
{
unsigned char c;
*dest++ = base32[(*src & 0xF8) >> 3]; // 1111 1000 first byte
*dest++ = base32[(*src & 0xF8) >> 3]; /* 1111 1000 first byte */
c = (*src++ & 0x07) << 2; // 0000 0111 first byte
c |= ((*src & 0xC0) >> 6); // 1100 0000 second byte
c = (*src++ & 0x07) << 2; /* 0000 0111 first byte */
c |= ((*src & 0xC0) >> 6); /* 1100 0000 second byte */
*dest++ = base32[(int) c];
*dest++ = base32[(*src & 0x3E) >> 1]; // 0011 1110 second byte
*dest++ = base32[(*src & 0x3E) >> 1]; /* 0011 1110 second byte */
c = (*src++ & 0x01) << 4; // 0000 0001 second byte
c |= ((*src & 0xF0) >> 4); // 1111 0000 third byte
c = (*src++ & 0x01) << 4; /* 0000 0001 second byte */
c |= ((*src & 0xF0) >> 4); /* 1111 0000 third byte */
*dest++ = base32[(int) c];
c = (*src++ & 0x0F) << 1; // 0000 1111 third byte
c |= ((*src & 0x80) >> 7); // 1000 0000 fourth byte
c = (*src++ & 0x0F) << 1; /* 0000 1111 third byte */
c |= ((*src & 0x80) >> 7); /* 1000 0000 fourth byte */
*dest++ = base32[(int) c];
*dest++ = base32[(*src & 0x7C) >> 2]; // 0111 1100 fourth byte
*dest++ = base32[(*src & 0x7C) >> 2]; /* 0111 1100 fourth byte */
c = (*src++ & 0x03) << 3; // 0000 0011 fourth byte
c |= ((*src & 0xE0) >> 5); // 1110 0000 fifth byte
c = (*src++ & 0x03) << 3; /* 0000 0011 fourth byte */
c |= ((*src & 0xE0) >> 5); /* 1110 0000 fifth byte */
*dest++ = base32[(int) c];
*dest++ = base32[*src++ & 0x1F]; // 0001 1111 fifth byte
*dest++ = base32[*src++ & 0x1F]; /* 0001 1111 fifth byte */
}
/* Eat 8 bytes from src, write 5 bytes to dest */
@ -78,26 +78,26 @@ decode_chunk(char *dest, char *src)
reverse_init = 1;
}
c = reverse32[(int) *src++] << 3; // Take bits 11111 from byte 1
c |= (reverse32[(int) *src] & 0x1C) >> 2; // Take bits 11100 from byte 2
c = reverse32[(int) *src++] << 3; /* Take bits 11111 from byte 1 */
c |= (reverse32[(int) *src] & 0x1C) >> 2; /* Take bits 11100 from byte 2 */
*dest++ = c;
c = (reverse32[(int) *src++] & 0x3) << 6; // Take bits 00011 from byte 2
c |= reverse32[(int) *src++] << 1; // Take bits 11111 from byte 3
c |= (reverse32[(int) *src] & 0x10) >> 4; // Take bits 10000 from byte 4
c = (reverse32[(int) *src++] & 0x3) << 6; /* Take bits 00011 from byte 2 */
c |= reverse32[(int) *src++] << 1; /* Take bits 11111 from byte 3 */
c |= (reverse32[(int) *src] & 0x10) >> 4; /* Take bits 10000 from byte 4 */
*dest++ = c;
c = (reverse32[(int) *src++] & 0xF) << 4; // Take bits 01111 from byte 4
c |= (reverse32[(int) *src] & 0x1E) >> 1; // Take bits 11110 from byte 5
c = (reverse32[(int) *src++] & 0xF) << 4; /* Take bits 01111 from byte 4 */
c |= (reverse32[(int) *src] & 0x1E) >> 1; /* Take bits 11110 from byte 5 */
*dest++ = c;
c = reverse32[(int) *src++] << 7; // Take bits 00001 from byte 5
c |= reverse32[(int) *src++] << 2; // Take bits 11111 from byte 6
c |= (reverse32[(int) *src] & 0x18) >> 3; // Take bits 11000 from byte 7
c = reverse32[(int) *src++] << 7; /* Take bits 00001 from byte 5 */
c |= reverse32[(int) *src++] << 2; /* Take bits 11111 from byte 6 */
c |= (reverse32[(int) *src] & 0x18) >> 3; /* Take bits 11000 from byte 7 */
*dest++ = c;
c = (reverse32[(int) *src++] & 0x7) << 5; // Take bits 00111 from byte 7
c |= reverse32[(int) *src++]; // Take bits 11111 from byte 8
c = (reverse32[(int) *src++] & 0x7) << 5; /* Take bits 00111 from byte 7 */
c |= reverse32[(int) *src++]; /* Take bits 11111 from byte 8 */
*dest++ = c;
}
@ -122,8 +122,8 @@ encode_data(const char *buf, const size_t len, int space, char *dest)
chunks--;
}
write = RAW_CHUNK * chunks;
write = MIN(write, len); // do not use more bytes than is available;
final = (write == len); // is this the last block?
write = MIN(write, len); /* do not use more bytes than is available; */
final = (write == len); /* is this the last block? */
chunks = write / RAW_CHUNK;
leftovers = write % RAW_CHUNK;
@ -146,7 +146,7 @@ encode_data(const char *buf, const size_t len, int space, char *dest)
*ep++ = padder[leftovers];
encode_chunk(ep, pp);
realwrite += ENC_CHUNK + 1; // plus padding character
realwrite += ENC_CHUNK + 1; /* plus padding character */
}
ep = encoded;
if (len > 0) {
@ -202,7 +202,7 @@ decode_data(char *dest, int size, const char *src, char *srcend)
ep += ENC_CHUNK;
len += RAW_CHUNK;
}
// Read last chunk:
/* Read last chunk */
if (padded) {
pp = padding;
padded = *ep++ - '0';

View file

@ -427,8 +427,9 @@ set_target(const char *host)
{
struct hostent *h;
if ((h = gethostbyname(host)) <= 0)
err(1, "couldn't resovle name %s", host);
h = gethostbyname(host);
if (!h)
err(1, "couldn't resolve name %s", host);
memset(&peer, 0, sizeof(peer));
peer.sin_family = AF_INET;

View file

@ -42,10 +42,10 @@ readname_loop(char *packet, int packetlen, char **src, char *dst, size_t length,
offset = (((s[-1] & 0x3f) << 8) | (s[0] & 0xff));
if (offset > packetlen) {
if (len == 0) {
// Bad jump first in packet
/* Bad jump first in packet */
return 0;
} else {
// Bad jump after some data
/* Bad jump after some data */
break;
}
}
@ -98,7 +98,7 @@ readshort(char *packet, char **src, short *dst)
int
readlong(char *packet, char **src, uint32_t *dst)
{
// A long as described in dns protocol is always 32 bits
/* A long as described in dns protocol is always 32 bits */
unsigned char *p;
p = (unsigned char *) *src;
@ -161,7 +161,7 @@ putname(char **buf, size_t buflen, const char *host)
}
int
putbyte(char **dst, char value)
putbyte(char **dst, unsigned char value)
{
**dst = value;
(*dst)++;
@ -170,7 +170,7 @@ putbyte(char **dst, char value)
}
int
putshort(char **dst, short value)
putshort(char **dst, unsigned short value)
{
unsigned char *p;
@ -186,7 +186,7 @@ putshort(char **dst, short value)
int
putlong(char **dst, uint32_t value)
{
// A long as described in dns protocol is always 32 bits
/* A long as described in dns protocol is always 32 bits */
unsigned char *p;
p = (unsigned char *) *dst;

View file

@ -23,8 +23,8 @@ int readlong(char *, char **, uint32_t *);
int readdata(char *, char **, char *, size_t);
int putname(char **, size_t, const char *);
int putbyte(char **, char);
int putshort(char **, short);
int putbyte(char **, unsigned char);
int putshort(char **, unsigned short);
int putlong(char **, uint32_t);
int putdata(char **, char *, size_t);

View file

@ -170,7 +170,7 @@ int
read_tun(int tun_fd, char *buf, int len)
{
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD)
// FreeBSD has no header
/* FreeBSD/Darwin/NetBSD has no header */
return read(tun_fd, buf + 4, len - 4) + 4;
#else /* !FREEBSD */
return read(tun_fd, buf, len);

View file

@ -17,8 +17,8 @@
#ifndef _VERSION_H_
#define _VERSION_H_
// This is the version of the network protocol
// It is usually equal to the latest iodine version number
/* This is the version of the network protocol
It is usually equal to the latest iodine version number */
#define VERSION 0x00000400
#endif /* _VERSION_H_ */