diff options
author | Haru <haru@dotalux.com> | 2015-12-26 02:28:59 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-05-08 19:53:57 +0200 |
commit | 2349b2a1528fe5dc41d930f8dd332df5ba521eb6 (patch) | |
tree | 3656a91a896f0ef090606b2b4c9184ad73153a3f | |
parent | 58a7bf46508b7f186704e7efb39576e09f0ab866 (diff) | |
download | hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.gz hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.bz2 hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.xz hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.zip |
Fixed various issues pointed out by cppcheck
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/char/char.c | 2 | ||||
-rw-r--r-- | src/char/geoip.c | 5 | ||||
-rw-r--r-- | src/char/inter.c | 2 | ||||
-rw-r--r-- | src/common/grfio.c | 2 | ||||
-rw-r--r-- | src/common/memmgr.c | 6 | ||||
-rw-r--r-- | src/common/showmsg.c | 13 | ||||
-rw-r--r-- | src/common/sql.c | 2 | ||||
-rw-r--r-- | src/map/battle.c | 5 | ||||
-rw-r--r-- | src/map/clif.c | 2 | ||||
-rw-r--r-- | src/map/instance.c | 9 | ||||
-rw-r--r-- | src/map/path.c | 8 | ||||
-rw-r--r-- | src/map/pc.c | 23 | ||||
-rw-r--r-- | src/map/script.c | 54 | ||||
-rw-r--r-- | src/map/skill.c | 8 | ||||
-rw-r--r-- | src/map/status.c | 13 | ||||
-rw-r--r-- | src/plugins/dbghelpplug.c | 28 | ||||
-rw-r--r-- | src/test/test_libconfig.c | 6 | ||||
-rw-r--r-- | src/test/test_spinlock.c | 4 |
18 files changed, 92 insertions, 100 deletions
diff --git a/src/char/char.c b/src/char/char.c index 8f3d5b0c9..cf2f7d87c 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1890,7 +1890,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { //When the weapon is sent and your option is riding, the client crashes on login!? // FIXME[Haru]: is OPTION_HANBOK intended to be part of this list? And if it is, should the list also include other OPTION_ costumes? - WBUFW(buf,56) = p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK) ? 0 : p->weapon; + WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->weapon; WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); diff --git a/src/char/geoip.c b/src/char/geoip.c index 433ff0918..002045850 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -132,9 +132,8 @@ void geoip_final(bool shutdown) **/ void geoip_init(void) { - int i, fno; + int fno; char db_type = 1; - unsigned char delim[3]; struct stat bufa; FILE *db; @@ -165,6 +164,8 @@ void geoip_init(void) if (fseek(db, -3l, SEEK_END) != 0) { db_type = 0; } else { + int i; + unsigned char delim[3]; for (i = 0; i < GEOIP_STRUCTURE_INFO_MAX_SIZE; i++) { if (fread(delim, sizeof(delim[0]), 3, db) != 3) { db_type = 0; diff --git a/src/char/inter.c b/src/char/inter.c index 8f7f5c144..d277abec9 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -1085,7 +1085,6 @@ int mapif_parse_broadcast(int fd) int mapif_parse_WisRequest(int fd) { struct WisData* wd; - static int wisid = 0; char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1];// escaped name char* data; @@ -1125,6 +1124,7 @@ int mapif_parse_WisRequest(int fd) } else { + static int wisid = 0; CREATE(wd, struct WisData, 1); // Whether the failure of previous wisp/page transmission (timeout) diff --git a/src/common/grfio.c b/src/common/grfio.c index 678875c91..c6e47d357 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -410,12 +410,12 @@ void *grfio_reads(const char *fname, int *size) // LocalFileCheck char lfname[256]; FILE *in; - unsigned char *buf = NULL; grfio_localpath_create(lfname, sizeof(lfname), (entry && entry->fnd) ? entry->fnd : fname); in = fopen(lfname, "rb"); if (in != NULL) { int declen; + unsigned char *buf = NULL; fseek(in,0,SEEK_END); declen = (int)ftell(in); if (declen == -1) { diff --git a/src/common/memmgr.c b/src/common/memmgr.c index 15e55fbeb..dfea24465 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -154,8 +154,8 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f #ifdef USE_MEMMGR ret = REALLOC(p, size, file, line, func); #else - size_t newSize; - if (p) { + if (p != NULL) { + size_t newSize; size_t oldSize = BUFFER_SIZE(p); ret = REALLOC(p, size, file, line, func); newSize = BUFFER_SIZE(ret); @@ -167,7 +167,7 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f memset(ret, 0, BUFFER_SIZE(ret)); } #endif - if (ret == NULL){ + if (ret == NULL) { ShowFatalError("%s:%d: in func %s: aRealloc error out of memory!\n",file,line,func); exit(EXIT_FAILURE); } diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 1c1d4ca8b..8ed8efc1d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -244,13 +244,13 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) continue; } else if (*q == ';') { // delimiter - if (numpoint < sizeof(numbers)/sizeof(*numbers)) { + if (numpoint < ARRAYLENGTH(numbers)) { // go to next array position numpoint++; } else { // array is full, so we 'forget' the first value - memmove(numbers,numbers+1,sizeof(numbers)/sizeof(*numbers)-1); - numbers[sizeof(numbers)/sizeof(*numbers)-1]=0; + memmove(numbers, numbers+1, ARRAYLENGTH(numbers)-1); + numbers[ARRAYLENGTH(numbers)-1]=0; } ++q; // and next number @@ -605,9 +605,6 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) { va_list apcopy; char prefix[100]; -#if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) - FILE *fp; -#endif if (!string || *string == '\0') { ShowError("Empty string passed to vShowMessage_().\n"); @@ -702,8 +699,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) } #if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) - if(strlen(DEBUGLOGPATH) > 0) { - fp=fopen(DEBUGLOGPATH,"a"); + if (strlen(DEBUGLOGPATH) > 0) { + FILE *fp = fopen(DEBUGLOGPATH,"a"); if (fp == NULL) { FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', access denied.\n", DEBUGLOGPATH); FFLUSH(STDERR); diff --git a/src/common/sql.c b/src/common/sql.c index 1eae1b29b..ef8cde536 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -880,10 +880,10 @@ void SqlStmt_Free(struct SqlStmt *self) } /* receives mysql error codes during runtime (not on first-time-connects) */ void hercules_mysql_error_handler(unsigned int ecode) { - static unsigned int retry = 1; switch( ecode ) { case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */ if( mysql_reconnect_type == 1 ) { + static unsigned int retry = 1; if( ++retry > mysql_reconnect_count ) { ShowFatalError("MySQL has been unreachable for too long, %u reconnects were attempted. Shutting Down\n", retry); exit(EXIT_FAILURE); diff --git a/src/map/battle.c b/src/map/battle.c index a7a6f4719..09b99aa05 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3512,8 +3512,6 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) { struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) { int nk; short s_ele = 0; - unsigned int skillratio = 100; //Skill dmg modifiers. - struct map_session_data *sd = NULL; struct status_change *sc; struct Damage ad; @@ -3666,6 +3664,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage = status->get_lv(src) * 10 + sstatus->int_; break; default: { + unsigned int skillratio = 100; //Skill dmg modifiers. MATK_ADD( status->get_matk(src, 2) ); #ifdef RENEWAL ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); @@ -4276,7 +4275,6 @@ void battle_calc_misc_attack_unknown(struct block_list *src, struct block_list * // FIXME: wflag is undocumented struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag) { - unsigned int skillratio = 100; //Skill dmg modifiers. short temp=0; short s_ele, s_ele_; int i, nk; @@ -4775,6 +4773,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } //End hit/miss calculation if (flag.hit && !flag.infdef) { //No need to do the math for plants + unsigned int skillratio = 100; //Skill dmg modifiers. //Hitting attack //Assuming that 99% of the cases we will not need to check for the flag.rh... we don't. diff --git a/src/map/clif.c b/src/map/clif.c index cf742fbf6..9b90b946e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -14771,7 +14771,6 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) { int mail_id = RFIFOL(fd,2); int i; - bool fail = false; if( !chrif->isconnected() ) return; @@ -14795,6 +14794,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) if( sd->mail.inbox.msg[i].item.nameid > 0 ) { struct item_data *data; unsigned int weight; + bool fail = false; if ((data = itemdb->exists(sd->mail.inbox.msg[i].item.nameid)) == NULL) return; diff --git a/src/map/instance.c b/src/map/instance.c index a6700d486..fa2cfec16 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -551,7 +551,7 @@ void instance_destroy(int instance_id) { struct party_data *p = NULL; struct guild *g = NULL; short *iptr = NULL; - int type, j; + int type; unsigned int now = (unsigned int)time(NULL); if( !instance->valid(instance_id) ) @@ -596,9 +596,10 @@ void instance_destroy(int instance_id) { } if( iptr != NULL ) { - ARR_FIND(0, *icptr, j, iptr[j] == instance_id); - if( j != *icptr ) - iptr[j] = -1; + int i; + ARR_FIND(0, *icptr, i, iptr[i] == instance_id); + if (i != *icptr) + iptr[i] = -1; } if (instance->list[instance_id].map) { diff --git a/src/map/path.c b/src/map/path.c index 543497c33..0df9708d8 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -254,7 +254,7 @@ static int add_path(struct node_heap *heap, struct path_node *tp, int16 x, int16 *------------------------------------------*/ bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell) { - register int i, j, x, y, dx, dy; + register int i, x, y, dx, dy; struct map_data *md; struct walkpath_data s_wpd; @@ -315,8 +315,7 @@ bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int1 } return false; // easy path unsuccessful - } - else { // !(flag&1) + } else { // !(flag&1) // A* (A-star) pathfinding // We always use A* for finding walkpaths because it is what game client uses. // Easy pathfinding cuts corners of non-walkable cells, but client always walks around it. @@ -331,6 +330,7 @@ bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int1 int xs = md->xs - 1; int ys = md->ys - 1; int len = 0; + int j; memset(tp, 0, sizeof(tp)); // Start node @@ -407,7 +407,7 @@ bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int1 } for (it = current; it->parent != NULL; it = it->parent, len++); - if (len > sizeof(wpd->path)) { + if (len > (int)sizeof(wpd->path)) { return false; } diff --git a/src/map/pc.c b/src/map/pc.c index ab1e6ebfc..1c635e5cf 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -11014,18 +11014,18 @@ int pc_readdb(void) { ShowError("can't read %s\n", line); return 1; } - while(fgets(line, sizeof(line), fp)) - { + while (fgets(line, sizeof(line), fp)) { char *split[10]; int lv,n; - if(line[0]=='/' && line[1]=='/') + if (line[0]=='/' && line[1]=='/') continue; - for(j=0,p=line;j<3 && p;j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; + for (j = 0, p = line; j < 3 && p != NULL; j++) { + split[j] = p; + p = strchr(p,','); + if (p != NULL) + *p++ = 0; } - if( j < 2 ) + if (j < 2) continue; lv=atoi(split[0]); @@ -11037,8 +11037,8 @@ int pc_readdb(void) { if(line[0]=='/' && line[1]=='/') continue; - for ( j = ELE_NEUTRAL, p = line; j<n && j<ELE_MAX && p; j++ ) { - while(*p==32 && *p>0) + for (j = ELE_NEUTRAL, p = line; j < n && j < ELE_MAX && p != NULL; j++) { + while (*p == ' ') p++; battle->attr_fix_table[lv-1][i][j]=atoi(p); #ifndef RENEWAL @@ -11046,7 +11046,8 @@ int pc_readdb(void) { battle->attr_fix_table[lv-1][i][j] = 0; #endif p=strchr(p,','); - if(p) *p++=0; + if (p != NULL) + *p++ = 0; } i++; diff --git a/src/map/script.c b/src/map/script.c index 181ff350f..a5e45f503 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2699,13 +2699,13 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o #endif #ifdef SCRIPT_DEBUG_DISASM i = 0; - while(i < script->pos) { - int j = i; - c_op op = script->get_com(script->buf,&i); + while (i < script->pos) { + c_op op = script->get_com(script->buf, &i); + int j = i; // Note: i is modified in the line above. ShowMessage("%06x %s", i, script->op2name(op)); - j = i; - switch(op) { + + switch (op) { case C_INT: ShowMessage(" %d", script->get_num(script->buf,&i)); break; @@ -3834,7 +3834,7 @@ void op_2str(struct script_state* st, int op, const char* s1, const char* s2) pcre *compiled_regex; pcre_extra *extra_regex; const char *pcre_error, *pcre_match; - int pcre_erroroffset, offsetcount, i; + int pcre_erroroffset, offsetcount; int offsets[256*3]; // (max_capturing_groups+1)*3 compiled_regex = libpcre->compile(s2, 0, &pcre_error, &pcre_erroroffset, NULL); @@ -3875,8 +3875,9 @@ void op_2str(struct script_state* st, int op, const char* s1, const char* s2) return; } - if( op == C_RE_EQ ) { - for( i = 0; i < offsetcount; i++ ) { + if (op == C_RE_EQ) { + int i; + for (i = 0; i < offsetcount; i++) { libpcre->get_substring(s1, offsets, offsetcount, i, &pcre_match); mapreg->setregstr(reference_uid(script->add_str("$@regexmatch$"), i), pcre_match); libpcre->free_substring(pcre_match); @@ -4920,7 +4921,7 @@ void script_load_translations(void) { libconfig->destroy(&translations_conf); if( total ) { - struct DBIterator *main_iter, *sub_iter; + struct DBIterator *main_iter; struct DBMap *string_db; struct string_translation *st = NULL; uint32 j = 0; @@ -4929,9 +4930,9 @@ void script_load_translations(void) { script->translation_buf_size = total; main_iter = db_iterator(script->translation_db); - for( string_db = dbi_first(main_iter); dbi_exists(main_iter); string_db = dbi_next(main_iter) ) { - sub_iter = db_iterator(string_db); - for( st = dbi_first(sub_iter); dbi_exists(sub_iter); st = dbi_next(sub_iter) ) { + for (string_db = dbi_first(main_iter); dbi_exists(main_iter); string_db = dbi_next(main_iter)) { + struct DBIterator *sub_iter = db_iterator(string_db); + for (st = dbi_first(sub_iter); dbi_exists(sub_iter); st = dbi_next(sub_iter)) { script->translation_buf[j++] = st->buf; } dbi_destroy(sub_iter); @@ -4956,8 +4957,8 @@ void script_load_translations(void) { /** * **/ -const char * script_get_translation_file_name(const char *file) { - static char file_name[200]; +const char *script_get_translation_file_name(const char *file) +{ int i, len = (int)strlen(file), last_bar = -1, last_dot = -1; for(i = 0; i < len; i++) { @@ -4968,6 +4969,7 @@ const char * script_get_translation_file_name(const char *file) { } if( last_bar != -1 || last_dot != -1 ) { + static char file_name[200]; if( last_bar != -1 && last_dot < last_bar ) last_dot = -1; safestrncpy(file_name, file+(last_bar >= 0 ? last_bar+1 : 0), ( last_dot >= 0 ? ( last_bar >= 0 ? last_dot - last_bar : last_dot ) : sizeof(file_name) )); @@ -4999,7 +5001,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) { atcommand->expand_message_table(); while(fgets(line, sizeof(line), fp)) { - size_t len = strlen(line), cursor = 0; + size_t len = strlen(line); if( len <= 1 ) continue; @@ -5008,6 +5010,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) { continue; if( strncasecmp(line,"msgctxt \"", 9) == 0 ) { + int cursor = 0; msgctxt[0] = '\0'; for(i = 9; i < len - 2; i++) { if( line[i] == '\\' && line[i+1] == '"' ) { @@ -5015,7 +5018,7 @@ void script_load_translation(const char *file, uint8 lang_id, uint32 *total) { i++; } else msgctxt[cursor] = line[i]; - if( ++cursor >= sizeof(msgctxt) - 1 ) + if (++cursor >= (int)sizeof(msgctxt) - 1) break; } msgctxt[cursor] = '\0'; @@ -18643,22 +18646,11 @@ BUILDIN(getcharip) { return false; } - /* check for IP */ - if (!sockt->session[sd->fd]->client_addr) { + if (sd->fd == 0 || sockt->session[sd->fd] == NULL || sockt->session[sd->fd]->client_addr == 0) { script_pushconststr(st, ""); - return true; - } - - /* return the client ip_addr converted for output */ - if (sd && sd->fd && sockt->session[sd->fd]) - { - /* initiliaze */ - const char *ip_addr = NULL; - uint32 ip; - - /* set ip, ip_addr and convert to ip and push str */ - ip = sockt->session[sd->fd]->client_addr; - ip_addr = sockt->ip2str(ip, NULL); + } else { + uint32 ip = sockt->session[sd->fd]->client_addr; + const char *ip_addr = sockt->ip2str(ip, NULL); script_pushstrcopy(st, ip_addr); } diff --git a/src/map/skill.c b/src/map/skill.c index 3004bf0e9..51d0792e3 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -15995,14 +15995,14 @@ int skill_enchant_elemental_end (struct block_list *bl, int type) { bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce) { - static int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1}; - static int dy[] = {-1, 0, 1, 0, -1, -1, 1, 1}; bool wall = true; if( (bl->type == BL_PC && battle_config.pc_cloak_check_type&1) || (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) ) { //Check for walls. + static int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1}; + static int dy[] = {-1, 0, 1, 0, -1, -1, 1, 1}; int i; ARR_FIND( 0, 8, i, map->getcell(bl->m, bl, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) @@ -16060,11 +16060,11 @@ int skill_check_cloaking_end(struct block_list *bl, va_list ap) bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *sce) { - static int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1}; - static int dy[] = {-1, 0, 1, 0, -1, -1, 1, 1}; bool wall = true; if( bl->type == BL_PC ) { //Check for walls. + static int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1}; + static int dy[] = {-1, 0, 1, 0, -1, -1, 1, 1}; int i; ARR_FIND( 0, 8, i, map->getcell(bl->m, bl, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) diff --git a/src/map/status.c b/src/map/status.c index 39bb25737..34bfd06b5 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -11613,7 +11613,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { if( --(sce->val4) > 0 ) { struct block_list *src = map->id2bl(sce->val2); int damage; - if( !src || (src && (status->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) ) + if (src == NULL || (status->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) break; map->freeblock_lock(); damage = sce->val3; @@ -12964,7 +12964,7 @@ int status_readdb_refine_libconfig(const char *filename) { struct config_t refine_db_conf; struct config_setting_t *r; char filepath[256]; - int i = 0, count = 0,type = 0; + int i = 0, count = 0; sprintf(filepath, "%s/%s", map->db_path, filename); if (!libconfig->load_file(&refine_db_conf, filepath)) @@ -12974,10 +12974,13 @@ int status_readdb_refine_libconfig(const char *filename) { while((r = libconfig->setting_get_elem(refine_db_conf.root,i++))) { char *name = config_setting_name(r); - if((type=status->readdb_refine_libconfig_sub(r, name, filename))) { - if( duplicate[type-1] ) { + int type = status->readdb_refine_libconfig_sub(r, name, filename); + if (type != 0) { + if (duplicate[type-1]) { ShowWarning("status_readdb_refine_libconfig: duplicate entry for %s in \"%s\", overwriting previous entry...\n", name, filename); - } else duplicate[type-1] = true; + } else { + duplicate[type-1] = true; + } count++; } } diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index 6c02b1a12..cf8be0901 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -446,17 +446,17 @@ Dhp__PrintProcessInfo( fprintf(log_file, "eip=%08x esp=%08x ebp=%08x iopl=%1x %s %s %s %s %s %s %s %s %s %s\n", context->Eip, context->Esp, context->Ebp, - (context->EFlags >> 12) & 3, // IOPL level value - context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending) - context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag) - context->EFlags & 0x00000800 ? "ov" : "nv", // VIF (virtual interrupt flag) - context->EFlags & 0x00000400 ? "dn" : "up", // OF (overflow flag) - context->EFlags & 0x00000200 ? "ei" : "di", // IF (interrupt enable flag) - context->EFlags & 0x00000080 ? "ng" : "pl", // SF (sign flag) - context->EFlags & 0x00000040 ? "zr" : "nz", // ZF (zero flag) - context->EFlags & 0x00000010 ? "ac" : "na", // AF (aux carry flag) - context->EFlags & 0x00000004 ? "po" : "pe", // PF (parity flag) - context->EFlags & 0x00000001 ? "cy" : "nc"); // CF (carry flag) + (context->EFlags >> 12) & 3, // IOPL level value + (context->EFlags & 0x00100000) ? "vip" : " ", // VIP (virtual interrupt pending) + (context->EFlags & 0x00080000) ? "vif" : " ", // VIF (virtual interrupt flag) + (context->EFlags & 0x00000800) ? "ov" : "nv", // VIF (virtual interrupt flag) + (context->EFlags & 0x00000400) ? "dn" : "up", // OF (overflow flag) + (context->EFlags & 0x00000200) ? "ei" : "di", // IF (interrupt enable flag) + (context->EFlags & 0x00000080) ? "ng" : "pl", // SF (sign flag) + (context->EFlags & 0x00000040) ? "zr" : "nz", // ZF (zero flag) + (context->EFlags & 0x00000010) ? "ac" : "na", // AF (aux carry flag) + (context->EFlags & 0x00000004) ? "po" : "pe", // PF (parity flag) + (context->EFlags & 0x00000001) ? "cy" : "nc"); // CF (carry flag) } if( context->ContextFlags & CONTEXT_SEGMENTS ) { @@ -467,8 +467,7 @@ Dhp__PrintProcessInfo( context->SegDs, context->SegEs, context->SegFs, - context->SegGs, - context->EFlags); + context->SegGs); if( context->ContextFlags & CONTEXT_CONTROL ) fprintf(log_file, " efl=%08x", @@ -951,7 +950,6 @@ Dhp__PrintDataValue( // ULONG64 length = 0; DWORD basetype; - BOOL isValid = TRUE; assert( pInterData != NULL ); log_file = pInterData->log_file; @@ -1260,7 +1258,7 @@ Dhp__PrintDataInfo( } else if( pSymInfo->Flags & SYMFLAG_REGISTER ) { - scope = ( pSymInfo->Flags & SYMFLAG_PARAMETER ? PARAM : LOCAL ); // register, optimized out(?) + scope = (pSymInfo->Flags & SYMFLAG_PARAMETER) ? PARAM : LOCAL; // register, optimized out(?) } else { diff --git a/src/test/test_libconfig.c b/src/test/test_libconfig.c index a3b233b98..e0a470e21 100644 --- a/src/test/test_libconfig.c +++ b/src/test/test_libconfig.c @@ -113,6 +113,7 @@ static const char *test_libconfig_read(void) libconfig->destroy(&config); return "Unable to read from file '" FILENAME "'."; } + fclose(fp); #undef FILENAME if (config.root == NULL) { libconfig->destroy(&config); @@ -200,7 +201,6 @@ static const char *test_libconfig_set_include_dir(void) static const char *test_libconfig_lookup(void) { struct config_t config; - struct config_setting_t *t = NULL; int32 i32; int64 i64; double f; @@ -221,12 +221,12 @@ static const char *test_libconfig_lookup(void) return "Unable to parse configuration."; } - if ((t = libconfig->lookup(&config, "Setting_Int")) == NULL) { + if (libconfig->lookup(&config, "Setting_Int") == NULL) { libconfig->destroy(&config); return "libconfig->lookup failed."; } - if ((t = libconfig->setting_lookup(config.root, "Setting_Int")) == NULL) { + if (libconfig->setting_lookup(config.root, "Setting_Int") == NULL) { libconfig->destroy(&config); return "libconfig->setting_lookup failed."; } diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c index 38186a975..6ffc4eafc 100644 --- a/src/test/test_spinlock.c +++ b/src/test/test_spinlock.c @@ -91,9 +91,9 @@ int do_init(int argc, char **argv){ // Everything fine? if (val != (THRC*PERINC)) { - printf("FAILED! (Result: %u, Expected: %u)\n", val, (THRC*PERINC)); + printf("FAILED! (Result: %u, Expected: %d)\n", val, (THRC*PERINC)); } else { - printf("OK! (Result: %u, Expected: %u)\n", val, (THRC*PERINC)); + printf("OK! (Result: %u, Expected: %d)\n", val, (THRC*PERINC)); ok++; } |