shared/install: rework InstallChange to always have .path set

We would set .path in all cases except INSTALL_CHANGE_AUXILIARY_FAILED, where
we would just just .source. This special case is just not worth it, because
we can't easily assert that .path is set. Let's remove this special case to
help the compiler know that .path is actually set.

Avoids a warning with gcc-13.0.1-0.1.fc38.x86_64.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-01-22 18:20:22 +01:00
parent 7100653885
commit 4a4af850b3

View file

@ -284,6 +284,9 @@ InstallChangeType install_changes_add(
assert(!changes == !n_changes);
assert(INSTALL_CHANGE_TYPE_VALID(type));
/* Message formatting requires <path> to be set. */
assert(path);
/* Register a change or error. Note that the return value may be the error
* that was passed in, or -ENOMEM generated internally. */
@ -340,6 +343,7 @@ void install_changes_dump(int r, const char *verb, const InstallChange *changes,
for (size_t i = 0; i < n_changes; i++) {
assert(verb || changes[i].type >= 0);
assert(changes[i].path);
/* When making changes here, make sure to also change install_error() in dbus-manager.c. */
@ -376,7 +380,7 @@ void install_changes_dump(int r, const char *verb, const InstallChange *changes,
break;
case INSTALL_CHANGE_AUXILIARY_FAILED:
if (!quiet)
log_warning("Failed to enable auxiliary unit %s, ignoring.", changes[i].source);
log_warning("Failed to enable auxiliary unit %s, ignoring.", changes[i].path);
break;
case -EEXIST:
if (changes[i].source)
@ -2134,7 +2138,7 @@ static int install_context_apply(
q = install_info_traverse(ctx, lp, i, flags, NULL);
if (q < 0) {
if (i->auxiliary) {
q = install_changes_add(changes, n_changes, INSTALL_CHANGE_AUXILIARY_FAILED, NULL, i->name);
q = install_changes_add(changes, n_changes, INSTALL_CHANGE_AUXILIARY_FAILED, i->name, NULL);
if (q < 0)
return q;
continue;