X Tutup
Skip to content

Commit cb31470

Browse files
committed
core: wrap long lines
1 parent 70666e2 commit cb31470

File tree

2 files changed

+97
-51
lines changed

2 files changed

+97
-51
lines changed

src/core/dbus-manager.c

Lines changed: 87 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
#include "virt.h"
3939
#include "watchdog.h"
4040

41-
/* Require 16MiB free in /run/systemd for reloading/reexecing. After all we need to serialize our state there, and if
42-
* we can't we'll fail badly. */
41+
/* Require 16MiB free in /run/systemd for reloading/reexecing. After all we need to serialize our state
42+
* there, and if we can't we'll fail badly. */
4343
#define RELOAD_DISK_SPACE_MIN (UINT64_C(16) * UINT64_C(1024) * UINT64_C(1024))
4444

4545
static UnitFileFlags unit_file_bools_to_flags(bool runtime, bool force) {
@@ -363,8 +363,8 @@ static int bus_get_unit_by_name(Manager *m, sd_bus_message *message, const char
363363
assert(message);
364364
assert(ret_unit);
365365

366-
/* More or less a wrapper around manager_get_unit() that generates nice errors and has one trick up its sleeve:
367-
* if the name is specified empty we use the client's unit. */
366+
/* More or less a wrapper around manager_get_unit() that generates nice errors and has one trick up
367+
* its sleeve: if the name is specified empty we use the client's unit. */
368368

369369
if (isempty(name)) {
370370
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@@ -520,7 +520,8 @@ static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userd
520520

521521
u = manager_get_unit_by_pid(m, pid);
522522
if (!u)
523-
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Client " PID_FMT " not member of any unit.", pid);
523+
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT,
524+
"Client " PID_FMT " not member of any unit.", pid);
524525
} else {
525526
u = hashmap_get(m->units_by_invocation_id, &id);
526527
if (!u)
@@ -531,8 +532,9 @@ static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userd
531532
if (r < 0)
532533
return r;
533534

534-
/* So here's a special trick: the bus path we return actually references the unit by its invocation ID instead
535-
* of the unit name. This means it stays valid only as long as the invocation ID stays the same. */
535+
/* So here's a special trick: the bus path we return actually references the unit by its invocation
536+
* ID instead of the unit name. This means it stays valid only as long as the invocation ID stays the
537+
* same. */
536538
path = unit_dbus_path_invocation_id(u);
537539
if (!path)
538540
return -ENOMEM;
@@ -552,7 +554,9 @@ static int method_get_unit_by_control_group(sd_bus_message *message, void *userd
552554

553555
u = manager_get_unit_by_cgroup(m, cgroup);
554556
if (!u)
555-
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Control group '%s' is not valid or not managed by this instance", cgroup);
557+
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT,
558+
"Control group '%s' is not valid or not managed by this instance",
559+
cgroup);
556560

557561
return reply_unit_path(u, message, error);
558562
}
@@ -851,17 +855,21 @@ static int transient_unit_from_message(
851855

852856
t = unit_name_to_type(name);
853857
if (t < 0)
854-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit name or type.");
858+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
859+
"Invalid unit name or type.");
855860

856861
if (!unit_vtable[t]->can_transient)
857-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units.", unit_type_to_string(t));
862+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
863+
"Unit type %s does not support transient units.",
864+
unit_type_to_string(t));
858865

859866
r = manager_load_unit(m, name, NULL, error, &u);
860867
if (r < 0)
861868
return r;
862869

863870
if (!unit_is_pristine(u))
864-
return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name);
871+
return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS,
872+
"Unit %s already exists.", name);
865873

866874
/* OK, the unit failed to load and is unreferenced, now let's
867875
* fill in the transient data instead */
@@ -1435,7 +1443,8 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *
14351443
return r;
14361444

14371445
if (!MANAGER_IS_SYSTEM(m))
1438-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers.");
1446+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1447+
"Reboot is only supported for system managers.");
14391448

14401449
m->objective = MANAGER_REBOOT;
14411450

@@ -1454,7 +1463,8 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error
14541463
return r;
14551464

14561465
if (!MANAGER_IS_SYSTEM(m))
1457-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers.");
1466+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1467+
"Powering off is only supported for system managers.");
14581468

14591469
m->objective = MANAGER_POWEROFF;
14601470

@@ -1473,7 +1483,8 @@ static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *er
14731483
return r;
14741484

14751485
if (!MANAGER_IS_SYSTEM(m))
1476-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers.");
1486+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1487+
"Halt is only supported for system managers.");
14771488

14781489
m->objective = MANAGER_HALT;
14791490

@@ -1492,7 +1503,8 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e
14921503
return r;
14931504

14941505
if (!MANAGER_IS_SYSTEM(m))
1495-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers.");
1506+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1507+
"KExec is only supported for system managers.");
14961508

14971509
m->objective = MANAGER_KEXEC;
14981510

@@ -1517,7 +1529,7 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
15171529

15181530
if (available < RELOAD_DISK_SPACE_MIN) {
15191531
char fb_available[FORMAT_BYTES_MAX], fb_need[FORMAT_BYTES_MAX];
1520-
log_warning("Dangerously low amount of free space on /run/systemd, root switching operation might not complete successfully. "
1532+
log_warning("Dangerously low amount of free space on /run/systemd, root switching might fail.\n"
15211533
"Currently, %s are free, but %s are suggested. Proceeding anyway.",
15221534
format_bytes(fb_available, sizeof(fb_available), available),
15231535
format_bytes(fb_need, sizeof(fb_need), RELOAD_DISK_SPACE_MIN));
@@ -1528,41 +1540,53 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
15281540
return r;
15291541

15301542
if (!MANAGER_IS_SYSTEM(m))
1531-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Root switching is only supported by system manager.");
1543+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1544+
"Root switching is only supported by system manager.");
15321545

15331546
r = sd_bus_message_read(message, "ss", &root, &init);
15341547
if (r < 0)
15351548
return r;
15361549

15371550
if (isempty(root))
1538-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New root directory may not be the empty string.");
1551+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1552+
"New root directory may not be the empty string.");
15391553
if (!path_is_absolute(root))
1540-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New root path '%s' is not absolute.", root);
1554+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1555+
"New root path '%s' is not absolute.", root);
15411556
if (path_equal(root, "/"))
1542-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New root directory cannot be the old root directory.");
1557+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1558+
"New root directory cannot be the old root directory.");
15431559

15441560
/* Safety check */
15451561
if (isempty(init)) {
15461562
r = path_is_os_tree(root);
15471563
if (r < 0)
1548-
return sd_bus_error_set_errnof(error, r, "Failed to determine whether root path '%s' contains an OS tree: %m", root);
1564+
return sd_bus_error_set_errnof(error, r,
1565+
"Failed to determine whether root path '%s' contains an OS tree: %m",
1566+
root);
15491567
if (r == 0)
1550-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified switch root path '%s' does not seem to be an OS tree. os-release file is missing.", root);
1568+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1569+
"Specified switch root path '%s' does not seem to be an OS tree. os-release file is missing.",
1570+
root);
15511571
} else {
15521572
_cleanup_free_ char *chased = NULL;
15531573

15541574
if (!path_is_absolute(init))
1555-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path to init binary '%s' not absolute.", init);
1575+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1576+
"Path to init binary '%s' not absolute.", init);
15561577

15571578
r = chase_symlinks(init, root, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &chased, NULL);
15581579
if (r < 0)
1559-
return sd_bus_error_set_errnof(error, r, "Could not resolve init executable %s: %m", init);
1580+
return sd_bus_error_set_errnof(error, r,
1581+
"Could not resolve init executable %s: %m", init);
15601582

15611583
if (laccess(chased, X_OK) < 0) {
15621584
if (errno == EACCES)
1563-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Init binary %s is not executable.", init);
1585+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1586+
"Init binary %s is not executable.", init);
15641587

1565-
return sd_bus_error_set_errnof(error, r, "Could not check whether init binary %s is executable: %m", init);
1588+
return sd_bus_error_set_errnof(error, r,
1589+
"Could not check whether init binary %s is executable: %m", init);
15661590
}
15671591
}
15681592

@@ -1632,7 +1656,8 @@ static int method_unset_environment(sd_bus_message *message, void *userdata, sd_
16321656
return r;
16331657

16341658
if (!strv_env_name_or_assignment_is_valid(minus))
1635-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments");
1659+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1660+
"Invalid environment variable names or assignments");
16361661

16371662
r = bus_verify_set_environment_async(m, message, error);
16381663
if (r < 0)
@@ -1668,9 +1693,11 @@ static int method_unset_and_set_environment(sd_bus_message *message, void *userd
16681693
return r;
16691694

16701695
if (!strv_env_name_or_assignment_is_valid(minus))
1671-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments");
1696+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1697+
"Invalid environment variable names or assignments");
16721698
if (!strv_env_is_valid(plus))
1673-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
1699+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1700+
"Invalid environment assignments");
16741701

16751702
r = bus_verify_set_environment_async(m, message, error);
16761703
if (r < 0)
@@ -1723,13 +1750,16 @@ static int method_lookup_dynamic_user_by_name(sd_bus_message *message, void *use
17231750
return r;
17241751

17251752
if (!MANAGER_IS_SYSTEM(m))
1726-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Dynamic users are only supported in the system instance.");
1753+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1754+
"Dynamic users are only supported in the system instance.");
17271755
if (!valid_user_group_name(name, VALID_USER_RELAX))
1728-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "User name invalid: %s", name);
1756+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1757+
"User name invalid: %s", name);
17291758

17301759
r = dynamic_user_lookup_name(m, name, &uid);
17311760
if (r == -ESRCH)
1732-
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_DYNAMIC_USER, "Dynamic user %s does not exist.", name);
1761+
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_DYNAMIC_USER,
1762+
"Dynamic user %s does not exist.", name);
17331763
if (r < 0)
17341764
return r;
17351765

@@ -1751,13 +1781,16 @@ static int method_lookup_dynamic_user_by_uid(sd_bus_message *message, void *user
17511781
return r;
17521782

17531783
if (!MANAGER_IS_SYSTEM(m))
1754-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Dynamic users are only supported in the system instance.");
1784+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1785+
"Dynamic users are only supported in the system instance.");
17551786
if (!uid_is_valid(uid))
1756-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "User ID invalid: " UID_FMT, uid);
1787+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
1788+
"User ID invalid: " UID_FMT, uid);
17571789

17581790
r = dynamic_user_lookup_uid(m, uid, &name);
17591791
if (r == -ESRCH)
1760-
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_DYNAMIC_USER, "Dynamic user ID " UID_FMT " does not exist.", uid);
1792+
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_DYNAMIC_USER,
1793+
"Dynamic user ID " UID_FMT " does not exist.", uid);
17611794
if (r < 0)
17621795
return r;
17631796

@@ -1776,7 +1809,8 @@ static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_
17761809
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
17771810

17781811
if (!MANAGER_IS_SYSTEM(m))
1779-
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Dynamic users are only supported in the system instance.");
1812+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
1813+
"Dynamic users are only supported in the system instance.");
17801814

17811815
r = sd_bus_message_new_method_return(message, &reply);
17821816
if (r < 0)
@@ -1793,7 +1827,8 @@ static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_
17931827
if (r == -EAGAIN) /* not realized yet? */
17941828
continue;
17951829
if (r < 0)
1796-
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Failed to look up a dynamic user.");
1830+
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED,
1831+
"Failed to look up a dynamic user.");
17971832

17981833
r = sd_bus_message_append(reply, "(us)", uid, d->name);
17991834
if (r < 0)
@@ -2001,7 +2036,10 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) {
20012036

20022037
assert(bus);
20032038

2004-
r = sd_bus_message_new_signal(bus, &message, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnitFilesChanged");
2039+
r = sd_bus_message_new_signal(bus, &message,
2040+
"/org/freedesktop/systemd1",
2041+
"org.freedesktop.systemd1.Manager",
2042+
"UnitFilesChanged");
20052043
if (r < 0)
20062044
return r;
20072045

@@ -2129,8 +2167,8 @@ static int reply_unit_file_changes_and_free(
21292167
good = true;
21302168
}
21312169

2132-
/* If there was a failed change, and no successful change, then return the first failure as proper method call
2133-
* error. */
2170+
/* If there was a failed change, and no successful change, then return the first failure as proper
2171+
* method call error. */
21342172
if (bad && !good)
21352173
return install_error(error, 0, changes, n_changes);
21362174

@@ -2555,7 +2593,8 @@ static int method_abandon_scope(sd_bus_message *message, void *userdata, sd_bus_
25552593
return r;
25562594

25572595
if (u->type != UNIT_SCOPE)
2558-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit '%s' is not a scope unit, refusing.", name);
2596+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
2597+
"Unit '%s' is not a scope unit, refusing.", name);
25592598

25602599
return bus_scope_method_abandon(message, u, error);
25612600
}
@@ -2576,7 +2615,8 @@ static int method_set_show_status(sd_bus_message *message, void *userdata, sd_bu
25762615
if (!isempty(t)) {
25772616
mode = show_status_from_string(t);
25782617
if (mode < 0)
2579-
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid show status '%s'", t);
2618+
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
2619+
"Invalid show status '%s'", t);
25802620
}
25812621

25822622
manager_override_show_status(m, mode, "bus");
@@ -3335,7 +3375,11 @@ static int send_finished(sd_bus *bus, void *userdata) {
33353375
assert(bus);
33363376
assert(times);
33373377

3338-
r = sd_bus_message_new_signal(bus, &message, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartupFinished");
3378+
r = sd_bus_message_new_signal(bus,
3379+
&message,
3380+
"/org/freedesktop/systemd1",
3381+
"org.freedesktop.systemd1.Manager",
3382+
"StartupFinished");
33393383
if (r < 0)
33403384
return r;
33413385

0 commit comments

Comments
 (0)
X Tutup