Bug 336 - optimized build doesn't compile on Ubuntu 8.10
optimized build doesn't compile on Ubuntu 8.10
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3.2
All All
: P1 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-10 17:56 UTC by Rajib Bhattacharjea
Modified: 2008-09-11 12:54 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rajib Bhattacharjea 2008-09-10 17:56:21 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.
Comment 1 Craig Dowell 2008-09-10 20:18:18 UTC
The optimized build does work on ns-regression and OSX Intel.
Comment 2 Mathieu Lacage 2008-09-10 23:06:31 UTC
(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.

Comment 3 Gustavo J. A. M. Carneiro 2008-09-11 10:21:59 UTC
changeset:   3678:3a4021da265d
Comment 4 Rajib Bhattacharjea 2008-09-11 10:38:26 UTC
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’
Comment 5 Rajib Bhattacharjea 2008-09-11 10:42:28 UTC
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
         }
Comment 6 Mathieu Lacage 2008-09-11 12:54:38 UTC
(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