Commit b618a231 authored by Pekka Pessi's avatar Pekka Pessi

tport, sresolv, su: fixed warnings from read()/fread()/fwrite().

darcs-hash:20061207085355-65a35-40859edbfb092bc1f8d7766111f3b7bd33bdb9fb.gz
parent 1528132b
...@@ -714,7 +714,7 @@ sres_resolver_new_internal(sres_cache_t *cache, ...@@ -714,7 +714,7 @@ sres_resolver_new_internal(sres_cache_t *cache,
#if HAVE_DEV_URANDOM #if HAVE_DEV_URANDOM
int fd; int fd;
if ((fd = open("/dev/urandom", O_RDONLY, 0)) != -1) { if ((fd = open("/dev/urandom", O_RDONLY, 0)) != -1) {
read(fd, &res->res_id, (sizeof res->res_id)); size_t len = read(fd, &res->res_id, (sizeof res->res_id)); (void)len;
close(fd); close(fd);
} }
else else
......
...@@ -148,7 +148,7 @@ static void init(void) ...@@ -148,7 +148,7 @@ static void init(void)
#endif /* HAVE_DEV_URANDOM */ #endif /* HAVE_DEV_URANDOM */
if (urandom) { if (urandom) {
fread(seed, sizeof seed, 1, urandom); size_t len = fread(seed, sizeof seed, 1, urandom); (void)len;
} }
else { else {
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
...@@ -225,7 +225,7 @@ void init_node(void) ...@@ -225,7 +225,7 @@ void init_node(void)
#endif #endif
if (urandom) { if (urandom) {
fread(node, sizeof node, 1, urandom); size_t len = fread(node, sizeof node, 1, urandom); (void)len;
} }
else for (i = 0; i < sizeof(node); i++) { else for (i = 0; i < sizeof(node); i++) {
unsigned r = random(); unsigned r = random();
...@@ -294,7 +294,7 @@ int su_randint(int lb, int ub) ...@@ -294,7 +294,7 @@ int su_randint(int lb, int ub)
if (!initialized) init(); if (!initialized) init();
if (urandom) { if (urandom) {
fread(&rnd, 1, sizeof rnd, urandom); size_t len = fread(&rnd, 1, sizeof rnd, urandom); (void)len;
} }
else else
rnd = random(); rnd = random();
...@@ -312,7 +312,7 @@ void *su_randmem(void *mem, size_t siz) ...@@ -312,7 +312,7 @@ void *su_randmem(void *mem, size_t siz)
if (!initialized) init(); if (!initialized) init();
if (urandom) { if (urandom) {
fread(mem, 1, siz, urandom); size_t len = fread(mem, 1, siz, urandom); (void)len;
} }
else for (i = 0; i < siz; i++) { else for (i = 0; i < siz; i++) {
unsigned r = random(); unsigned r = random();
...@@ -329,14 +329,13 @@ void *su_randmem(void *mem, size_t siz) ...@@ -329,14 +329,13 @@ void *su_randmem(void *mem, size_t siz)
*/ */
uint32_t su_random(void) uint32_t su_random(void)
{ {
uint32_t rnd;
if (!initialized) init(); if (!initialized) init();
if (urandom) if (urandom) {
fread(&rnd, 1, sizeof rnd, urandom); uint32_t rnd;
else size_t len = fread(&rnd, 1, sizeof rnd, urandom); (void)len;
rnd = (uint32_t)random(); return rnd;
}
return rnd; return (uint32_t)random();
} }
...@@ -166,7 +166,8 @@ void tport_dump_iovec(tport_t const *self, msg_t *msg, ...@@ -166,7 +166,8 @@ void tport_dump_iovec(tport_t const *self, msg_t *msg,
size_t len = iov[i].mv_len; size_t len = iov[i].mv_len;
if (len > n) if (len > n)
len = n; len = n;
fwrite(iov[i].mv_base, len, 1, mr->mr_dump_file); if (fwrite(iov[i].mv_base, len, 1, mr->mr_dump_file) != len)
break;
n -= len; n -= len;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment