Skip to content

Commit a977d8d

Browse files
committed
vs warnings
1 parent 91605e1 commit a977d8d

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

include/maxplus/algebra/mpmatrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ inline unsigned int VectorList::getSize() const { return static_cast<unsigned in
320320

321321
inline void VectorList::grow() {
322322
auto last = static_cast<unsigned int>(this->size());
323-
this->resize(last + 1);
323+
this->resize(static_cast<size_t>(last + 1));
324324
this->insert(this->begin() + last, std::make_unique<Vector>(oneVectorSize, MP_MINUSINFINITY));
325325
}
326326

src/base/analysis/mcm/mcmdg.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ CDouble mcmDG(MCMgraph *mcmGraph) {
6262
std::vector<std::vector<int>> d(n + 1, std::vector<int>(n));
6363

6464
// Initialize
65-
for (int i = 0; i < n; i++) {
65+
for (unsigned int i = 0; i < n; i++) {
6666
level[i] = -1;
6767
}
6868
d[0][0] = 0;
@@ -74,7 +74,7 @@ CDouble mcmDG(MCMgraph *mcmGraph) {
7474
Q_u.push_back(&(mcmGraph->getNodes().front()));
7575

7676
// Compute the distances
77-
int k = Q_k.front();
77+
unsigned int k = Q_k.front();
7878
Q_k.pop_front();
7979
MCMnode* u = Q_u.front();
8080
Q_u.pop_front();
@@ -83,7 +83,7 @@ CDouble mcmDG(MCMgraph *mcmGraph) {
8383
MCMedge* e = *iter;
8484
MCMnode* v = e->dst;
8585

86-
if (level[v->id] < k + 1) {
86+
if (level[v->id] < static_cast<int>(k + 1)) {
8787
Q_k.push_back(k + 1);
8888
Q_u.push_back(v);
8989
pi[k + 1][v->id] = level[v->id];

src/base/analysis/mcm/mcmgraph.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ MCMnode::MCMnode(CId nId, bool nVisible) : id(nId), visible(nVisible) {}
105105
*/
106106
static void splitMCMedgeToSequence(MCMgraph &g, MCMedge &e) {
107107
// Create dummy node n;
108-
MCMnode *n = g.addNode(g.getNodes().size());
108+
MCMnode *n = g.addNode(static_cast<CId>(g.getNodes().size()));
109109

110110
// Create a new edge between the src node of e and a new
111111
// dummy node.
112-
MCMedge *eN = g.addEdge(g.getEdges().size(), *e.src, *n, 0, e.d - 1);
112+
MCMedge *eN = g.addEdge(static_cast<CId>(g.getEdges().size()), *e.src, *n, 0, e.d - 1);
113113

114114
// Remove e from the set of edges its source node is connected to
115115
// and add eN to this list
@@ -226,7 +226,7 @@ static void addLongestDelayEdgeForNode(MCMgraph &g, MCMnode &n, MCMedge &e) {
226226
if (d[m->id] > 0 && e.dst->id != m->id) {
227227
// Create an edge between n and m
228228
MCMedge *eN = g.addEdge(
229-
g.getEdges().size(), n, *m, d[m->id], e.d, false); // e.d should always be 1
229+
static_cast<CId>(g.getEdges().size()), n, *m, d[m->id], e.d, false); // e.d should always be 1
230230
n.out.push_back(eN);
231231
m->in.push_back(eN);
232232
}
@@ -435,7 +435,7 @@ static void addNodeToComponent(const MCMnode &n, MCMgraph &comp) {
435435
// in the previous loop already
436436
for (const auto &e : n.in) {
437437
// Is source node in the component?
438-
for (auto iterN : comp.getNodes()) {
438+
for (auto& iterN : comp.getNodes()) {
439439
// if the source node is in the component and it is not a self-edge
440440
if ((e->src->id == iterN.id) && (e->src->id != e->dst->id)) {
441441
// Add a copy of the edge to the component

src/base/analysis/mcm/mcmhoward.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class AlgHoward {
187187
v_aux[i] = EPSILON;
188188
}
189189

190-
for (unsigned int i = 0; i < narcs; i++) {
190+
for (int i = 0; i < narcs; i++) {
191191
if (v_aux[ij[i * 2]] <= a[i]) {
192192
(**pi)[ij[i * 2]] = ij[i * 2 + 1];
193193
c[ij[i * 2]] = a[i];

src/base/analysis/mcm/mcmkarp.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ CDouble maximumCycleMeanKarp(MCMgraph &mcmGraph) {
7373

7474
// Initialize
7575
// d[k][u], 1<=k<n+1, 0<=u<n with value -inf
76-
for (int k = 1; k < n + 1; k++) {
77-
for (int u = 0; u < n; u++) {
76+
for (unsigned int k = 1; k < n + 1; k++) {
77+
for (unsigned int u = 0; u < n; u++) {
7878
d[k][u] = -INT_MAX;
7979
}
8080
}
8181
// d[0][u], 0<=u<n with value 0
82-
for (int u = 0; u < n; u++) {
82+
for (unsigned int u = 0; u < n; u++) {
8383
d[0][u] = 0;
8484
}
8585

8686
// Compute the distances
87-
for (int k = 1; k < n + 1; k++) {
87+
for (unsigned int k = 1; k < n + 1; k++) {
8888
for (const auto& v : mcmGraph.getNodes()) {
8989
for (auto e = v.in.begin(); e != v.in.end(); e++) {
9090
MCMnode* u = (*e)->src;
@@ -97,7 +97,7 @@ CDouble maximumCycleMeanKarp(MCMgraph &mcmGraph) {
9797
CDouble l = -INT_MAX;
9898
for (const auto & u : mcmGraph.getNodes()) {
9999
CDouble ld = INT_MAX;
100-
for (int k = 0; k < n; k++) {
100+
for (unsigned int k = 0; k < n; k++) {
101101
ld = MIN(ld, (CDouble)(d[n][u.id] - d[k][u.id]) / (CDouble)(n - k));
102102
}
103103
l = MAX(l, ld);
@@ -125,18 +125,18 @@ CDouble maximumCycleMeanKarpDouble(MCMgraph &mcmGraph, const MCMnode **criticalN
125125

126126
// Initialize
127127
// d[k][u], 1<=k<n+1, 0<=u<n with value -inf
128-
for (int k = 1; k < n + 1; k++) {
129-
for (int u = 0; u < n; u++) {
128+
for (unsigned int k = 1; k < n + 1; k++) {
129+
for (unsigned int u = 0; u < n; u++) {
130130
d[k][u] = -DBL_MAX;
131131
}
132132
}
133133
// d[0][u], 0<=u<n with value 0
134-
for (int u = 0; u < n; u++) {
134+
for (unsigned int u = 0; u < n; u++) {
135135
d[0][u] = 0.0;
136136
}
137137

138138
// Compute the distances
139-
for (int k = 1; k < n + 1; k++) {
139+
for (unsigned int k = 1; k < n + 1; k++) {
140140
for (const auto& v : mcmGraph.getNodes()) {
141141
for (auto e = v.in.begin(); e != v.in.end(); e++) {
142142
MCMnode* u = (*e)->src;
@@ -149,7 +149,7 @@ CDouble maximumCycleMeanKarpDouble(MCMgraph &mcmGraph, const MCMnode **criticalN
149149
CDouble l = -DBL_MAX;
150150
for (const auto& u : mcmGraph.getNodes()) {
151151
CDouble ld = DBL_MAX;
152-
for (int k = 0; k < n; k++) {
152+
for (unsigned int k = 0; k < n; k++) {
153153
CDouble nld = (d[n][u.id] - d[k][u.id]) / static_cast<CDouble>(n - k);
154154
if (nld < ld) {
155155
ld = nld;

src/base/string/cstring.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ CString::CString(const CString &s) = default;
8181
*/
8282
CString::CString(const int n) {
8383
char str[32];
84-
sprintf(&str[0], "%i", n);
84+
sprintf_s(&str[0], 32, "%i", n);
8585
append(std::string(str));
8686
}
8787

@@ -91,7 +91,7 @@ CString::CString(const int n) {
9191
*/
9292
CString::CString(const unsigned int n) {
9393
char str[32];
94-
sprintf(&str[0], "%u", n);
94+
sprintf_s(&str[0], 32, "%u", n);
9595
append(std::string(str));
9696
}
9797

@@ -101,7 +101,7 @@ CString::CString(const unsigned int n) {
101101
*/
102102
CString::CString(const long int n) {
103103
char str[32];
104-
sprintf(&str[0], "%ld", n);
104+
sprintf_s(&str[0], 32, "%ld", n);
105105
append(std::string(str));
106106
}
107107

@@ -111,7 +111,7 @@ CString::CString(const long int n) {
111111
*/
112112
CString::CString(const unsigned long int n) {
113113
char str[32];
114-
sprintf(&str[0], "%ld", n);
114+
sprintf_s(&str[0], 32, "%ld", n);
115115
append(std::string(str));
116116
}
117117

@@ -121,7 +121,7 @@ CString::CString(const unsigned long int n) {
121121
*/
122122
CString::CString(const long long int n) {
123123
char str[32];
124-
sprintf(&str[0], "%lld", n);
124+
sprintf_s(&str[0], 32, "%lld", n);
125125
append(std::string(str));
126126
}
127127

@@ -131,7 +131,7 @@ CString::CString(const long long int n) {
131131
*/
132132
CString::CString(const unsigned long long int n) {
133133
char str[32];
134-
sprintf(&str[0], "%lld", n);
134+
sprintf_s(&str[0], 32, "%lld", n);
135135
append(std::string(str));
136136
}
137137

@@ -141,7 +141,7 @@ CString::CString(const unsigned long long int n) {
141141
*/
142142
CString::CString(const CDouble n) {
143143
char str[32];
144-
sprintf(&str[0], "%g", n);
144+
sprintf_s(&str[0], 32, "%g", n);
145145
append(std::string(str));
146146
}
147147

@@ -447,8 +447,8 @@ bool isTok(const char c, const char *tok) { return (strchr(tok, c) != nullptr);
447447
* Split a string into tokens using the given token delimiter.
448448
*/
449449
void stringTok(CStrings &l, CString &str, const char *tok) {
450-
const CString::size_type S = str.size();
451-
CString::size_type i = 0;
450+
const int S = static_cast<int>(str.size());
451+
int i = 0;
452452

453453
// Clear list of strings
454454
l.clear();
@@ -464,7 +464,7 @@ void stringTok(CStrings &l, CString &str, const char *tok) {
464464
}
465465

466466
// find end of word
467-
CString::size_type j = i + 1;
467+
int j = i + 1;
468468
while ((j < S) && (!isTok(str[j], tok))) {
469469
++j;
470470
}

src/testbench/game/policyiterationtest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void PolicyIterationTest::testInvalidInputGraphTest() {
184184
new PolicyIteration<MPAStateLabel, MPAREdgeLabel>();
185185
PolicyIteration<MPAStateLabel, MPAREdgeLabel>::PolicyIterationResult result =
186186
pi->solve(mpa);
187-
} catch (const std::runtime_error &error) {
187+
} catch (const std::runtime_error&) {
188188
// test passes
189189
// SUCCEED();
190190
}

0 commit comments

Comments
 (0)