Use standard unsigned integer types

This commit is contained in:
Andreas Steffen
2016-03-24 18:52:48 +01:00
parent b210369314
commit b12c53ce77
584 changed files with 3430 additions and 3430 deletions
+31 -31
View File
@@ -775,25 +775,25 @@ bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace)
/**
* Helper functions for chunk_mac()
*/
static inline u_int64_t sipget(u_char *in)
static inline uint64_t sipget(u_char *in)
{
u_int64_t v = 0;
uint64_t v = 0;
int i;
for (i = 0; i < 64; i += 8, ++in)
{
v |= ((u_int64_t)*in) << i;
v |= ((uint64_t)*in) << i;
}
return v;
}
static inline u_int64_t siprotate(u_int64_t v, int shift)
static inline uint64_t siprotate(uint64_t v, int shift)
{
return (v << shift) | (v >> (64 - shift));
}
static inline void sipround(u_int64_t *v0, u_int64_t *v1, u_int64_t *v2,
u_int64_t *v3)
static inline void sipround(uint64_t *v0, uint64_t *v1, uint64_t *v2,
uint64_t *v3)
{
*v0 += *v1;
*v1 = siprotate(*v1, 13);
@@ -814,8 +814,8 @@ static inline void sipround(u_int64_t *v0, u_int64_t *v1, u_int64_t *v2,
*v3 ^= *v0;
}
static inline void sipcompress(u_int64_t *v0, u_int64_t *v1, u_int64_t *v2,
u_int64_t *v3, u_int64_t m)
static inline void sipcompress(uint64_t *v0, uint64_t *v1, uint64_t *v2,
uint64_t *v3, uint64_t m)
{
*v3 ^= m;
sipround(v0, v1, v2, v3);
@@ -823,28 +823,28 @@ static inline void sipcompress(u_int64_t *v0, u_int64_t *v1, u_int64_t *v2,
*v0 ^= m;
}
static inline u_int64_t siplast(size_t len, u_char *pos)
static inline uint64_t siplast(size_t len, u_char *pos)
{
u_int64_t b;
uint64_t b;
int rem = len & 7;
b = ((u_int64_t)len) << 56;
b = ((uint64_t)len) << 56;
switch (rem)
{
case 7:
b |= ((u_int64_t)pos[6]) << 48;
b |= ((uint64_t)pos[6]) << 48;
case 6:
b |= ((u_int64_t)pos[5]) << 40;
b |= ((uint64_t)pos[5]) << 40;
case 5:
b |= ((u_int64_t)pos[4]) << 32;
b |= ((uint64_t)pos[4]) << 32;
case 4:
b |= ((u_int64_t)pos[3]) << 24;
b |= ((uint64_t)pos[3]) << 24;
case 3:
b |= ((u_int64_t)pos[2]) << 16;
b |= ((uint64_t)pos[2]) << 16;
case 2:
b |= ((u_int64_t)pos[1]) << 8;
b |= ((uint64_t)pos[1]) << 8;
case 1:
b |= ((u_int64_t)pos[0]);
b |= ((uint64_t)pos[0]);
break;
case 0:
break;
@@ -855,9 +855,9 @@ static inline u_int64_t siplast(size_t len, u_char *pos)
/**
* Caculate SipHash-2-4 with an optional first block given as argument.
*/
static u_int64_t chunk_mac_inc(chunk_t chunk, u_char *key, u_int64_t m)
static uint64_t chunk_mac_inc(chunk_t chunk, u_char *key, uint64_t m)
{
u_int64_t v0, v1, v2, v3, k0, k1;
uint64_t v0, v1, v2, v3, k0, k1;
size_t len = chunk.len;
u_char *pos = chunk.ptr, *end;
@@ -896,7 +896,7 @@ static u_int64_t chunk_mac_inc(chunk_t chunk, u_char *key, u_int64_t m)
/**
* Described in header.
*/
u_int64_t chunk_mac(chunk_t chunk, u_char *key)
uint64_t chunk_mac(chunk_t chunk, u_char *key)
{
return chunk_mac_inc(chunk, key, 0);
}
@@ -957,16 +957,16 @@ void chunk_hash_seed()
/**
* Described in header.
*/
u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
uint32_t chunk_hash_inc(chunk_t chunk, uint32_t hash)
{
/* we could use a mac of the previous hash, but this is faster */
return chunk_mac_inc(chunk, key, ((u_int64_t)hash) << 32 | hash);
return chunk_mac_inc(chunk, key, ((uint64_t)hash) << 32 | hash);
}
/**
* Described in header.
*/
u_int32_t chunk_hash(chunk_t chunk)
uint32_t chunk_hash(chunk_t chunk)
{
return chunk_mac(chunk, key);
}
@@ -974,15 +974,15 @@ u_int32_t chunk_hash(chunk_t chunk)
/**
* Described in header.
*/
u_int32_t chunk_hash_static_inc(chunk_t chunk, u_int32_t hash)
uint32_t chunk_hash_static_inc(chunk_t chunk, uint32_t hash)
{ /* we could use a mac of the previous hash, but this is faster */
return chunk_mac_inc(chunk, static_key, ((u_int64_t)hash) << 32 | hash);
return chunk_mac_inc(chunk, static_key, ((uint64_t)hash) << 32 | hash);
}
/**
* Described in header.
*/
u_int32_t chunk_hash_static(chunk_t chunk)
uint32_t chunk_hash_static(chunk_t chunk)
{
return chunk_mac(chunk, static_key);
}
@@ -990,9 +990,9 @@ u_int32_t chunk_hash_static(chunk_t chunk)
/**
* Described in header.
*/
u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum)
uint16_t chunk_internet_checksum_inc(chunk_t data, uint16_t checksum)
{
u_int32_t sum = ntohs((u_int16_t)~checksum);
uint32_t sum = ntohs((uint16_t)~checksum);
while (data.len > 1)
{
@@ -1001,7 +1001,7 @@ u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum)
}
if (data.len)
{
sum += (u_int16_t)*data.ptr << 8;
sum += (uint16_t)*data.ptr << 8;
}
while (sum >> 16)
{
@@ -1013,7 +1013,7 @@ u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum)
/**
* Described in header.
*/
u_int16_t chunk_internet_checksum(chunk_t data)
uint16_t chunk_internet_checksum(chunk_t data)
{
return chunk_internet_checksum_inc(data, 0xffff);
}
+7 -7
View File
@@ -375,7 +375,7 @@ void chunk_hash_seed();
* @param chunk data to hash
* @return hash value
*/
u_int32_t chunk_hash(chunk_t chunk);
uint32_t chunk_hash(chunk_t chunk);
/**
* Incremental version of chunk_hash. Use this to hash two or more chunks.
@@ -384,7 +384,7 @@ u_int32_t chunk_hash(chunk_t chunk);
* @param hash previous hash value
* @return hash value
*/
u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
uint32_t chunk_hash_inc(chunk_t chunk, uint32_t hash);
/**
* Computes a 32 bit hash of the given chunk.
@@ -398,7 +398,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
* @param chunk data to hash
* @return hash value
*/
u_int32_t chunk_hash_static(chunk_t chunk);
uint32_t chunk_hash_static(chunk_t chunk);
/**
* Incremental version of chunk_hash_static(). Use this to hash two or more
@@ -408,7 +408,7 @@ u_int32_t chunk_hash_static(chunk_t chunk);
* @param hash previous hash value
* @return hash value
*/
u_int32_t chunk_hash_static_inc(chunk_t chunk, u_int32_t hash);
uint32_t chunk_hash_static_inc(chunk_t chunk, uint32_t hash);
/**
* Computes a quick MAC from the given chunk and key using SipHash.
@@ -422,7 +422,7 @@ u_int32_t chunk_hash_static_inc(chunk_t chunk, u_int32_t hash);
* @param key key to use
* @return MAC for given input and key
*/
u_int64_t chunk_mac(chunk_t chunk, u_char *key);
uint64_t chunk_mac(chunk_t chunk, u_char *key);
/**
* Calculate the Internet Checksum according to RFC 1071 for the given chunk.
@@ -434,7 +434,7 @@ u_int64_t chunk_mac(chunk_t chunk, u_char *key);
* @param data data to process
* @return checksum (one's complement, network order)
*/
u_int16_t chunk_internet_checksum(chunk_t data);
uint16_t chunk_internet_checksum(chunk_t data);
/**
* Extend the given Internet Checksum (one's complement, in network byte order)
@@ -447,7 +447,7 @@ u_int16_t chunk_internet_checksum(chunk_t data);
* @param checksum previous checksum (one's complement, network order)
* @return checksum (one's complement, network order)
*/
u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum);
uint16_t chunk_internet_checksum_inc(chunk_t data, uint16_t checksum);
/**
* printf hook function for chunk_t.
+1 -1
View File
@@ -102,7 +102,7 @@ static cpu_feature_t get_via_features()
*/
cpu_feature_t cpu_feature_get_all()
{
char vendor[3 * sizeof(u_int32_t) + 1];
char vendor[3 * sizeof(uint32_t) + 1];
cpu_feature_t f = 0;
u_int a, b, c, d;
+5 -5
View File
@@ -56,10 +56,10 @@ struct private_integrity_checker_t {
int checksum_count;
};
METHOD(integrity_checker_t, build_file, u_int32_t,
METHOD(integrity_checker_t, build_file, uint32_t,
private_integrity_checker_t *this, char *file, size_t *len)
{
u_int32_t checksum;
uint32_t checksum;
chunk_t *contents;
contents = chunk_map(file, FALSE);
@@ -109,7 +109,7 @@ static int callback(struct dl_phdr_info *dlpi, size_t size, Dl_info *dli)
return 0;
}
METHOD(integrity_checker_t, build_segment, u_int32_t,
METHOD(integrity_checker_t, build_segment, uint32_t,
private_integrity_checker_t *this, void *sym, size_t *len)
{
chunk_t segment;
@@ -154,7 +154,7 @@ METHOD(integrity_checker_t, check_file, bool,
private_integrity_checker_t *this, char *name, char *file)
{
integrity_checksum_t *cs;
u_int32_t sum;
uint32_t sum;
size_t len = 0;
cs = find_checksum(this, name);
@@ -188,7 +188,7 @@ METHOD(integrity_checker_t, check_segment, bool,
private_integrity_checker_t *this, char *name, void *sym)
{
integrity_checksum_t *cs;
u_int32_t sum;
uint32_t sum;
size_t len = 0;
cs = find_checksum(this, name);
+4 -4
View File
@@ -35,11 +35,11 @@ struct integrity_checksum_t {
/* size in bytes of the file on disk */
size_t file_len;
/* checksum of the file on disk */
u_int32_t file;
uint32_t file;
/* size in bytes of executable segment in memory */
size_t segment_len;
/* checksum of the executable segment in memory */
u_int32_t segment;
uint32_t segment;
};
/**
@@ -66,7 +66,7 @@ struct integrity_checker_t {
* @param len return length in bytes of file
* @return checksum, 0 on error
*/
u_int32_t (*build_file)(integrity_checker_t *this, char *file, size_t *len);
uint32_t (*build_file)(integrity_checker_t *this, char *file, size_t *len);
/**
* Check the integrity of the code segment in memory.
@@ -83,7 +83,7 @@ struct integrity_checker_t {
* @param len return length in bytes of code segment in memory
* @return checksum, 0 on error
*/
u_int32_t (*build_segment)(integrity_checker_t *this, void *sym, size_t *len);
uint32_t (*build_segment)(integrity_checker_t *this, void *sym, size_t *len);
/**
* Check both, on disk file integrity and loaded segment.
+4 -4
View File
@@ -120,17 +120,17 @@ struct memory_header_t {
/**
* Padding to make sizeof(memory_header_t) == 32
*/
u_int32_t padding[sizeof(void*) == sizeof(u_int32_t) ? 3 : 0];
uint32_t padding[sizeof(void*) == sizeof(uint32_t) ? 3 : 0];
/**
* Number of bytes following after the header
*/
u_int32_t bytes;
uint32_t bytes;
/**
* magic bytes to detect bad free or heap underflow, MEMORY_HEADER_MAGIC
*/
u_int32_t magic;
uint32_t magic;
}__attribute__((__packed__));
@@ -142,7 +142,7 @@ struct memory_tail_t {
/**
* Magic bytes to detect heap overflow, MEMORY_TAIL_MAGIC
*/
u_int32_t magic;
uint32_t magic;
}__attribute__((__packed__));
+1 -1
View File
@@ -33,7 +33,7 @@
/* This is from the kernel sources. We limit the length of directory names to
* 256 as we only use it to enumerate FDs. */
struct linux_dirent64 {
u_int64_t d_ino;
uint64_t d_ino;
int64_t d_off;
unsigned short d_reclen;
unsigned char d_type;
+3 -3
View File
@@ -20,9 +20,9 @@
/**
* Described in header.
*/
void* malloc_align(size_t size, u_int8_t align)
void* malloc_align(size_t size, uint8_t align)
{
u_int8_t pad;
uint8_t pad;
void *ptr;
if (align == 0)
@@ -46,7 +46,7 @@ void* malloc_align(size_t size, u_int8_t align)
*/
void free_align(void *ptr)
{
u_int8_t pad, *pos;
uint8_t pad, *pos;
pos = ptr - 1;
/* verify padding to check any corruption */
+1 -1
View File
@@ -74,7 +74,7 @@ static inline size_t round_down(size_t size, size_t alignment)
* @param align alignment, up to 255 bytes, usually a power of 2
* @return allocated hunk, aligned to align bytes
*/
void* malloc_align(size_t size, u_int8_t align);
void* malloc_align(size_t size, uint8_t align);
/**
* Free a hunk allocated by malloc_align().
+13 -13
View File
@@ -26,7 +26,7 @@
* Architecture independent bitfield definition helpers (at least with GCC).
*
* Defines a bitfield with a type t and a fixed size of bitfield members, e.g.:
* BITFIELD2(u_int8_t,
* BITFIELD2(uint8_t,
* low: 4,
* high: 4,
* ) flags;
@@ -80,7 +80,7 @@
* @param host host order 16-bit value
* @param network unaligned address to write network order value to
*/
static inline void htoun16(void *network, u_int16_t host)
static inline void htoun16(void *network, uint16_t host)
{
char *unaligned = (char*)network;
@@ -94,7 +94,7 @@ static inline void htoun16(void *network, u_int16_t host)
* @param host host order 32-bit value
* @param network unaligned address to write network order value to
*/
static inline void htoun32(void *network, u_int32_t host)
static inline void htoun32(void *network, uint32_t host)
{
char *unaligned = (char*)network;
@@ -108,7 +108,7 @@ static inline void htoun32(void *network, u_int32_t host)
* @param host host order 64-bit value
* @param network unaligned address to write network order value to
*/
static inline void htoun64(void *network, u_int64_t host)
static inline void htoun64(void *network, uint64_t host)
{
char *unaligned = (char*)network;
@@ -122,10 +122,10 @@ static inline void htoun64(void *network, u_int64_t host)
* @param network unaligned address to read network order value from
* @return host order value
*/
static inline u_int16_t untoh16(void *network)
static inline uint16_t untoh16(void *network)
{
char *unaligned = (char*)network;
u_int16_t tmp;
uint16_t tmp;
memcpy(&tmp, unaligned, sizeof(tmp));
return ntohs(tmp);
@@ -137,10 +137,10 @@ static inline u_int16_t untoh16(void *network)
* @param network unaligned address to read network order value from
* @return host order value
*/
static inline u_int32_t untoh32(void *network)
static inline uint32_t untoh32(void *network)
{
char *unaligned = (char*)network;
u_int32_t tmp;
uint32_t tmp;
memcpy(&tmp, unaligned, sizeof(tmp));
return ntohl(tmp);
@@ -152,10 +152,10 @@ static inline u_int32_t untoh32(void *network)
* @param network unaligned address to read network order value from
* @return host order value
*/
static inline u_int64_t untoh64(void *network)
static inline uint64_t untoh64(void *network)
{
char *unaligned = (char*)network;
u_int64_t tmp;
uint64_t tmp;
memcpy(&tmp, unaligned, sizeof(tmp));
return be64toh(tmp);
@@ -167,9 +167,9 @@ static inline u_int64_t untoh64(void *network)
* @param p unaligned address to read little endian value from
* @return host order value
*/
static inline u_int32_t uletoh32(void *p)
static inline uint32_t uletoh32(void *p)
{
u_int32_t ret;
uint32_t ret;
memcpy(&ret, p, sizeof(ret));
ret = le32toh(ret);
@@ -182,7 +182,7 @@ static inline u_int32_t uletoh32(void *p)
* @param p host order 32-bit value
* @param v unaligned address to write little endian value to
*/
static inline void htoule32(void *p, u_int32_t v)
static inline void htoule32(void *p, uint32_t v)
{
v = htole32(v);
memcpy(p, &v, sizeof(v));
+1 -1
View File
@@ -20,7 +20,7 @@
/**
* Described in header.
*/
void memxor(u_int8_t dst[], u_int8_t src[], size_t n)
void memxor(uint8_t dst[], uint8_t src[], size_t n)
{
int m, i;
+1 -1
View File
@@ -80,7 +80,7 @@ static inline void *memset_noop(void *s, int c, size_t n)
/**
* Same as memcpy, but XORs src into dst instead of copy
*/
void memxor(u_int8_t dest[], u_int8_t src[], size_t n);
void memxor(uint8_t dest[], uint8_t src[], size_t n);
/**
* Safely overwrite n bytes of memory at ptr with zero, non-inlining variant.
+1 -1
View File
@@ -121,7 +121,7 @@ int time_delta_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
char* unit = "second";
time_t *arg1 = *((time_t**)(args[0]));
time_t *arg2 = *((time_t**)(args[1]));
u_int64_t delta = llabs(*arg1 - *arg2);
uint64_t delta = llabs(*arg1 - *arg2);
if (delta > 2 * 60 * 60 * 24)
{
+5 -5
View File
@@ -50,10 +50,10 @@
*/
#if defined __sun || defined WIN32
#include <stdint.h>
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint64_t u_int64_t;
typedef uint8_t uint8_t;
typedef uint16_t uint16_t;
typedef uint32_t uint32_t;
typedef uint64_t uint64_t;
#endif
#ifdef HAVE_INT128
@@ -70,7 +70,7 @@ typedef unsigned __int128 u_int128_t;
# define MAX_UINT_TYPE u_int128_t
#else
# define MAX_INT_TYPE int64_t
# define MAX_UINT_TYPE u_int64_t
# define MAX_UINT_TYPE uint64_t
#endif
/**