diff options
author | Haru <haru@dotalux.com> | 2013-09-25 00:29:15 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-25 00:29:15 +0200 |
commit | 44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7 (patch) | |
tree | 1c1e300503d99ecbe8b41355daa716858aaece5d /src/common | |
parent | b9c8f57b92d2935db971a38e144529682712dc82 (diff) | |
download | hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.gz hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.bz2 hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.xz hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.zip |
Renamed more forgotten variables during interface conversions
(related: b9c8f57)
Most renames are trivial (just to avoid shadowing global variables, even
if they currently did no harm), but there were some cases of partly
renamed variables that caused some NULL checks to always pass and who
knows what could have been happened when they were too subtle to make
the application crash.
Also corrected some potentially unsafe macro definitions
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/HPMi.h | 2 | ||||
-rw-r--r-- | src/common/console.c | 4 | ||||
-rw-r--r-- | src/common/console.h | 2 | ||||
-rw-r--r-- | src/common/strlib.c | 54 | ||||
-rw-r--r-- | src/common/strlib.h | 4 |
5 files changed, 33 insertions, 33 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 5e44b80c7..c8bce8ee8 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -91,7 +91,7 @@ HPExport struct HPMi_interface { bool (*addPacket) (unsigned short cmd, unsigned short length, void (*receive)(int fd), unsigned int point, unsigned int pluginID); } HPMi_s; #ifndef _HPM_H_ - HPExport struct HPMi_interface *HPMi; +HPExport struct HPMi_interface *HPMi; #endif #endif /* _HPMi_H_ */ diff --git a/src/common/console.c b/src/common/console.c index c9772ecfd..6f25bd2fd 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -386,8 +386,8 @@ void console_parse_init(void) { iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } -void console_setSQL(Sql *SQL) { - console->SQL = SQL; +void console_setSQL(Sql *SQL_handle) { + console->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ diff --git a/src/common/console.h b/src/common/console.h index 214a41175..cef898f17 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -64,7 +64,7 @@ struct console_interface { void (*load_defaults) (void); void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); - void (*setSQL) (Sql *SQL); + void (*setSQL) (Sql *SQL_handle); #endif }; diff --git a/src/common/strlib.c b/src/common/strlib.c index 686b2e47d..e45cb0789 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -444,9 +444,9 @@ bool bin2hex(char* output, unsigned char* input, size_t count) /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// -/// @param sv Parse state +/// @param svstate Parse state /// @return 1 if a field was parsed, 0 if already done, -1 on error. -int sv_parse_next(struct s_svstate* sv) +int sv_parse_next(struct s_svstate* svstate) { enum { START_OF_FIELD, @@ -462,13 +462,13 @@ int sv_parse_next(struct s_svstate* sv) char delim; int i; - if( sv == NULL ) + if( svstate == NULL ) return -1;// error - str = sv->str; - len = sv->len; - opt = sv->opt; - delim = sv->delim; + str = svstate->str; + len = svstate->len; + opt = svstate->opt; + delim = svstate->delim; // check opt if( delim == '\n' && (opt&(SV_TERMINATE_CRLF|SV_TERMINATE_LF)) ) @@ -482,9 +482,9 @@ int sv_parse_next(struct s_svstate* sv) return -1;// error } - if( sv->done || str == NULL ) + if( svstate->done || str == NULL ) { - sv->done = true; + svstate->done = true; return 0;// nothing to parse } @@ -495,10 +495,10 @@ int sv_parse_next(struct s_svstate* sv) ((opt&SV_TERMINATE_CR) && str[i] == '\r') || \ ((opt&SV_TERMINATE_CRLF) && i+1 < len && str[i] == '\r' && str[i+1] == '\n') ) #define IS_C_ESCAPE() ( (opt&SV_ESCAPE_C) && str[i] == '\\' ) -#define SET_FIELD_START() sv->start = i -#define SET_FIELD_END() sv->end = i +#define SET_FIELD_START() svstate->start = i +#define SET_FIELD_END() svstate->end = i - i = sv->off; + i = svstate->off; state = START_OF_FIELD; while( state != END ) { @@ -578,14 +578,14 @@ int sv_parse_next(struct s_svstate* sv) else ++i;// CR or LF #endif - sv->done = true; + svstate->done = true; state = END; break; } } if( IS_END() ) - sv->done = true; - sv->off = i; + svstate->done = true; + svstate->off = i; #undef IS_END #undef IS_DELIM @@ -619,31 +619,31 @@ int sv_parse_next(struct s_svstate* sv) /// @param opt Options that determine the parsing behaviour /// @return Number of fields found in the string or -1 if an error occured int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) { - struct s_svstate sv; + struct s_svstate svstate; int count; // initialize if( out_pos == NULL ) npos = 0; for( count = 0; count < npos; ++count ) out_pos[count] = -1; - sv.str = str; - sv.len = len; - sv.off = startoff; - sv.opt = opt; - sv.delim = delim; - sv.done = false; + svstate.str = str; + svstate.len = len; + svstate.off = startoff; + svstate.opt = opt; + svstate.delim = delim; + svstate.done = false; // parse count = 0; if( npos > 0 ) out_pos[0] = startoff; - while( !sv.done ) { + while( !svstate.done ) { ++count; - if( sv_parse_next(&sv) <= 0 ) + if( sv_parse_next(&svstate) <= 0 ) return -1;// error - if( npos > count*2 ) out_pos[count*2] = sv.start; - if( npos > count*2+1 ) out_pos[count*2+1] = sv.end; + if( npos > count*2 ) out_pos[count*2] = svstate.start; + if( npos > count*2+1 ) out_pos[count*2+1] = svstate.end; } - if( npos > 1 ) out_pos[1] = sv.off; + if( npos > 1 ) out_pos[1] = svstate.off; return count; } diff --git a/src/common/strlib.h b/src/common/strlib.h index 9b1875d45..5ef455a0e 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -124,9 +124,9 @@ struct sv_interface { /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// - /// @param sv Parse state + /// @param svstate Parse state /// @return 1 if a field was parsed, 0 if done, -1 on error. - int (*parse_next) (struct s_svstate* sv); + int (*parse_next) (struct s_svstate* svstate); /// Parses a delim-separated string. /// Starts parsing at startoff and fills the pos array with position pairs. |