1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

install: FOREACH_LINE excorcism

This commit is contained in:
Lennart Poettering 2018-10-18 16:18:20 +02:00
parent d5b3c07da6
commit bef77f378c

View File

@ -15,6 +15,7 @@
#include "alloc-util.h" #include "alloc-util.h"
#include "conf-files.h" #include "conf-files.h"
#include "conf-parser.h" #include "conf-parser.h"
#include "def.h"
#include "dirent-util.h" #include "dirent-util.h"
#include "extract-word.h" #include "extract-word.h"
#include "fd-util.h" #include "fd-util.h"
@ -2841,7 +2842,6 @@ static int read_presets(UnitFileScope scope, const char *root_dir, Presets *pres
STRV_FOREACH(p, files) { STRV_FOREACH(p, files) {
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f;
char line[LINE_MAX];
int n = 0; int n = 0;
f = fopen(*p, "re"); f = fopen(*p, "re");
@ -2852,11 +2852,18 @@ static int read_presets(UnitFileScope scope, const char *root_dir, Presets *pres
return -errno; return -errno;
} }
FOREACH_LINE(line, f, return -errno) { for (;;) {
_cleanup_free_ char *line = NULL;
PresetRule rule = {}; PresetRule rule = {};
const char *parameter; const char *parameter;
char *l; char *l;
r = read_line(f, LONG_LINE_MAX, &line);
if (r < 0)
return r;
if (r == 0)
break;
l = strstrip(line); l = strstrip(line);
n++; n++;