diff options
author | Haru <haru@dotalux.com> | 2016-01-09 21:44:27 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-01-09 21:44:27 +0100 |
commit | e248c3394d7a2a76cfb39e0955ebab648ecc2bf0 (patch) | |
tree | 31d8b0b7de923cff4a49131b82a6ff4de2fd2769 | |
parent | 10f9f4282097f177d6ee0b26572dcf4308e6d6fb (diff) | |
download | hercules-e248c3394d7a2a76cfb39e0955ebab648ecc2bf0.tar.gz hercules-e248c3394d7a2a76cfb39e0955ebab648ecc2bf0.tar.bz2 hercules-e248c3394d7a2a76cfb39e0955ebab648ecc2bf0.tar.xz hercules-e248c3394d7a2a76cfb39e0955ebab648ecc2bf0.zip |
Sanitized various macros
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/common/db.c | 2 | ||||
-rw-r--r-- | src/common/db.h | 4 | ||||
-rw-r--r-- | src/common/ers.h | 14 | ||||
-rw-r--r-- | src/common/memmgr.c | 22 | ||||
-rw-r--r-- | src/common/memmgr.h | 2 | ||||
-rw-r--r-- | src/common/showmsg.c | 2 | ||||
-rw-r--r-- | src/common/sql.h | 4 | ||||
-rw-r--r-- | src/common/sysinfo.c | 2 | ||||
-rw-r--r-- | src/config/const.h | 6 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/homunculus.h | 2 |
11 files changed, 31 insertions, 31 deletions
diff --git a/src/common/db.c b/src/common/db.c index 361e212cb..ca9a70f7c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -353,7 +353,7 @@ static struct db_stats { }; #define DB_COUNTSTAT(token) do { if ((stats.token) != UINT32_MAX) ++(stats.token); } while(0) #else /* !defined(DB_ENABLE_STATS) */ -#define DB_COUNTSTAT(token) +#define DB_COUNTSTAT(token) (void)0 #endif /* !defined(DB_ENABLE_STATS) */ /* [Ind/Hercules] */ diff --git a/src/common/db.h b/src/common/db.h index 205288f13..b73970947 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -1717,7 +1717,7 @@ HPShared struct db_interface *DB; * @return negative if v1 is top, positive if v2 is top, 0 if equal. */ #define BHEAP_MINTOPCMP(v1, v2) \ - ( v1 == v2 ? 0 : v1 < v2 ? -1 : 1 ) + ( (v1) == (v2) ? 0 : (v1) < (v2) ? -1 : 1 ) /** * Generic comparator for a max-heap (maximum value at top). @@ -1732,6 +1732,6 @@ HPShared struct db_interface *DB; * @return negative if v1 is top, positive if v2 is top, 0 if equal. */ #define BHEAP_MAXTOPCMP(v1, v2) \ - ( v1 == v2 ? 0 : v1 > v2 ? -1 : 1 ) + ( (v1) == (v2) ? 0 : (v1) > (v2) ? -1 : 1 ) #endif /* COMMON_DB_H */ diff --git a/src/common/ers.h b/src/common/ers.h index 938882edd..1689345dc 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -148,15 +148,15 @@ typedef struct eri { #ifdef DISABLE_ERS // Use memory manager to allocate/free and disable other interface functions -# define ers_alloc(obj,type) (type *)aMalloc(sizeof(type)) -# define ers_free(obj,entry) aFree(entry) -# define ers_entry_size(obj) (size_t)0 -# define ers_destroy(obj) -# define ers_chunk_size(obj,size) +# define ers_alloc(obj,type) ((void)(obj), (type *)aMalloc(sizeof(type))) +# define ers_free(obj,entry) ((void)(obj), aFree(entry)) +# define ers_entry_size(obj) ((void)(obj), (size_t)0) +# define ers_destroy(obj) ((void)(obj), (void)0) +# define ers_chunk_size(obj,size) ((void)(obj), (void)(size), (size_t)0) // Disable the public functions # define ers_new(size,name,options) NULL -# define ers_report() -# define ers_final() +# define ers_report() (void)0 +# define ers_final() (void)0 #else /* not DISABLE_ERS */ // These defines should be used to allow the code to keep working whenever // the system is disabled diff --git a/src/common/memmgr.c b/src/common/memmgr.c index 97991ceaa..93c23ff18 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -45,7 +45,7 @@ struct malloc_interface *iMalloc; # define REALLOC(p,n,file,line,func) mwRealloc((p),(n),(file),(line)) # define STRDUP(p,file,line,func) mwStrdup((p),(file),(line)) # define FREE(p,file,line,func) mwFree((p),(file),(line)) -# define MEMORY_USAGE() (size_t)0 +# define MEMORY_USAGE() ((size_t)0) # define MEMORY_VERIFY(ptr) mwIsSafeAddr((ptr), 1) # define MEMORY_CHECK() CHECK() @@ -67,21 +67,21 @@ struct malloc_interface *iMalloc; # include <gc.h> # ifdef GC_ADD_CALLER -# define RETURN_ADDR 0, +# define MALLOC(n,file,line,func) GC_debug_malloc((n), 0, (file), (line)) +# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), 0, (file), (line)) +# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), 0, (file), (line)) +# define STRDUP(p,file,line,func) GC_debug_strdup((p), 0, (file), (line)) # else -# define RETURN_ADDR +# define MALLOC(n,file,line,func) GC_debug_malloc((n), (file), (line)) +# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), (file), (line)) +# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), (file), (line)) +# define STRDUP(p,file,line,func) GC_debug_strdup((p), (file), (line)) # endif -# define MALLOC(n,file,line,func) GC_debug_malloc((n), RETURN_ADDR (file),(line)) -# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), RETURN_ADDR (file),(line)) -# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), RETURN_ADDR (file),(line)) -# define STRDUP(p,file,line,func) GC_debug_strdup((p), RETURN_ADDR (file),(line)) # define FREE(p,file,line,func) GC_debug_free(p) # define MEMORY_USAGE() GC_get_heap_size() # define MEMORY_VERIFY(ptr) (GC_base(ptr) != NULL) # define MEMORY_CHECK() GC_gcollect() -# undef RETURN_ADDR - #else # define MALLOC(n,file,line,func) malloc(n) @@ -89,9 +89,9 @@ struct malloc_interface *iMalloc; # define REALLOC(p,n,file,line,func) realloc((p),(n)) # define STRDUP(p,file,line,func) strdup(p) # define FREE(p,file,line,func) free(p) -# define MEMORY_USAGE() (size_t)0 +# define MEMORY_USAGE() ((size_t)0) # define MEMORY_VERIFY(ptr) true -# define MEMORY_CHECK() +# define MEMORY_CHECK() (void)0 #endif diff --git a/src/common/memmgr.h b/src/common/memmgr.h index 4b06ae56e..5975f55c4 100644 --- a/src/common/memmgr.h +++ b/src/common/memmgr.h @@ -60,7 +60,7 @@ #ifdef __GNUC__ // GCC has variable length arrays #define CREATE_BUFFER(name, type, size) type name[size] -#define DELETE_BUFFER(name) +#define DELETE_BUFFER(name) (void)0 #else // others don't, so we emulate them diff --git a/src/common/showmsg.c b/src/common/showmsg.c index e60b9f536..956222a7d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -478,7 +478,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) { return ret; } -#define FFLUSH(handle) +#define FFLUSH(handle) (void)(handle) #define STDOUT GetStdHandle(STD_OUTPUT_HANDLE) #define STDERR GetStdHandle(STD_ERROR_HANDLE) diff --git a/src/common/sql.h b/src/common/sql.h index 33643407d..e949a8280 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -272,13 +272,13 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename); HPShared struct sql_interface *SQL; #if defined(SQL_REMOVE_SHOWDEBUG) -#define Sql_ShowDebug(self) (void)0 +#define Sql_ShowDebug(self) (void)(self) #else #define Sql_ShowDebug(self) (SQL->ShowDebug_((self), __FILE__, __LINE__)) #endif #if defined(SQL_REMOVE_SHOWDEBUG) -#define SqlStmt_ShowDebug(self) (void)0 +#define SqlStmt_ShowDebug(self) (void)(self) #else /// Shows debug information (with statement). #define SqlStmt_ShowDebug(self) (SQL->StmtShowDebug_((self), __FILE__, __LINE__)) diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index dbedfa2db..7cc4cd16a 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -65,7 +65,7 @@ struct sysinfo_interface *sysinfo; #define VCSTYPE_UNKNOWN 0 #define VCSTYPE_GIT 1 #define VCSTYPE_SVN 2 -#define VCSTYPE_NONE -1 +#define VCSTYPE_NONE (-1) #ifdef WIN32 /** diff --git a/src/config/const.h b/src/config/const.h index 75bf35dd9..655f0f949 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -101,9 +101,9 @@ md.damage = md.damage * 150 / 100 + md.damage * status->get_lv(src) / 100; \ } while(0) #else - #define RE_LVL_DMOD(val) - #define RE_LVL_MDMOD(val) - #define RE_LVL_TMDMOD() + #define RE_LVL_DMOD(val) (void)(val) + #define RE_LVL_MDMOD(val) (void)(val) + #define RE_LVL_TMDMOD() (void)0 #endif // Renewal variable cast time reduction diff --git a/src/map/clif.h b/src/map/clif.h index 7567e507b..250689e90 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -63,7 +63,7 @@ struct view_data; #define clif_disp_onlyself(sd,mes,len) clif->disp_message( &(sd)->bl, (mes), (len), SELF ) #define MAX_ROULETTE_LEVEL 7 /** client-defined value **/ #define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/ -#define RGB2BGR(c) ((c & 0x0000FF) << 16 | (c & 0x00FF00) | (c & 0xFF0000) >> 16) +#define RGB2BGR(c) (((c) & 0x0000FF) << 16 | ((c) & 0x00FF00) | ((c) & 0xFF0000) >> 16) #define COLOR_RED 0xff0000U #define COLOR_GREEN 0x00ff00U diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 1712c98a9..3e3aff414 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -70,7 +70,7 @@ enum homun_id { hom->dex_value = hom->luk_value = hom->level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE \ ) #else -#define APPLY_HOMUN_LEVEL_STATWEIGHT() +#define APPLY_HOMUN_LEVEL_STATWEIGHT() 0 #endif struct h_stats { |