Skip to content

Commit

Permalink
Fix some clang warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbroad committed Dec 2, 2017
1 parent 53b169b commit 2a392ef
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 29 deletions.
14 changes: 7 additions & 7 deletions actor_scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -2961,9 +2961,9 @@ int parse_actor_skin (actor_types *act, const xmlNode *cfg, const xmlNode *defau
const xmlNode *default_node= get_default_node(cfg, defaults);

if(default_node){
if(skin->hands_name==NULL || *skin->hands_name=='\0')
if(*skin->hands_name=='\0')
get_item_string_value(skin->hands_name, sizeof(skin->hands_name), default_node, (xmlChar*)"hands");
if(skin->head_name==NULL || *skin->head_name=='\0')
if(*skin->head_name=='\0')
get_item_string_value(skin->head_name, sizeof(skin->head_name), default_node, (xmlChar*)"head");
}
}
Expand Down Expand Up @@ -3307,10 +3307,10 @@ int parse_actor_weapon(actor_types *act, const xmlNode *cfg, const xmlNode *defa
const xmlNode *default_node= get_default_node(cfg, defaults);

if(default_node){
if(weapon->skin_name==NULL || *weapon->skin_name=='\0')
if(*weapon->skin_name=='\0')
get_item_string_value(weapon->skin_name, sizeof(weapon->skin_name), default_node, (xmlChar*)"skin");
if(type_idx!=GLOVE_FUR && type_idx!=GLOVE_LEATHER){ // these dont have meshes
if(weapon->model_name==NULL || *weapon->model_name=='\0'){
if(*weapon->model_name=='\0'){
get_item_string_value(weapon->model_name, sizeof(weapon->model_name), default_node, (xmlChar*)"mesh");
weapon->mesh_index= cal_load_weapon_mesh(act, weapon->model_name, "weapon");
}
Expand Down Expand Up @@ -3365,11 +3365,11 @@ int parse_actor_body_part (actor_types *act, body_part *part, const xmlNode *cfg

// check for default entries, if found, use them to fill in missing data
if(default_node){
if(part->skin_name==NULL || *part->skin_name=='\0')
if(*part->skin_name=='\0')
if(strcmp(part_name, "head")){ // heads don't have separate skins here
get_item_string_value(part->skin_name, sizeof(part->skin_name), default_node, (xmlChar*)"skin");
}
if(part->model_name==NULL || *part->model_name=='\0'){
if(*part->model_name=='\0'){
get_item_string_value(part->model_name, sizeof(part->model_name), default_node, (xmlChar*)"mesh");
if(strcmp("shield",part_name)==0)
part->mesh_index= cal_load_weapon_mesh(act, part->model_name, part_name);
Expand Down Expand Up @@ -3603,7 +3603,7 @@ int parse_actor_shield_part (actor_types *act, shield_part *part, const xmlNode

// check for default entries, if found, use them to fill in missing data
if(default_node){
if(part->model_name==NULL || *part->model_name=='\0'){
if(*part->model_name=='\0'){
get_item_string_value(part->model_name, sizeof(part->model_name), default_node, (xmlChar*)"mesh");
part->mesh_index= cal_load_weapon_mesh(act, part->model_name, "shield");
}
Expand Down
2 changes: 1 addition & 1 deletion chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ static void set_button_highlight(widget_list *w, int set_on)

static int click_channel_color_handler(widget_list *w, int mx, int my, Uint32 flags)
{
if(w->id >= 0 && w->id < COLROWS * COLCOLS)
if(w->id < COLROWS * COLCOLS)
{
set_button_highlight(widget_find(w->window_id, selected_color), 0);
set_button_highlight(w, 1);
Expand Down
4 changes: 2 additions & 2 deletions draw_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ void update_camera()
new_zoom_level = 1.0;
camera_tilt_duration = camera_zoom_duration = 0;
camera_tilt_speed = 0.0;
if (fabsf(tz + camera_z + 0.2) < fabsf(vect[2]) - 0.01)
if (fabsf(tz + camera_z + 0.2f) < fabsf(vect[2]) - 0.01)
rx = -90.0 + 180.0 * asinf((tz + camera_z + 0.2) / vect[2]) / M_PI;
}
else if (new_zoom_level > old_zoom_level)
Expand All @@ -500,7 +500,7 @@ void update_camera()
new_zoom_level = old_zoom_level;
camera_tilt_duration = camera_zoom_duration = 0;
camera_tilt_speed = 0.0;
if (fabsf(tz + camera_z + 0.2) < fabsf(vect[2]) - 0.01)
if (fabsf(tz + camera_z + 0.2f) < fabsf(vect[2]) - 0.01)
rx = -90.0 + 180.0 * asinf((tz + camera_z + 0.2) / vect[2]) / M_PI;
}
}
Expand Down
4 changes: 2 additions & 2 deletions io/fileutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "../xz/7zCrc.h"
#include "../xz/XzCrc64.h"

static void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); }
static void SzFree(void *p, void *address) { p = p; free(address); }
static void *SzAlloc(void *p, size_t size) { return malloc(size); }
static void SzFree(void *p, void *address) { free(address); }
static ISzAlloc lzmaAlloc = { SzAlloc, SzFree };

void init_crc_tables()
Expand Down
2 changes: 1 addition & 1 deletion new_actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void add_enhanced_actor_from_server (const char *in_data, int len)
my_strncp(this_actor->hair_tex,actors_defs[actor_type].hair[hair].hair_name,sizeof(this_actor->hair_tex));
#ifdef NEW_EYES
//eyes
if (actors_defs[actor_type].eyes && actors_defs[actor_type].eyes[eyes].eyes_name)
if (actors_defs[actor_type].eyes && *actors_defs[actor_type].eyes[eyes].eyes_name != '\0')
{
my_strncp(this_actor->eyes_tex,actors_defs[actor_type].eyes[eyes].eyes_name,sizeof(this_actor->eyes_tex));
}
Expand Down
4 changes: 2 additions & 2 deletions particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ static __inline__ void calc_particle_random_min_max(float f1, float f2, float* v

static __inline__ void calc_particle_random2_min_max(float f1, float f2, float* v_min, float* v_max)
{
*v_min = (f1+f2)*0.5f-abs(f2-f1);
*v_max = (f1+f2)*0.5f+abs(f2-f1);
*v_min = (f1+f2)*0.5f-fabsf(f2-f1);
*v_max = (f1+f2)*0.5f+fabsf(f2-f1);
}

void calc_bounding_box_for_particle_sys(AABBOX* bbox, particle_sys *system_id)
Expand Down
2 changes: 1 addition & 1 deletion popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void popup_add_option_displaytext(popup_t *this_popup,
popup_option_group_t group_id,
const char *const text)
{
popup_option_value_t dummy_value;
popup_option_value_t dummy_value = (popup_option_value_t){0};
popup_add_option_extended( this_popup, group_id, text, dummy_value, OPTION_TYPE_DISPLAYTEXT );
}

Expand Down
6 changes: 3 additions & 3 deletions spells.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ static int mouseover_sigils_handler(window_info *win, int mx, int my)

static void set_spell_help_text(int spell){

char clr[4];
unsigned char clr[4];

if (spell<0) {
spell_help[0]=0;
Expand All @@ -1446,13 +1446,13 @@ static void set_spell_help_text(int spell){
clr[0]=127+c_red2;
clr[1]=clr[2]=' ';
clr[3]=0;
safe_strcat((char*)spell_help,clr,sizeof(spell_help));
safe_strcat((char*)spell_help,(char*)clr,sizeof(spell_help));
safe_strcat((char*)spell_help,GET_UNCASTABLE_STR(spells_list[spell].uncastable),sizeof(spell_help));
}
safe_strcat((char*)spell_help,"\n",sizeof(spell_help));
clr[0]=127+c_grey1;
clr[1]=0;
safe_strcat((char*)spell_help,clr,sizeof(spell_help));
safe_strcat((char*)spell_help,(char*)clr,sizeof(spell_help));
safe_strcat((char*)spell_help,spells_list[spell].desc,sizeof(spell_help));

}
Expand Down
2 changes: 0 additions & 2 deletions xz/LzmaEnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2079,8 +2079,6 @@ void LzmaEnc_Finish(CLzmaEncHandle pp)
CLzmaEnc *p = (CLzmaEnc *)pp;
if (p->mtMode)
MatchFinderMt_ReleaseStream(&p->matchFinderMt);
#else
pp = pp;
#endif
}

Expand Down
5 changes: 1 addition & 4 deletions xz/XzDec.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ void BraState_Free(void *pp, ISzAlloc *alloc)
SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
{
CBraState *p = ((CBraState *)pp);
alloc = alloc;
p->encodeMode = 0;
p->ip = 0;
if (p->methodId == XZ_ID_Delta)
Expand Down Expand Up @@ -129,7 +128,6 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
SizeT srcLenOrig = *srcLen;
*destLen = 0;
*srcLen = 0;
finishMode = finishMode;
*wasFinished = 0;
while (destLenOrig > 0)
{
Expand Down Expand Up @@ -295,8 +293,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
{
ELzmaStatus status;
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, finishMode, &status);
srcWasFinished = srcWasFinished;
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status);
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
return res;
}
Expand Down
8 changes: 4 additions & 4 deletions xz/XzEnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

#include "XzEnc.h"

static void *SzBigAlloc(void *p, size_t size) { p = p; return BigAlloc(size); }
static void SzBigFree(void *p, void *address) { p = p; BigFree(address); }
static void *SzBigAlloc(void *p, size_t size) { return BigAlloc(size); }
static void SzBigFree(void *p, void *address) { BigFree(address); }
static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };

static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
static void *SzAlloc(void *p, size_t size) { return MyAlloc(size); }
static void SzFree(void *p, void *address) { MyFree(address); }
static ISzAlloc g_Alloc = { SzAlloc, SzFree };

#define XzBlock_ClearFlags(p) (p)->flags = 0;
Expand Down

0 comments on commit 2a392ef

Please sign in to comment.