pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/Dwrite/ClickHouse/commit/4e76629aafc4e855e6a1d006e655d48ea141c6ea

crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> Fixes for -Wshorten-64-to-32 · Dwrite/ClickHouse@4e76629 · GitHub
Skip to content

Commit 4e76629

Browse files
committed
Fixes for -Wshorten-64-to-32
- lots of static_cast - add safe_cast - types adjustments - config - IStorage::read/watch - ... - some TODO's (to convert types in future) P.S. That was quite a journey... v2: fixes after rebase v3: fix conflicts after ClickHouse#42308 merged Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
1 parent 19715f1 commit 4e76629

411 files changed

Lines changed: 1209 additions & 965 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/base/ReplxxLineReader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class TemporaryFile
151151
{
152152
size_t dot_pos = path.rfind('.');
153153
if (dot_pos != std::string::npos)
154-
fd = ::mkstemps(path.data(), path.size() - dot_pos);
154+
fd = ::mkstemps(path.data(), static_cast<int>(path.size() - dot_pos));
155155
else
156156
fd = ::mkstemp(path.data());
157157

@@ -408,7 +408,7 @@ ReplxxLineReader::ReplxxLineReader(
408408
// In a simplest case use simple comment.
409409
commented_line = fmt::format("-- {}", state.text());
410410
}
411-
rx.set_state(replxx::Replxx::State(commented_line.c_str(), commented_line.size()));
411+
rx.set_state(replxx::Replxx::State(commented_line.c_str(), static_cast<int>(commented_line.size())));
412412

413413
return rx.invoke(Replxx::ACTION::COMMIT_LINE, code);
414414
};
@@ -480,7 +480,7 @@ void ReplxxLineReader::openEditor()
480480
if (executeCommand(argv) == 0)
481481
{
482482
const std::string & new_query = readFile(editor_file.getPath());
483-
rx.set_state(replxx::Replxx::State(new_query.c_str(), new_query.size()));
483+
rx.set_state(replxx::Replxx::State(new_query.c_str(), static_cast<int>(new_query.size())));
484484
}
485485
}
486486
catch (const std::runtime_error & e)
@@ -526,7 +526,7 @@ void ReplxxLineReader::openInteractiveHistorySearch()
526526
{
527527
std::string new_query = readFile(output_file.getPath());
528528
rightTrim(new_query);
529-
rx.set_state(replxx::Replxx::State(new_query.c_str(), new_query.size()));
529+
rx.set_state(replxx::Replxx::State(new_query.c_str(), static_cast<int>(new_query.size())));
530530
}
531531
}
532532
catch (const std::runtime_error & e)

base/base/StringRef.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ inline size_t hashLessThan16(const char * data, size_t size)
265265

266266
struct CRC32Hash
267267
{
268-
size_t operator() (StringRef x) const
268+
unsigned operator() (StringRef x) const
269269
{
270270
const char * pos = x.data;
271271
size_t size = x.size;
@@ -275,22 +275,22 @@ struct CRC32Hash
275275

276276
if (size < 8)
277277
{
278-
return hashLessThan8(x.data, x.size);
278+
return static_cast<unsigned>(hashLessThan8(x.data, x.size));
279279
}
280280

281281
const char * end = pos + size;
282-
size_t res = -1ULL;
282+
unsigned res = -1U;
283283

284284
do
285285
{
286286
UInt64 word = unalignedLoad<UInt64>(pos);
287-
res = CRC_INT(res, word);
287+
res = static_cast<unsigned>(CRC_INT(res, word));
288288

289289
pos += 8;
290290
} while (pos + 8 < end);
291291

292292
UInt64 word = unalignedLoad<UInt64>(end - 8); /// I'm not sure if this is normal.
293-
res = CRC_INT(res, word);
293+
res = static_cast<unsigned>(CRC_INT(res, word));
294294

295295
return res;
296296
}

base/base/itoa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ QuotientAndRemainder<N> static inline split(UnsignedOfSize<N> value)
122122
constexpr DivisionBy10PowN<N> division;
123123

124124
UnsignedOfSize<N> quotient = (division.multiplier * (UnsignedOfSize<2 * N>(value) + division.add)) >> division.shift;
125-
UnsignedOfSize<N / 2> remainder = value - quotient * pow10<UnsignedOfSize<N / 2>>(N);
125+
UnsignedOfSize<N / 2> remainder = static_cast<UnsignedOfSize<2 * N>>(value - quotient * pow10<UnsignedOfSize<N / 2>>(N));
126126

127127
return {quotient, remainder};
128128
}

programs/client/Client.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,15 +1108,21 @@ void Client::processConfig()
11081108
else
11091109
format = config().getString("format", is_interactive ? "PrettyCompact" : "TabSeparated");
11101110

1111-
format_max_block_size = config().getInt("format_max_block_size", global_context->getSettingsRef().max_block_size);
1111+
format_max_block_size = config().getUInt64("format_max_block_size",
1112+
global_context->getSettingsRef().max_block_size);
11121113

11131114
insert_format = "Values";
11141115

11151116
/// Setting value from cmd arg overrides one from config
11161117
if (global_context->getSettingsRef().max_insert_block_size.changed)
1118+
{
11171119
insert_format_max_block_size = global_context->getSettingsRef().max_insert_block_size;
1120+
}
11181121
else
1119-
insert_format_max_block_size = config().getInt("insert_format_max_block_size", global_context->getSettingsRef().max_insert_block_size);
1122+
{
1123+
insert_format_max_block_size = config().getUInt64("insert_format_max_block_size",
1124+
global_context->getSettingsRef().max_insert_block_size);
1125+
}
11201126

