Skip to content

Commit

Permalink
Fix various warnnigs messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberium committed Sep 17, 2015
1 parent bb5dfcc commit cf77ece
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions cmake/compiler/clang/settings.cmake
Expand Up @@ -6,6 +6,9 @@ if(WARNINGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual")
message(STATUS "Clang: All warnings enabled")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused*result")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
endif()

if(DEBUG)
Expand Down
4 changes: 4 additions & 0 deletions cmake/compiler/gcc/settings.cmake
Expand Up @@ -6,7 +6,11 @@ if(PLATFORM EQUAL X86)
set(SSE_FLAGS "-msse2 -mfpmath=sse")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused*result")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
endif()

add_definitions(-DHAVE_SSE2)
message(STATUS "GCC: SFMT enabled, SSE2 flags forced")

Expand Down
8 changes: 4 additions & 4 deletions src/game/CalendarHandler.cpp
Expand Up @@ -44,7 +44,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
sCalendarMgr.GetPlayerInvitesList(guid, invites);

data << uint32(invites.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u invites", invites.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u invites", uint32(invites.size()));

for (CalendarInvitesList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
Expand All @@ -66,7 +66,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
sCalendarMgr.GetPlayerEventsList(guid, events);

data << uint32(events.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u events", events.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u events", uint32(events.size()));

for (CalendarEventsList::const_iterator itr = events.begin(); itr != events.end(); ++itr)
{
Expand Down Expand Up @@ -368,7 +368,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
CharacterDatabase.PExecute("UPDATE calendar_events SET "
"type=%hu, flags=%u, dungeonId=%d, eventTime=%u, title='%s', description='%s'"
"WHERE eventid=" UI64FMTD,
type, flags, dungeonId, event->EventTime, title.c_str(), description.c_str(), eventId);
type, flags, dungeonId, uint32(event->EventTime), title.c_str(), description.c_str(), eventId);
}
else
sCalendarMgr.SendCalendarCommandResult(_player, CALENDAR_ERROR_EVENT_INVALID);
Expand Down Expand Up @@ -510,7 +510,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
invite.LastUpdateTime = time(NULL);

sCalendarMgr.SendCalendarEventInvite(&invite);
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "PREINVITE> sender[%s], Invitee[%u]", playerGuid.GetString().c_str(), inviteeGuid.GetString().c_str());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "PREINVITE> sender[%s], Invitee[%s]", playerGuid.GetString().c_str(), inviteeGuid.GetString().c_str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/Player.cpp
Expand Up @@ -20225,7 +20225,7 @@ void Player::SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaLockS
case AREA_LOCKSTATUS_QUEST_NOT_COMPLETED:
if (mapEntry->MapID == 269) // Exception for Black Morass
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetMangosString(LANG_TELEREQ_QUEST_BLACK_MORASS));
GetSession()->SendAreaTriggerMessage("%s", GetSession()->GetMangosString(LANG_TELEREQ_QUEST_BLACK_MORASS));
break;
}
else if (mapEntry->IsContinent()) // do not report anything for quest areatrigge
Expand Down
2 changes: 1 addition & 1 deletion src/scriptdev2/base/escort_ai.cpp
Expand Up @@ -40,7 +40,7 @@ void npc_escortAI::GetAIInformation(ChatHandler& reader)
m_creature->GetMotionMaster()->GetWaypointPathInformation(oss);
}

reader.PSendSysMessage(oss.str().c_str());
reader.PSendSysMessage("%s", oss.str().c_str());
}

bool npc_escortAI::IsVisible(Unit* pWho) const
Expand Down
Expand Up @@ -68,7 +68,7 @@ struct npc_anubisath_sentinelAI : public ScriptedAI
if (m_lAssistList.size() == MAX_BUDDY)
reader.PSendSysMessage("Anubisath Sentinel - proper group found");
else
reader.PSendSysMessage("Anubisath Sentinel - not correct number of mobs for group found. Number found %u, should be %u", m_lAssistList.size(), MAX_BUDDY);
reader.PSendSysMessage("Anubisath Sentinel - not correct number of mobs for group found. Number found %u, should be %u", uint32(m_lAssistList.size()), MAX_BUDDY);
}

void JustReachedHome() override
Expand Down
6 changes: 3 additions & 3 deletions src/shared/ByteBuffer.cpp
Expand Up @@ -51,7 +51,7 @@ void ByteBuffer::print_storage() const
for (size_t i = 0; i < size(); ++i)
ss << uint32(read<uint8>(i)) << " - ";

sLog.outDebug(ss.str().c_str());
sLog.outDebug("%s", ss.str().c_str());
}

void ByteBuffer::textlike() const
Expand All @@ -68,7 +68,7 @@ void ByteBuffer::textlike() const
for (size_t i = 0; i < size(); ++i)
ss << read<uint8>(i);

sLog.outDebug(ss.str().c_str());
sLog.outDebug("%s", ss.str().c_str());
}

void ByteBuffer::hexlike() const
Expand Down Expand Up @@ -107,5 +107,5 @@ void ByteBuffer::hexlike() const
ss << buf << " ";
}

sLog.outDebug(ss.str().c_str());
sLog.outDebug("%s", ss.str().c_str());
}
2 changes: 1 addition & 1 deletion src/shared/Database/SQLStorage.cpp
Expand Up @@ -156,7 +156,7 @@ void SQLStorage::prepareToLoad(uint32 maxRecordId, uint32 recordCount, uint32 re

// Set index array
m_Index = new char* [maxRecordId];
memset(m_Index, NULL, maxRecordId * sizeof(char*));
memset(m_Index, 0, maxRecordId * sizeof(char*));

SQLStorageBase::prepareToLoad(maxRecordId, recordCount, recordSize);
}
Expand Down

3 comments on commit cf77ece

@evil-at-wow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the CMake changes: I'm not in favor of hiding warnings, so if reasonably possible I would prefer to fix the actual code instead of setting up compiler flags to hide them.

The GCC changes don't really make sense to me. Why would you want to hide warnings for every architecture except (32-bit) x86? Am I detecting a quick copy/paste mistake there - the GCC file is very similar to the clang one, but not quite the same?

@cyberium
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg i missed the "warning block"

About hiding its only about all case when we have something like
fread(..,size,.) and we dont realy need to check if size is same to the returned by function size.

@evil-at-wow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing some context about the warnings. I would assume we're using fread to actually read some data, in which case I'd say we do need to check the return value to catch any errors and make sure we got what we think we've read (or otherwise advance in the file as much as we expected if we don't care about the actual data).

I'll try reverting the flags locally and check how bad it would be to change the code.

Please sign in to comment.