ports/net/xprobe/files/patch-src-target.cc
Po-Chuan Hsieh 29873d969e
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)
2023-08-22 01:03:00 +08:00

29 lines
769 B
C++

--- 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++];