summaryrefslogtreecommitdiff
path: root/mcastseed/src
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-07-17 14:18:59 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-07-17 14:18:59 +0200
commita430fa470e4b7dd06fb92a0c32d09d9e00bdc827 (patch)
tree36e0f163a593ccb517d34111be425dec25ec2da4 /mcastseed/src
parent1dc0b45923fd9c487dbe5bcb2264e821fe676e73 (diff)
downloadeficast-a430fa470e4b7dd06fb92a0c32d09d9e00bdc827.tar.gz
eficast-a430fa470e4b7dd06fb92a0c32d09d9e00bdc827.tar.bz2
eficast-a430fa470e4b7dd06fb92a0c32d09d9e00bdc827.zip
Bugfix for EOF + pedantic-aware comments
Diffstat (limited to 'mcastseed/src')
-rw-r--r--mcastseed/src/random_speed_dd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/mcastseed/src/random_speed_dd.c b/mcastseed/src/random_speed_dd.c
index 0c11c05..1fbc863 100644
--- a/mcastseed/src/random_speed_dd.c
+++ b/mcastseed/src/random_speed_dd.c
@@ -6,11 +6,11 @@
char buf[0xffff];
int main() {
- size_t nread, nwrite, remains;
+ ssize_t nread, nwrite, remains;
- srandom(1); // Always the same pseudo-random sequence
+ srandom(1); /* Always the same pseudo-random sequence */
- while ( (nread=read(0, buf, 0xf & rand())) >= 0 ) {
+ while ( (nread=read(0, buf, 0xfff & rand())) > 0 ) {
remains = nread;
while ( remains ) {
nwrite=write(1, buf, nread);
@@ -23,8 +23,12 @@ int main() {
remains -= nwrite;
}
}
- //fprintf(stderr, "nread==%zi, nwrite==%zi\n", nread, nwrite);
- usleep( 0xfffff & rand() );
+ /*fprintf(stderr, "nread==%zu, nwrite==%zu\n", nread, nwrite);*/
+ usleep( 0xffff & rand() );
+ }
+ if ( nread < 0 ) {
+ perror("read");
+ return nread;
}
return 0;