11211127
ClientInfo & client_info = global_context->getClientInfo();
11221128
client_info.setInitialQuery();

programs/copier/ZooKeeperStaff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class Zxid
4747
WrappingUInt32 epoch;
4848
WrappingUInt32 counter;
4949
explicit Zxid(UInt64 _zxid)
50-
: epoch(_zxid >> 32)
51-
, counter(_zxid)
50+
: epoch(static_cast<UInt32>(_zxid >> 32))
51+
, counter(static_cast<UInt32>(_zxid))
5252
{}
5353

5454
bool operator<=(const Zxid & other) const

programs/install/Install.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ namespace
893893
if (fs::exists(pid_file))
894894
{
895895
ReadBufferFromFile in(pid_file.string());
896-
UInt64 pid;
896+
Int32 pid;
897897
if (tryReadIntText(pid, in))
898898
{
899899
fmt::print("{} file exists and contains pid = {}.\n", pid_file.string(), pid);
@@ -982,9 +982,9 @@ namespace
982982
return 0;
983983
}
984984

985-
UInt64 isRunning(const fs::path & pid_file)
985+
int isRunning(const fs::path & pid_file)
986986
{
987-
UInt64 pid = 0;
987+
int pid = 0;
988988

989989
if (fs::exists(pid_file))
990990
{
@@ -1057,7 +1057,7 @@ namespace
10571057
if (force && do_not_kill)
10581058
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Specified flags are incompatible");
10591059

1060-
UInt64 pid = isRunning(pid_file);
1060+
int pid = isRunning(pid_file);
10611061

10621062
if (!pid)
10631063
return 0;

programs/keeper/Keeper.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ namespace ErrorCodes
6868
namespace
6969
{
7070

71-
int waitServersToFinish(std::vector<DB::ProtocolServerAdapter> & servers, size_t seconds_to_wait)
71+
size_t waitServersToFinish(std::vector<DB::ProtocolServerAdapter> & servers, size_t seconds_to_wait)
7272
{
73-
const int sleep_max_ms = 1000 * seconds_to_wait;
74-
const int sleep_one_ms = 100;
75-
int sleep_current_ms = 0;
76-
int current_connections = 0;
73+
const size_t sleep_max_ms = 1000 * seconds_to_wait;
74+
const size_t sleep_one_ms = 100;
75+
size_t sleep_current_ms = 0;
76+
size_t current_connections = 0;
7777
for (;;)
7878
{
7979
current_connections = 0;
@@ -441,7 +441,7 @@ int Keeper::main(const std::vector<std::string> & /*args*/)
441441
main_config_reloader.reset();
442442

443443
LOG_DEBUG(log, "Waiting for current connections to Keeper to finish.");
444-
int current_connections = 0;
444+
size_t current_connections = 0;
445445
for (auto & server : *servers)
446446
{
447447
server.stop();

programs/local/LocalServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,14 @@ void LocalServer::processConfig()
546546

547547
/// Setting value from cmd arg overrides one from config
548548
if (global_context->getSettingsRef().max_insert_block_size.changed)
549+
{
549550
insert_format_max_block_size = global_context->getSettingsRef().max_insert_block_size;
551+
}
550552
else
551-
insert_format_max_block_size = config().getInt("insert_format_max_block_size", global_context->getSettingsRef().max_insert_block_size);
553+
{
554+
insert_format_max_block_size = config().getUInt64("insert_format_max_block_size",
555+
global_context->getSettingsRef().max_insert_block_size);
556+
}
552557

553558
/// Sets external authenticators config (LDAP, Kerberos).
554559
global_context->setExternalAuthenticatorsConfig(config());

programs/obfuscator/Obfuscator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Float transformFloatMantissa(Float x, UInt64 seed)
279279
constexpr size_t mantissa_num_bits = std::is_same_v<Float, Float32> ? 23 : 52;
280280

281281
UInt x_uint = bit_cast<UInt>(x);
282-
x_uint = feistelNetwork(x_uint, mantissa_num_bits, seed);
282+
x_uint = static_cast<UInt>(feistelNetwork(x_uint, mantissa_num_bits, seed));
283283
return bit_cast<Float>(x_uint);
284284
}
285285

@@ -511,13 +511,13 @@ class DateTimeModel : public IModel
511511
for (size_t i = 0; i < size; ++i)
512512
{
513513
UInt32 src_datetime = src_data[i];
514-
UInt32 src_date = date_lut.toDate(src_datetime);
514+
UInt32 src_date = static_cast<UInt32>(date_lut.toDate(src_datetime));
515515

516516
Int32 src_diff = src_datetime - src_prev_value;
517-
Int32 res_diff = transformSigned(src_diff, seed);
517+
Int32 res_diff = static_cast<Int32>(transformSigned(src_diff, seed));
518518

519519
UInt32 new_datetime = res_prev_value + res_diff;
520-
UInt32 new_time = new_datetime - date_lut.toDate(new_datetime);
520+
UInt32 new_time = new_datetime - static_cast<UInt32>(date_lut.toDate(new_datetime));
521521
res_data[i] = src_date + new_time;
522522

523523
src_prev_value = src_datetime;

programs/odbc-bridge/ColumnInfoHandler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ void ODBCColumnsInfoHandler::handleRequest(HTTPServerRequest & request, HTTPServ
183183
if (columns.empty())
184184
throw Exception("Columns definition was not returned", ErrorCodes::LOGICAL_ERROR);
185185

186-
WriteBufferFromHTTPServerResponse out(response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout);
186+
WriteBufferFromHTTPServerResponse out(
187+
response,
188+
request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD,
189+
static_cast<unsigned>(keep_alive_timeout));
187190
try
188191
{
189192
writeStringBinary(columns.toString(), out);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy