Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/xprobe: Fix build with Clang 16 and remove the workaround
random_shuffle has bee deprecated in C++14 and removed since C++17. Use shuffle instead. target.cc:373:3: error: use of undeclared identifier 'random_shuffle' random_shuffle(ports.begin(), ports.end()); ^ 5 warnings and 1 error generated. Tested on: 14.0-CURRENT (1400093)
- Loading branch information
Showing
2 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- src/target.cc.orig 2005-07-27 08:38:17 UTC | ||
+++ src/target.cc | ||
@@ -28,6 +28,8 @@ | ||
#include "os_matrix.h" | ||
#include "xplib/xplib.h" | ||
#include "log.h" | ||
+#include <algorithm> | ||
+#include <random> | ||
|
||
extern Interface *ui; | ||
extern Xprobe_Module_Hdlr *xmh; | ||
@@ -363,6 +365,8 @@ void Port_Range::set_range(u_short a, u_short b) { | ||
|
||
int Port_Range::get_next(u_short *port) { | ||
int k, sz=size(); | ||
+ std::random_device rd; | ||
+ std::mt19937 g(rd()); | ||
|
||
if (curr+low > high) | ||
return 1; | ||
@@ -370,7 +373,7 @@ int Port_Range::get_next(u_short *port) { | ||
// initialize | ||
for (k=0; k < sz; k++) | ||
ports.push_back(low + k); | ||
- random_shuffle(ports.begin(), ports.end()); | ||
+ std::shuffle(ports.begin(), ports.end(), g); | ||
*port = ports[curr++]; | ||
} else | ||
*port = ports[curr++]; |