From c5780deadbda31d4a76e7f4ded866d769c2a1151 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 15 Sep 2016 15:29:16 +0200 Subject: Fixed some issues detected by clang's static analyzer (Xcode 8/macOS Sierra) Signed-off-by: Haru --- src/common/HPM.c | 2 +- src/common/socket.c | 4 ---- src/common/timer.c | 4 ---- src/map/battle.c | 6 ++---- src/map/clif.c | 5 +---- src/map/path.c | 2 -- src/map/script.c | 2 -- 7 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/common/HPM.c b/src/common/HPM.c index c34828010..ff1371b14 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -898,7 +898,7 @@ bool hplugins_parse_conf(const struct config_t *config, const char *filename, en for (i = 0; i < VECTOR_LENGTH(HPM->config_listeners[point]); i++) { const struct HPConfListenStorage *entry = &VECTOR_INDEX(HPM->config_listeners[point], i); const char *config_name = entry->key; - const char *str = buf; + const char *str = NULL; if ((setting = libconfig->lookup(config, config_name)) == NULL) { if (!imported && entry->required) { ShowWarning("Missing configuration '%s' in file %s!\n", config_name, filename); diff --git a/src/common/socket.c b/src/common/socket.c index 5f284587a..d4b8bb43f 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1023,10 +1023,6 @@ int do_sockets(int next) } } -#ifdef __clang_analyzer__ - // Let Clang's static analyzer know this never happens (it thinks it might because of a NULL check in session_is_valid) - if (!sockt->session[i]) continue; -#endif // __clang_analyzer__ sockt->session[i]->func_parse(i); if(!sockt->session[i]) diff --git a/src/common/timer.c b/src/common/timer.c index 0b28f6a06..f820ebe12 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -258,10 +258,6 @@ int64 timer_gettick(void) { /// Adds a timer to the timer_heap static void push_timer_heap(int tid) { BHEAP_ENSURE(timer_heap, 1, 256); -#ifdef __clang_analyzer__ // Clang's static analyzer warns that BHEAP_ENSURE might set BHEAP_DATA(timer_heap) to NULL. -#include "assert.h" - assert(BHEAP_DATA(timer_heap) != NULL); -#endif // __clang_analyzer__ BHEAP_PUSH(timer_heap, tid, DIFFTICK_MINTOPCMP, swap); } diff --git a/src/map/battle.c b/src/map/battle.c index daef8f6a8..67ab8c9b8 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6008,20 +6008,18 @@ int battle_damage_area(struct block_list *bl, va_list ap) { if (bl->type == BL_MOB && BL_UCCAST(BL_MOB, bl)->class_ == MOBID_EMPELIUM) return 0; if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { - struct map_session_data *sd = NULL; nullpo_ret(src); map->freeblock_lock(); - sd = BL_CAST(BL_PC, src); if (src->type == BL_PC) - battle->drain(sd, bl, damage, damage, status_get_race(bl), is_boss(bl)); + battle->drain(BL_UCAST(BL_PC, src), bl, damage, damage, status_get_race(bl), is_boss(bl)); if( amotion ) battle->delay_damage(tick, amotion,src,bl,0,CR_REFLECTSHIELD,0,damage,ATK_DEF,0,true); else status_fix_damage(src,bl,damage,0); clif->damage(bl,bl,amotion,dmotion,damage,1,BDT_ENDURE,0); - if (src->type != BL_PC || !sd->state.autocast) + if (src->type != BL_PC || !BL_UCCAST(BL_PC, src)->state.autocast) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); map->freeblock_unlock(); } diff --git a/src/map/clif.c b/src/map/clif.c index 040f86a58..3e6b4937b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3249,10 +3249,7 @@ void clif_changelook(struct block_list *bl,int type,int val) #endif break; case LOOK_BODY2: - if (val && ( - sd->sc.option&OPTION_WEDDING || sd->sc.option&OPTION_XMAS || - sd->sc.option&OPTION_SUMMER || sd->sc.option&OPTION_HANBOK || - sd->sc.option&OPTION_OKTOBERFEST)) + if (sd != NULL && (sd->sc.option&OPTION_COSTUME) != OPTION_NOTHING) val = 0; vd->body_style = val; break; diff --git a/src/map/path.c b/src/map/path.c index f5e08d4df..07b38b740 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -192,10 +192,8 @@ bool path_search_long(struct shootpath_data *spd,struct block_list *bl,int16 m,i /// Ensures there is enough space in array to store new element. static void heap_push_node(struct node_heap *heap, struct path_node *node) { -#ifndef __clang_analyzer__ // TODO: Figure out why clang's static analyzer doesn't like this BHEAP_ENSURE(*heap, 1, 256); BHEAP_PUSH2(*heap, node, NODE_MINTOPCMP, swap_ptr); -#endif // __clang_analyzer__ } /// Updates path_node in the binary node_heap. diff --git a/src/map/script.c b/src/map/script.c index a1efbb3b8..d1aee29bf 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5482,8 +5482,6 @@ bool script_sprintf(struct script_state *st, int start, struct StringBuf *out) safestrncpy(buf, p, len); StrBuf->AppendStr(out, buf); } - - p = np; np++; // placeholder = "%%" ; (special case) -- cgit v1.2.3-60-g2f50