1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

gcc warnings

- uint64_t format errors using <cinttypes> define SCNu64
- sprintf without format string replacing with strcpy (might be better
to move to strncpy or something else)
- use return value of fread(...)
- use return value of system(...)
This commit is contained in:
ShelbyZ 2017-11-01 22:24:50 -07:00
parent 9fd4155121
commit 33da12a8d3
9 changed files with 23 additions and 19 deletions

View file

@ -3,6 +3,7 @@
#include <mutex>
#include <stdio.h>
#include <cinttypes>
#include <mysql.h>
@ -38,18 +39,11 @@ namespace Db {
{
if( m_pValue )
{
#ifdef _WIN32
uint64_t value;
sscanf( m_pValue, "%I64d", &value );
sscanf( m_pValue, "%" SCNu64, &value );
return value;
#else
uint64_t value;
sscanf( m_pValue, "%Lu", &value );
return value;
#endif
}
else
}
else
return 0;
}

View file

@ -139,7 +139,7 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
serverListPacket.data().server[0].id = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 );
serverListPacket.data().server[0].index = 0;
serverListPacket.data().final = 1;
sprintf( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
strcpy( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
pRP.addPacket( serverListPacket );

View file

@ -273,7 +273,7 @@ bool Core::Entity::Player::loadSearchInfo()
m_searchSelectClass = field[1].get< uint8_t >();
m_searchSelectRegion = field[2].get< uint8_t >();
sprintf( m_searchMessage, field[3].getString().c_str() );
strcpy( m_searchMessage, field[3].getString().c_str() );
return true;
}

View file

@ -31,6 +31,8 @@
#include "src/servers/Server_Zone/Session.h"
#include <boost/make_shared.hpp>
#include <cinttypes>
extern Core::Db::Database g_database;
extern Core::Scripting::ScriptManager g_scriptMgr;
extern Core::Data::ExdData g_exdData;
@ -256,7 +258,7 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
else if ( subCommand == "eorzeatime" )
{
uint64_t timestamp;
sscanf( params.c_str(), "%llu", &timestamp );
sscanf( params.c_str(), "%" SCNu64, &timestamp );
pPlayer->setEorzeaTimeOffset( timestamp );
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );

View file

@ -329,7 +329,11 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
fseek( fp, 0, SEEK_END );
int32_t size = ftell( fp );
rewind( fp );
fread( packet, sizeof( char ), size, fp );
if ( fread( packet, sizeof( char ), size, fp ) != size )
{
g_log.error( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) );
return;
}
fclose( fp );
// cycle through the packet entries and queue each one

View file

@ -335,7 +335,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = param1;
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,

View file

@ -84,7 +84,7 @@ void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePac
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = status;
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
queueOutPacket( searchInfoPacket );
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
@ -98,7 +98,7 @@ void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePac
GamePacketNew< FFXIVIpcInitSearchInfo, ServerZoneIpcType > searchInfoPacket( pPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = pPlayer->getOnlineStatusMask();
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() );
queueOutPacket( searchInfoPacket );
}

View file

@ -51,7 +51,7 @@ private:
memset( &m_data.name[0], 0, sizeof( m_data.name ) );
sprintf( &m_data.name[0], player->getName().c_str() );
strcpy( &m_data.name[0], player->getName().c_str() );
memcpy( m_data.aetheryte, player->getAetheryteArray(), sizeof ( m_data.aetheryte ) );

View file

@ -303,7 +303,11 @@ int main()
outputFile1.write(&section[0], section.size());
outputFile1.close();
std::string command= std::string("java -jar unluac_2015_06_13.jar ") + "generated/" + questInfo->name_intern + ".luab" + ">> " + "generated/" + questInfo->name_intern + ".lua";
system(command.c_str());
if ( system( command.c_str() ) == -1 )
{
g_log.error( "Error executing java command:\n" + command + "\nerrno: " + std::strerror( errno ) );
return errno;
}
for( ; ; )
{