[Lldb-commits] [lldb] r128493 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Stephen Wilson wilsons at start.ca
Tue Mar 29 16:20:06 PDT 2011


Hi Jim.

On Tue, Mar 29, 2011 at 09:45:47PM -0000, Jim Ingham wrote:
>  get_random_port ()
>  {
> +    if (!rand_initialized)
> +    {
> +        rand_initialized = true;
> +        sranddev();
> +    }
>      return (rand() % (UINT16_MAX - 1000u)) + 1000u;
>  }
>  

Would something like the following address the issue (applied atop your patch)?
IIRC sranddev() is mostly a BSD'ism, whereas the following should be OK
in any standard C environment.



diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index b434853..987f246 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 
 // C++ Includes
 #include <algorithm>
@@ -61,8 +62,10 @@ get_random_port ()
 {
     if (!rand_initialized)
     {
+        time_t seed = time(NULL);
+
         rand_initialized = true;
-        sranddev();
+        srand(seed);
     }
     return (rand() % (UINT16_MAX - 1000u)) + 1000u;
 }





More information about the lldb-commits mailing list