Skip to content

Commit

Permalink
Use explicit cast instead of 1ll.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Dec 31, 2021
1 parent c038507 commit 01fccc4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions td/mtproto/AuthData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?..
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions td/telegram/Td.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/UserId.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 01fccc4

Please sign in to comment.