Skip to content

Commit 7aa9be1

Browse files
Fix constexpr warnings and constant std::move warnings C26478 C26497.
1 parent d0e7f8c commit 7aa9be1

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/ServerErrorHandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ServerErrorHandler : public REQUEST_HANDLER
1515
m_disableStartupPage(disableStartupPage),
1616
m_statusCode(statusCode),
1717
m_subStatusCode(subStatusCode),
18-
m_statusText(std::move(statusText)),
18+
m_statusText(statusText),
1919
m_ExceptionInfoContent(responseContent)
2020
{
2121
}

src/Servers/IIS/AspNetCoreModuleV2/DefaultRules.ruleset

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<Rule Id="C26475" Action="Error" />
8181
<Rule Id="C26476" Action="None" /> <!-- Expression/symbol 'name' uses a naked union 'union' with multiple type pointers: Use variant instead -->
8282
<Rule Id="C26477" Action="Error" />
83-
<Rule Id="C26478" Action="None" /> <!-- Don't use std::move on constant variables. -->
8483
<Rule Id="C26481" Action="None" /> <!-- Don't use pointer arithmetic. Use span instead -->
8584
<Rule Id="C26482" Action="None" /> <!-- Only index into arrays using constant expressions. -->
8685
<Rule Id="C26483" Action="Error" />
@@ -95,7 +94,7 @@
9594
<Rule Id="C26494" Action="None" /> <!-- Variable 'variable' is uninitialized. Always initialize an object. -->
9695
<Rule Id="C26495" Action="None" /> <!-- Variable 'variable' is uninitialized. Always initialize a member variable -->
9796
<Rule Id="C26496" Action="None" /> <!-- The variable 'variable' is assigned only once, mark it as const. -->
98-
<Rule Id="C26497" Action="None" /> <!-- Attempt to make this constexpr -->
97+
<Rule Id="C26497" Action="Error" />
9998
<Rule Id="C26498" Action="Error" />
10099
<Rule Id="C26814" Action="None" /> <!-- The const variable 'variable' can be computed at compile time. Consider using constexpr -->
101100
<Rule Id="C26818" Action="None" /> <!-- Switch statement does not cover all cases. Consider adding a 'default' label -->

src/Servers/IIS/AspNetCoreModuleV2/IISLib/hashfn.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
// the low end of the hashtable otherwise. LKRhash applies this internally
1313
// to all hash signatures for exactly this reason.
1414

15-
inline DWORD
15+
inline constexpr DWORD
1616
HashScramble(DWORD dwHash)
1717
{
1818
// Here are 10 primes slightly greater than 10^9
1919
// 1000000007, 1000000009, 1000000021, 1000000033, 1000000087,
2020
// 1000000093, 1000000097, 1000000103, 1000000123, 1000000181.
2121

2222
// default value for "scrambling constant"
23-
const DWORD RANDOM_CONSTANT = 314159269UL;
23+
constexpr DWORD RANDOM_CONSTANT = 314159269UL;
2424
// large prime number, also used for scrambling
25-
const DWORD RANDOM_PRIME = 1000000007UL;
25+
constexpr DWORD RANDOM_PRIME = 1000000007UL;
2626

2727
return (RANDOM_CONSTANT * dwHash) % RANDOM_PRIME ;
2828
}
2929

3030

3131
// Faster scrambling function suggested by Eric Jacobsen
3232

33-
inline DWORD
33+
inline DWORD constexpr
3434
HashRandomizeBits(DWORD dw)
3535
{
3636
return (((dw * 1103515245 + 12345) >> 16)
@@ -39,7 +39,7 @@ HashRandomizeBits(DWORD dw)
3939

4040

4141
// Small prime number used as a multiplier in the supplied hash functions
42-
const DWORD HASH_MULTIPLIER = 101;
42+
constexpr DWORD HASH_MULTIPLIER = 101;
4343

4444
#undef HASH_SHIFT_MULTIPLY
4545

@@ -273,51 +273,51 @@ Hash(
273273
}
274274

275275
// Identity hash functions: scalar values map to themselves
276-
inline DWORD Hash(char c)
276+
inline constexpr DWORD Hash(char c)
277277
{ return c; }
278278

279-
inline DWORD Hash(unsigned char uc)
279+
inline constexpr DWORD Hash(unsigned char uc)
280280
{ return uc; }
281281

282-
inline DWORD Hash(signed char sc)
282+
inline constexpr DWORD Hash(signed char sc)
283283
{ return sc; }
284284

285-
inline DWORD Hash(short sh)
285+
inline constexpr DWORD Hash(short sh)
286286
{ return sh; }
287287

288-
inline DWORD Hash(unsigned short ush)
288+
inline constexpr DWORD Hash(unsigned short ush)
289289
{ return ush; }
290290

291-
inline DWORD Hash(int i)
291+
inline constexpr DWORD Hash(int i)
292292
{ return i; }
293293

294-
inline DWORD Hash(unsigned int u)
294+
inline constexpr DWORD Hash(unsigned int u)
295295
{ return u; }
296296

297-
inline DWORD Hash(long l)
297+
inline constexpr DWORD Hash(long l)
298298
{ return l; }
299299

300-
inline DWORD Hash(unsigned long ul)
300+
inline constexpr DWORD Hash(unsigned long ul)
301301
{ return ul; }
302302

303-
inline DWORD Hash(float f)
303+
inline constexpr DWORD Hash(float f)
304304
{
305305
// be careful of rounding errors when computing keys
306306
union {
307307
float f;
308308
DWORD dw;
309-
} u;
309+
} u{};
310310
u.f = f;
311311
return u.dw;
312312
}
313313

314-
inline DWORD Hash(double dbl)
314+
inline constexpr DWORD Hash(double dbl)
315315
{
316316
// be careful of rounding errors when computing keys
317317
union {
318318
double dbl;
319319
DWORD dw[2];
320-
} u;
320+
} u{};
321321
u.dbl = dbl;
322322
return u.dw[0] * HASH_MULTIPLIER + u.dw[1];
323323
}

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/StartupExceptionApplication.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class StartupExceptionApplication : public InProcessApplicationBase
2424
m_error(errorPageContent),
2525
m_statusCode(statusCode),
2626
m_subStatusCode(subStatusCode),
27-
m_statusText(std::move(statusText)),
27+
m_statusText(statusText),
2828
InProcessApplicationBase(pServer, pApplication)
2929
{
3030
}

0 commit comments

Comments
 (0)