summaryrefslogtreecommitdiff
path: root/src/char/int_guild.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-12-10 19:48:55 +0100
committerHaru <haru@dotalux.com>2013-12-17 01:11:33 +0100
commit15a0f6dea6f4f3c5adc9a1bc9e7e8be81cc49c48 (patch)
treec5dd5b25003f8c21381c7a2e1f010dba71e40b90 /src/char/int_guild.c
parenta23d072a66d2569ba13921522be3c82ae9aad576 (diff)
downloadhercules-15a0f6dea6f4f3c5adc9a1bc9e7e8be81cc49c48.tar.gz
hercules-15a0f6dea6f4f3c5adc9a1bc9e7e8be81cc49c48.tar.bz2
hercules-15a0f6dea6f4f3c5adc9a1bc9e7e8be81cc49c48.tar.xz
hercules-15a0f6dea6f4f3c5adc9a1bc9e7e8be81cc49c48.zip
Fixed several compiler warnings
- Warnings detected thanks to Xcode's compiler settings (more strict by default) and clang, warnings mostly but not only related to data sizes on 64 bit systems, that were silenced until now by very lax compiler settings. - This also decreases by a great deal the amount of warnings produced by MSVC in x64 mode (for the adventurous ones who tried that) - Also fixed (or silenced in case of false positives) the potential issues pointed out by the (awesome) clang static analyzer. - Patch co-produced with Ind, I'm merging and committing in his place! Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/int_guild.c')
-rw-r--r--src/char/int_guild.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 5f033f4d7..6bd8ca568 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -447,16 +447,16 @@ struct guild * inter_guild_fromsql(int guild_id)
while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
{
int position;
- struct guild_position* p;
+ struct guild_position *pos;
SQL->GetData(sql_handle, 0, &data, NULL); position = atoi(data);
if( position < 0 || position >= MAX_GUILDPOSITION )
continue;// invalid position
- p = &g->position[position];
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); p->mode = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); p->exp_mode = atoi(data);
- p->modified = GS_POSITION_UNMODIFIED;
+ pos = &g->position[position];
+ SQL->GetData(sql_handle, 1, &data, &len); memcpy(pos->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(sql_handle, 2, &data, NULL); pos->mode = atoi(data);
+ SQL->GetData(sql_handle, 3, &data, NULL); pos->exp_mode = atoi(data);
+ pos->modified = GS_POSITION_UNMODIFIED;
}
//printf("- Read guild_alliance %d from sql \n",guild_id);
@@ -1664,7 +1664,7 @@ static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int ac
int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
{
// Could speed up
- struct guild *g[2];
+ struct guild *g[2] = { NULL };
int j,i;
g[0] = inter_guild_fromsql(guild_id1);
g[1] = inter_guild_fromsql(guild_id2);
@@ -1675,25 +1675,19 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1
if(g[0]==NULL || g[1]==NULL)
return 0;
- if(flag&GUILD_ALLIANCE_REMOVE)
- {
+ if( flag&GUILD_ALLIANCE_REMOVE ) {
// Remove alliance/opposition, in case of alliance, remove on both side
- for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
- {
+ for( i = 0; i < ((flag&GUILD_ALLIANCE_TYPE_MASK) ? 1 : 2); i++ ) {
ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == g[1-i]->guild_id && g[i]->alliance[j].opposition == (flag&GUILD_ALLIANCE_TYPE_MASK) );
if( j < MAX_GUILDALLIANCE )
g[i]->alliance[j].guild_id = 0;
}
- }
- else
- {
+ } else {
// Add alliance, in case of alliance, add on both side
- for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
- {
+ for( i = 0; i < ((flag&GUILD_ALLIANCE_TYPE_MASK) ? 1 : 2); i++ ) {
// Search an empty slot
ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 );
- if( j < MAX_GUILDALLIANCE )
- {
+ if( j < MAX_GUILDALLIANCE ) {
g[i]->alliance[j].guild_id=g[1-i]->guild_id;
memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH);
// Set alliance type