Skip to content

Commit 8c95ad3

Browse files
authored
Fix warnings in examples (#8636)
1 parent a8e98b5 commit 8c95ad3

File tree

13 files changed

+40
-23
lines changed

13 files changed

+40
-23
lines changed

builds/win32/msvc15/empbuild.vcxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@
276276
<Project>{4fe03933-98cd-4879-a135-fd9430087a6b}</Project>
277277
</ProjectReference>
278278
</ItemGroup>
279+
<ItemGroup>
280+
<None Include="..\..\..\examples\empbuild\empbuild.epp" />
281+
</ItemGroup>
279282
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
280283
<ImportGroup Label="ExtensionTargets">
281284
</ImportGroup>
282-
</Project>
285+
</Project>

builds/win32/msvc15/empbuild.vcxproj.filters

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
<UniqueIdentifier>{307f31db-efbf-4c9c-9aa6-dbda2d6d8484}</UniqueIdentifier>
1414
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
1515
</Filter>
16+
<Filter Include="GPRE files">
17+
<UniqueIdentifier>{dbcdcdf8-efc8-4106-b609-1e490745e955}</UniqueIdentifier>
18+
</Filter>
1619
</ItemGroup>
1720
<ItemGroup>
1821
<ClCompile Include="..\..\..\gen\examples\empbuild.cpp">
1922
<Filter>Source Files</Filter>
2023
</ClCompile>
2124
</ItemGroup>
22-
</Project>
25+
<ItemGroup>
26+
<None Include="..\..\..\examples\empbuild\empbuild.epp">
27+
<Filter>GPRE files</Filter>
28+
</None>
29+
</ItemGroup>
30+
</Project>

examples/dbcrypt/CryptKeyHolder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ int CryptKeyHolder::keyCallback(CheckStatusWrapper* status, ICryptKeyCallback* c
273273
confEntry = getEntry(status, "Key");
274274
if (confEntry)
275275
{
276-
key = confEntry->getIntValue();
276+
key = static_cast<ISC_UCHAR>(confEntry->getIntValue());
277277
confEntry->release();
278278
}
279279
else
@@ -311,7 +311,7 @@ ICryptKeyCallback* CryptKeyHolder::keyHandle(CheckStatusWrapper* status, const c
311311
IConfigEntry* confEntry = getEntry(status, kn);
312312
if (confEntry)
313313
{
314-
int k = confEntry->getIntValue();
314+
int k = static_cast<int>(confEntry->getIntValue());
315315
confEntry->release();
316316
if (k > 0 && k < 256)
317317
{

examples/dbcrypt/DbCrypt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class DbCrypt : public IDbCryptPluginImpl<DbCrypt, CheckStatusWrapper>
119119

120120
private:
121121
IPluginConfig* config;
122-
char savedKeyName[32];
122+
char savedKeyName[32]{};
123123
ISC_UCHAR key;
124124

125125
std::atomic_int refCounter;
@@ -218,7 +218,7 @@ void DbCrypt::setKey(CheckStatusWrapper* status, unsigned int length, IKeyHolder
218218
def->release();
219219
if (confEntry)
220220
{
221-
v = confEntry->getIntValue();
221+
v = static_cast<char>(confEntry->getIntValue());
222222
confEntry->release();
223223
if (v)
224224
{

examples/dbcrypt/msvc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.user

examples/empbuild/empbuild.epp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ while (fgets (line, 100, Fp) != NULL)
287287
if (*line == '\n')
288288
break;
289289

290-
len = strlen (line);
290+
len = static_cast<int>(strlen(line));
291291
EXEC SQL INSERT CURSOR be VALUES (:line INDICATOR :len);
292292
}
293293

@@ -365,7 +365,7 @@ while (fgets (line, 100, Fp) != NULL)
365365
if (*line == '\n')
366366
break;
367367

368-
len = strlen (line);
368+
len = static_cast<int>(strlen(line));
369369
EXEC SQL INSERT CURSOR bd VALUES (:line INDICATOR :len);
370370
}
371371

examples/extauth/ExtAuth.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
#define HANDSHAKE_DEBUG(A)
3434

35-
const unsigned LOGINSIZE = 128u;
36-
const unsigned RANDSIZE = 32u;
37-
const unsigned SALTLEN = 8u;
35+
constexpr unsigned LOGINSIZE = 128u;
36+
constexpr unsigned RANDSIZE = 32u;
37+
constexpr unsigned SALTLEN = 8u;
3838

3939
typedef unsigned int ULong;
4040

@@ -138,7 +138,7 @@ class PluginData
138138

139139
PseudoRandom pseudoRand;
140140
HashSha256 hash;
141-
rsa_key privateKey;
141+
rsa_key privateKey{};
142142
int iniLvl;
143143
};
144144

@@ -253,7 +253,7 @@ int ExtAuthClient::authenticate(ThrowStatusWrapper* status, IClientBlock* cBlock
253253
error(status, "Malformed data from server - missing random block");
254254

255255
// next append login to random block
256-
unsigned len = strlen(login);
256+
unsigned len = static_cast<unsigned>(strlen(login));
257257
if (len > LOGINSIZE)
258258
len = LOGINSIZE;
259259
memcpy(&bytes[RANDSIZE], login, len);
@@ -340,7 +340,7 @@ class ExtAuthServer : public IServerImpl<ExtAuthServer, ThrowStatusWrapper>, pub
340340
}
341341

342342
private:
343-
unsigned char msg[RANDSIZE + LOGINSIZE];
343+
unsigned char msg[RANDSIZE + LOGINSIZE]{};
344344
bool sentData;
345345
};
346346

@@ -377,7 +377,7 @@ int ExtAuthServer::authenticate(ThrowStatusWrapper* status, IServerBlock* sBlock
377377

378378
// decompose message
379379
const char* login = reinterpret_cast<const char*>(data);
380-
unsigned len = strnlen(login, dl);
380+
unsigned len = static_cast<unsigned>(strnlen(login, dl));
381381
if (len == dl)
382382
error(status, "Wrong data from client - no signature in a message");
383383
if (len == 0)

examples/extauth/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ KEYGEN_objects=$(INTERMED)/keygen.o
6161
TCWRAP_objects=$(INTERMED)/TcWrapper.o
6262
KEY_AUTH_objects=$(INTERMED)/ExtAuth.o
6363

64-
CXXFLAGS=-std=c++11 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE)
64+
CXXFLAGS=-std=c++20 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE)
6565
LDFLAGS=-pthread -L$(LIB) -Wl,-rpath,'$$ORIGIN/../lib' $(TOMCRYPT_LINK)
6666

6767
LINK_LIBS=-lfbclient -ltomcrypt -ltommath

examples/extauth/TcWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ unsigned readHexKey(ThrowStatusWrapper* status, const char* hex, unsigned char*
8181
error(status, "Key format error");
8282
*k++ = static_cast<unsigned char>(c);
8383
}
84-
return k - key;
84+
return static_cast<unsigned>(k - key);
8585
}
8686

8787
void PseudoRandom::init(ThrowStatusWrapper* status)

examples/extauth/msvc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.user

0 commit comments

Comments
 (0)