type = unit_name_to_type(info->name);
if (type < 0)
return -EINVAL;
- if (unit_name_is_valid(info->name, UNIT_NAME_TEMPLATE|UNIT_NAME_INSTANCE) && !unit_type_may_template(type)) {
- log_error("Unit type %s cannot be templated.", unit_type_to_string(type));
- return -EINVAL;
- }
+ if (unit_name_is_valid(info->name, UNIT_NAME_TEMPLATE|UNIT_NAME_INSTANCE) && !unit_type_may_template(type))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Unit type %s cannot be templated.", unit_type_to_string(type));
if (!(flags & SEARCH_LOAD)) {
r = lstat(path, &st);
}
}
- if (!found_unit) {
- log_debug("Cannot find unit %s%s%s.", info->name, template ? " or " : "", strempty(template));
- return -ENOENT;
- }
+ if (!found_unit)
+ return log_debug_errno(SYNTHETIC_ERRNO(ENOENT),
+ "Cannot find unit %s%s%s.",
+ info->name, template ? " or " : "", strempty(template));
if (info->type == UNIT_FILE_TYPE_MASKED)
return result;
if (q < 0)
return q;
- r = install_info_traverse(scope, c, paths, i, flags, NULL);
- if (r < 0) {
+ q = install_info_traverse(scope, c, paths, i, flags, NULL);
+ if (q < 0) {
unit_file_changes_add(changes, n_changes, r, i->name, NULL);
- return r;
+ return q;
}
/* We can attempt to process a masked unit when a different unit
l = &i->required_by;
strv_free(*l);
- *l = strv_new(target_info->name, NULL);
+ *l = strv_new(target_info->name);
if (!*l)
return -ENOMEM;
}
STRV_FOREACH(p, files) {
_cleanup_fclose_ FILE *f;
- char line[LINE_MAX];
int n = 0;
f = fopen(*p, "re");
return -errno;
}
- FOREACH_LINE(line, f, return -errno) {
+ for (;;) {
+ _cleanup_free_ char *line = NULL;
PresetRule rule = {};
const char *parameter;
char *l;
+ r = read_line(f, LONG_LINE_MAX, &line);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ break;
+
l = strstrip(line);
n++;
/* Unit_name will remain the same as parameter when no instances are specified */
r = split_pattern_into_name_and_instances(parameter, &unit_name, &instances);
if (r < 0) {
- log_syntax(NULL, LOG_WARNING, *p, n, 0, "Couldn't parse line '%s'. Ignoring.", line);
+ log_syntax(NULL, LOG_WARNING, *p, n, r, "Couldn't parse line '%s'. Ignoring.", line);
continue;
}