Use explicit cast instead of 1ll.

This commit is contained in:
levlam 2021-12-31 09:36:24 +03:00
parent c038507831
commit 01fccc430f
3 changed files with 6 additions and 6 deletions

View File

@ -100,7 +100,7 @@ std::vector<ServerSalt> AuthData::get_future_salts() const {
int64 AuthData::next_message_id(double now) {
double server_time = get_server_time(now);
auto t = static_cast<int64>(server_time * (1ll << 32));
auto t = static_cast<int64>(server_time * (static_cast<int64>(1) << 32));
// randomize lower bits for clocks with low precision
// TODO(perf) do not do this for systems with good precision?..
@ -119,13 +119,13 @@ int64 AuthData::next_message_id(double now) {
bool AuthData::is_valid_outbound_msg_id(int64 id, double now) const {
double server_time = get_server_time(now);
auto id_time = static_cast<double>(id) / static_cast<double>(1ll << 32);
auto id_time = static_cast<double>(id) / static_cast<double>(static_cast<int64>(1) << 32);
return server_time - 150 < id_time && id_time < server_time + 30;
}
bool AuthData::is_valid_inbound_msg_id(int64 id, double now) const {
double server_time = get_server_time(now);
auto id_time = static_cast<double>(id) / static_cast<double>(1ll << 32);
auto id_time = static_cast<double>(id) / static_cast<double>(static_cast<int64>(1) << 32);
return server_time - 300 < id_time && id_time < server_time + 30;
}

View File

@ -4890,10 +4890,10 @@ void Td::on_request(uint64 id, td_api::addNetworkStatistics &request) {
if (entry.net_type == NetType::None) {
return send_error_raw(id, 400, "Network statistics entry can't be increased for NetworkTypeNone");
}
if (entry.rx > (1ll << 40) || entry.rx < 0) {
if (entry.rx > (static_cast<int64>(1) << 40) || entry.rx < 0) {
return send_error_raw(id, 400, "Wrong received bytes value");
}
if (entry.tx > (1ll << 40) || entry.tx < 0) {
if (entry.tx > (static_cast<int64>(1) << 40) || entry.tx < 0) {
return send_error_raw(id, 400, "Wrong sent bytes value");
}
if (entry.count > (1 << 30) || entry.count < 0) {

View File

@ -20,7 +20,7 @@ class UserId {
int64 id = 0;
public:
static constexpr int64 MAX_USER_ID = (1ll << 40) - 1;
static constexpr int64 MAX_USER_ID = (static_cast<int64>(1) << 40) - 1;
UserId() = default;