mirror of
https://github.com/benhoyt/inih.git
synced 2025-01-28 22:52:54 +08:00
Fix redundant cast-to-int when INI_USE_STACK!=0 (#137)
Code context (ini.c): 101: #if INI_USE_STACK 102: char line[INI_MAX_LINE]; 103: int max_line = INI_MAX_LINE; 104: #else 105: char* line; 106: size_t max_line = INI_INITIAL_ALLOC; 107: #endif ... 133: while (reader(line, (int)max_line, stream) != NULL) { SonarCloud is reporting a "code smell" due to a redundant cast to `int` at line 133. This only happens when INI_USE_STACK is true, and not otherwise, as in that case, `max_line` is of type `size_t` that gets correctly casted to `int`. This patch changes the type of `max_line` variable to `size_t` for all situations. SonarCloud report URL: https://sonarcloud.io/project/issues?pullRequest=221&issues=AYGYdhPZKkhmUWy1nsvP&open=AYGYdhPZKkhmUWy1nsvP&id=snoopy Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
This commit is contained in:
parent
4bd3261ea4
commit
0566527e70
2
ini.c
2
ini.c
@ -100,7 +100,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
/* Uses a fair bit of stack (use heap instead if you need to) */
|
||||
#if INI_USE_STACK
|
||||
char line[INI_MAX_LINE];
|
||||
int max_line = INI_MAX_LINE;
|
||||
size_t max_line = INI_MAX_LINE;
|
||||
#else
|
||||
char* line;
|
||||
size_t max_line = INI_INITIAL_ALLOC;
|
||||
|
Loading…
x
Reference in New Issue
Block a user