mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
BUILD: stats: remove non portable getline() usage
getline() was used to read stats-file. However, this function is not portable and may cause build issue on some systems. Replace it by standard fgets(). No need to backport.
This commit is contained in:
parent
ef943c186d
commit
fbc3d46b9f
@ -351,8 +351,6 @@ void apply_stats_file(void)
|
|||||||
FILE *file;
|
FILE *file;
|
||||||
struct ist istline;
|
struct ist istline;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
ssize_t len;
|
|
||||||
size_t alloc_len;
|
|
||||||
int linenum;
|
int linenum;
|
||||||
|
|
||||||
if (!global.stats_file)
|
if (!global.stats_file)
|
||||||
@ -370,15 +368,20 @@ void apply_stats_file(void)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line = malloc(sizeof(char) * LINESIZE);
|
||||||
|
if (!line) {
|
||||||
|
ha_warning("config: Can't load stats file: line alloc error.\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
linenum = 0;
|
linenum = 0;
|
||||||
domain = STFILE_DOMAIN_UNSET;
|
domain = STFILE_DOMAIN_UNSET;
|
||||||
while (1) {
|
while (1) {
|
||||||
len = getline(&line, &alloc_len, file);
|
if (!fgets(line, LINESIZE, file))
|
||||||
if (len < 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
++linenum;
|
++linenum;
|
||||||
istline = iststrip(ist2(line, len));
|
istline = iststrip(ist(line));
|
||||||
if (!istlen(istline))
|
if (!istlen(istline))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user