Bugzilla – Bug 336
optimized build doesn't compile on Ubuntu 8.10
Last modified: 2008-09-11 12:54:48 UTC
In ns-3-dev AND the RC2 tarball. Platform: x86 Ubuntu 8.10 (Intrepid Ibex) alpha 5, gcc4.3.2 Configured as: ./waf configure --enable-nsc -d optimized Warning generated: [223/539] cxx: src/core/random-variable.cc -> build/optimized/src/core/random-variable_1.o cc1plus: warnings being treated as errors ../src/core/random-variable.cc: In static member function ‘static void ns3::RandomVariableBase::GetRandomSeeds(uint32_t*)’: ../src/core/random-variable.cc:199: error: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result I think this can be fixed by using something other than the low level read call.
The optimized build does work on ns-regression and OSX Intel.
(In reply to comment #0) > In ns-3-dev AND the RC2 tarball. > > Platform: x86 Ubuntu 8.10 (Intrepid Ibex) alpha 5, gcc4.3.2 > > Configured as: > ./waf configure --enable-nsc -d optimized > > Warning generated: > [223/539] cxx: src/core/random-variable.cc -> > build/optimized/src/core/random-variable_1.o > cc1plus: warnings being treated as errors > ../src/core/random-variable.cc: In static member function ‘static void > ns3::RandomVariableBase::GetRandomSeeds(uint32_t*)’: > ../src/core/random-variable.cc:199: error: ignoring return value of ‘ssize_t > read(int, void*, size_t)’, declared with attribute warn_unused_result > > I think this can be fixed by using something other than the low level read > call. An even easier way to fix this warning would be to actually check that you have read what you expected.
changeset: 3678:3a4021da265d
Nope, in opt builds, NS_ASSERT is replaced with whitespace, so: [223/539] cxx: src/core/random-variable.cc -> build/optimized/src/core/random-variable_1.o cc1plus: warnings being treated as errors ../src/core/random-variable.cc: In static member function ‘static void ns3::RandomVariableBase::GetRandomSeeds(uint32_t*)’: ../src/core/random-variable.cc:199: error: unused variable ‘bytes_read’
One solution is to conditionally FATAL_ERROR out if somehow the read from /dev/random fails. diff -r 3a4021da265d src/core/random-variable.cc --- a/src/core/random-variable.cc Thu Sep 11 15:21:19 2008 +0100 +++ b/src/core/random-variable.cc Thu Sep 11 10:41:46 2008 -0400 @@ -198,7 +198,10 @@ { ssize_t bytes_read = read (RandomVariableBase::devRandom, &seeds[i], sizeof (seeds[i])); - NS_ASSERT (bytes_read == sizeof (seeds[i])); + if (bytes_read != sizeof (seeds[i])) + { + NS_FATAL_ERROR ("Read from /dev/random failed"); + } } if (RngStream::CheckSeed(seeds)) break; // Got a valid one }
(In reply to comment #5) > One solution is to conditionally FATAL_ERROR out if somehow the read from > /dev/random fails. > > diff -r 3a4021da265d src/core/random-variable.cc > --- a/src/core/random-variable.cc Thu Sep 11 15:21:19 2008 +0100 > +++ b/src/core/random-variable.cc Thu Sep 11 10:41:46 2008 -0400 > @@ -198,7 +198,10 @@ > { > ssize_t bytes_read = read (RandomVariableBase::devRandom, > &seeds[i], sizeof (seeds[i])); > - NS_ASSERT (bytes_read == sizeof (seeds[i])); > + if (bytes_read != sizeof (seeds[i])) > + { > + NS_FATAL_ERROR ("Read from /dev/random failed"); > + } > } > if (RngStream::CheckSeed(seeds)) break; // Got a valid one > } Pushed this. changeset 07fdb67e52bb