Issue information

Issue ID
#5531
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Apr 1, 2012 8:23
Last Post
pan
Jul 9, 2014 3:28
Confirmation
N/A

Hercules Elf Bot - Apr 1, 2012 8:23

Originally posted by [b]mkbu95[/b]
In nullpo.c:
[CODE]void nullpo_info_f(const char *file, int line, const char *func,
const char *fmt, ...)[/CODE]Is never used.

[CODE]void nullpo_info(const char *file, int line, const char *func)[/CODE]
Is only used 3 times in battle.c for "apparently" the same thing:
[CODE] memset(&wd,0,sizeof(wd));
memset(&flag,0,sizeof(flag));

if(src==NULL || target==NULL)
{
nullpo_info(NLP_MARK);
return wd;
}[/CODE][CODE] memset(&ad,0,sizeof(ad));
memset(&flag,0,sizeof(flag));

if(src==NULL || target==NULL)
{
nullpo_info(NLP_MARK);
return ad;
}[/CODE][CODE] memset(&md,0,sizeof(md));

if( src == NULL || target == NULL ){
nullpo_info(NLP_MARK);
return md;
}[/CODE]

In nullpo.h:
[CODE]// ‰Â•Ïˆø”ƒ}ƒNƒ‚ÉŠÖ‚·‚ÉðŒƒRƒ“ƒpƒCƒ‹
#if __STDC_VERSION__ >= 199901L
/* C99‚ɑΉž */
#define nullpo_ret_f(t, fmt, ...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return(0);}

#define nullpo_retv_f(t, fmt, ...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return;}

#define nullpo_retr_f(ret, t, fmt, ...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return(ret);}

#define nullpo_retb_f(t, fmt, ...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {break;}

#elif __GNUC__ >= 2
/* GCC—p */
#define nullpo_ret_f(t, fmt, args...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return(0);}

#define nullpo_retv_f(t, fmt, args...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return;}

#define nullpo_retr_f(ret, t, fmt, args...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return(ret);}

#define nullpo_retb_f(t, fmt, args...) \
if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {break;}

#else

/* ‚»‚Ì‘¼Ã¢â‚¬Å¡ÃƒÅ’ê‡EEE orz */

#endif[/CODE]This is never used.

[CODE]#define nullpo_retb(t) (void)(t)[/CODE] This is never used.

[CODE]// ‰Â•Ïˆø”ƒ}ƒNƒ‚ÉŠÖ‚·‚ÉðŒƒRƒ“ƒpƒCƒ‹
#if __STDC_VERSION__ >= 199901L
/* C99‚ɑΉž */
#define nullpo_ret_f(t, fmt, ...) (void)(t)
#define nullpo_retv_f(t, fmt, ...) (void)(t)
#define nullpo_retr_f(ret, t, fmt, ...) (void)(t)
#define nullpo_retb_f(t, fmt, ...) (void)(t)

#elif __GNUC__ >= 2
/* GCC—p */
#define nullpo_ret_f(t, fmt, args...) (void)(t)
#define nullpo_retv_f(t, fmt, args...) (void)(t)
#define nullpo_retr_f(ret, t, fmt, args...) (void)(t)
#define nullpo_retb_f(t, fmt, args...) (void)(t)

#else
/* ‚»‚Ì‘¼Ã¢â‚¬Å¡ÃƒÅ’ê‡EEE orz */
#endif[/CODE] Never used.

[hr]
Just to clear the situation: I don't know much about these stuff above (nullpo settings /hmm ) but since it's never used/obselete, could be removed. /slur
And What about change these macros to "static inline", does this make anything better?

"Did you know?": /heh
nullpo.c had only one significant change, where printf were replaced with ShowMessage.
nullpo.h last change was about 2007.

Well, thanks for reading, and sorry if this is not important /sry
Kind regards, /kis2
mkbu95

This post has been edited by mkbu95 on Apr 1, 2012 8:27

Hercules Elf Bot - Apr 1, 2012 11:29

Originally posted by [b]xazax[/b]
These functions are more like utilites, that help us debugging problmes, Once there are null pointer crashes, that are hard to track, we can add calls to those functions to the certain points of the source, and it would help us to gather more information.

It does not affect the code compiled in release mode, so there are no performance impact. All in all, i would not remove them, though they are barely used right now.

pan - Jul 9, 2014 3:28

This snippet was already removed.