mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
modules-load: fgets() excorcism
This commit is contained in:
parent
1d47b56995
commit
a889e206a7
|
@ -72,25 +72,25 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent
|
||||||
if (ignore_enoent && r == -ENOENT)
|
if (ignore_enoent && r == -ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return log_error_errno(r, "Failed to open %s, ignoring: %m", path);
|
return log_error_errno(r, "Failed to open %s: %m", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("apply: %s", path);
|
log_debug("apply: %s", path);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char line[LINE_MAX], *l;
|
_cleanup_free_ char *line = NULL;
|
||||||
|
char *l;
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
if (!fgets(line, sizeof(line), f)) {
|
r = read_line(f, LONG_LINE_MAX, &line);
|
||||||
if (feof(f))
|
if (r < 0)
|
||||||
break;
|
return log_error_errno(errno, "Failed to read file '%s': %m", path);
|
||||||
|
if (r == 0)
|
||||||
return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
l = strstrip(line);
|
l = strstrip(line);
|
||||||
if (!*l)
|
if (isempty(l))
|
||||||
continue;
|
continue;
|
||||||
if (strchr(COMMENTS "\n", *l))
|
if (strchr(COMMENTS, *l))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
k = module_load_and_warn(ctx, l, true);
|
k = module_load_and_warn(ctx, l, true);
|
||||||
|
|
Loading…
Reference in a new issue