[vlc-commits] [Git][videolan/vlc][master] 2 commits: src: test: shared_data_ptr: mask assignment
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Nov 23 19:01:15 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
e226ce31 by Alexandre Janniaux at 2022-11-23T18:49:13+00:00
src: test: shared_data_ptr: mask assignment
Fix the following warning:
WARNING : ./src/test/shared_data_ptr.cpp:81: 9: explicitly
assigning value of variable of type 'MockRcPtr' (aka
'vlc_shared_data_ptr<mockrc, void (*)(mockrc *), void (*)(mockrc *),
&mockrc_Hold, &mockrc_Release>') to itself
[-Wself-assign-overloaded]
ptr = ptr; /* self-assignement should have no effect */
~~~ ^ ~~~
- - - - -
d430a323 by Alexandre Janniaux at 2022-11-23T18:49:13+00:00
src: test: shared_data_ptr: replace random_shuffle
std::random_shuffle has been deprecated and removed later in favour of
std::shuffle, which require a random number generator parameter, to
address security issues because of std::rand. We can replace it right
away since std::shuffle is supported starting with C++11.
Fixes the following warning:
WARNING :
./src/test/shared_data_ptr.cpp:119: 14:
'random_shuffle<std::__wrap_iter<vlc::vlc_shared_data_ptr<mockrc,
void (*)(mockrc *), void (*)(mockrc *), &mockrc_Hold,
&mockrc_Release> *>>' is deprecated [-Wdeprecated-declarations]
- - - - -
1 changed file:
- src/test/shared_data_ptr.cpp
Changes:
=====================================
src/test/shared_data_ptr.cpp
=====================================
@@ -1,5 +1,6 @@
#include <assert.h>
#include <algorithm>
+#include <random>
#include <vector>
#include <vlc_cxx_helpers.hpp>
@@ -78,7 +79,8 @@ static void test_assignment()
/* ptr2 had been moved, no decrement */
assert(mock.count == 1);
- ptr = ptr; /* self-assignement should have no effect */
+ auto &ptr2 = ptr;
+ ptr = ptr2; /* self-assignement should have no effect */
assert(mock.count == 1);
}
@@ -116,7 +118,10 @@ static void test_vector()
std::vector<MockRcPtr> vec(10, MockRcPtr(&mock, false));
assert(mock.count == 10);
- std::random_shuffle(vec.begin(), vec.end());
+ std::random_device rd;
+ std::mt19937 g(rd());
+
+ std::shuffle(vec.begin(), vec.end(), g);
assert(mock.count == 10);
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9d25f27f52879b401a4a62376e83274561aacb13...d430a32330fc822d85f07bb5a99191e6b4c00ebe
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9d25f27f52879b401a4a62376e83274561aacb13...d430a32330fc822d85f07bb5a99191e6b4c00ebe
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list