Skip to content

Commit

Permalink
Resolve compilation and warning issues (OpenAtomFoundation#1740)
Browse files Browse the repository at this point in the history
* Resolve compilation and warning issues
  • Loading branch information
Mixficsol authored Jul 17, 2023
1 parent a37f45c commit bac8102
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/pika_binlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Version final : public pstd::noncopyable {

void debug() {
std::shared_lock l(rwlock_);
printf("Current pro_num %u pro_offset %lu\n", pro_num_, pro_offset_);
printf("Current pro_num %u pro_offset %llu\n", pro_num_, pro_offset_);
}

private:
Expand Down
4 changes: 2 additions & 2 deletions src/pika_geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void GeoDistCmd::Do(std::shared_ptr<Slot> slot) {
double distance = geohashGetDistance(first_xy[0], first_xy[1], second_xy[0], second_xy[1]);
distance = length_converter(distance, unit_);
char buf[32];
sprintf(buf, "%.4f", distance);
snprintf(buf, sizeof(buf), "%.4f", distance);
res_.AppendStringLenUint64(strlen(buf));
res_.AppendContent(buf);
}
Expand Down Expand Up @@ -371,7 +371,7 @@ static void GetAllNeighbors(const std::shared_ptr<Slot>& slot, std::string& key,
double distance = geohashGetDistance(longitude, latitude, xy[0], xy[1]);
distance = length_converter(distance, range.unit);
char buf[32];
sprintf(buf, "%.4f", distance);
snprintf(buf, sizeof(buf), "%.4f", distance);
res.AppendStringLenUint64(strlen(buf));
res.AppendContent(buf);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ void PikaServer::SlowlogPushEntry(const PikaCmdArgsType& argv, int32_t time, int
for (uint32_t idx = 0; idx < slargc; ++idx) {
if (slargc != argv.size() && idx == slargc - 1) {
char buffer[32];
sprintf(buffer, "... (%lu more arguments)", argv.size() - slargc + 1);
snprintf(buffer, sizeof(buffer), "... (%lu more arguments)", argv.size() - slargc + 1);
entry.argv.push_back(std::string(buffer));
} else {
if (argv[idx].size() > SLOWLOG_ENTRY_MAX_STRING) {
Expand Down
2 changes: 1 addition & 1 deletion src/pika_slot_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ void SlotsReloadCmd::Do(std::shared_ptr<Slot> slot) {
g_pika_server->Bgslotsreload(slot);
const PikaServer::BGSlotsReload &info = g_pika_server->bgslots_reload();
char buf[256];
snprintf(buf, sizeof(buf), "+%s : %lu", info.s_start_time.c_str(), g_pika_server->GetSlotsreloadingCursor());
snprintf(buf, sizeof(buf), "+%s : %lld", info.s_start_time.c_str(), g_pika_server->GetSlotsreloadingCursor());
res_.AppendContent(buf);
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/storage/include/storage/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace storage {

int Int64ToStr(char* dst, size_t dstlen, int64_t svalue);
int StrToInt64(const char* s, size_t slen, int64_t* value);
int StringMatch(const char* pattern, int pattern_len, const char* string, int string_len, int nocase);
int StringMatch(const char* pattern, uint64_t pattern_len, const char* string, uint64_t string_len, int nocase);
int StrToLongDouble(const char* s, size_t slen, long double* ldval);
int LongDoubleToStr(long double ldval, std::string* value);
Expand Down
4 changes: 0 additions & 4 deletions src/storage/src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ int StrToInt64(const char* s, size_t slen, int64_t* value) {
}

/* Glob-style pattern matching. */
int StringMatch(const char* pattern, int pattern_len, const char* str, int string_len, int nocase) {
return pstd::stringmatchlen(pattern, pattern_len, str, string_len, nocase);
}

int StringMatch(const char* pattern, uint64_t pattern_len, const char* str, uint64_t string_len, int nocase) {
return pstd::stringmatchlen(pattern, static_cast<int32_t>(pattern_len), str, static_cast<int32_t>(string_len), nocase);
}
Expand Down

0 comments on commit bac8102

Please sign in to comment.