Skip to content

Commit dcd6361

Browse files
committed
tree-wide: do not wrap assert_se in extra parentheses
We were inconsitently using them in some cases, but in majority not. Using assignment in assert_se is very common, not an exception like in 'if', so let's drop the extra parens everywhere.
1 parent 6978efc commit dcd6361

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

src/basic/path-util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ int systemd_installation_has_version(const char *root, unsigned minimal_version)
918918
if (r < 0)
919919
return r;
920920

921-
assert_se((c = endswith(path, "*.so")));
921+
assert_se(c = endswith(path, "*.so"));
922922
*c = '\0'; /* truncate the glob part */
923923

924924
STRV_FOREACH(name, names) {

src/libsystemd/sd-bus/test-bus-server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static void *server(void *p) {
6868

6969
if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "Exit")) {
7070

71-
assert_se((sd_bus_can_send(bus, 'h') >= 1) == (c->server_negotiate_unix_fds && c->client_negotiate_unix_fds));
71+
assert_se((sd_bus_can_send(bus, 'h') >= 1) ==
72+
(c->server_negotiate_unix_fds && c->client_negotiate_unix_fds));
7273

7374
r = sd_bus_message_new_method_return(m, &reply);
7475
if (r < 0) {

src/test/test-copy.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void test_copy_tree(void) {
9595
STRV_FOREACH(p, files) {
9696
_cleanup_free_ char *f;
9797

98-
assert_se((f = strappend(original_dir, *p)));
98+
assert_se(f = strappend(original_dir, *p));
9999

100100
assert_se(mkdir_parents(f, 0755) >= 0);
101101
assert_se(write_string_file(f, "file", WRITE_STRING_FILE_CREATE) == 0);
@@ -104,8 +104,8 @@ static void test_copy_tree(void) {
104104
STRV_FOREACH_PAIR(link, p, links) {
105105
_cleanup_free_ char *f, *l;
106106

107-
assert_se((f = strappend(original_dir, *p)));
108-
assert_se((l = strappend(original_dir, *link)));
107+
assert_se(f = strappend(original_dir, *p));
108+
assert_se(l = strappend(original_dir, *link));
109109

110110
assert_se(mkdir_parents(l, 0755) >= 0);
111111
assert_se(symlink(f, l) == 0);
@@ -120,7 +120,7 @@ static void test_copy_tree(void) {
120120
_cleanup_free_ char *buf = NULL, *f;
121121
size_t sz = 0;
122122

123-
assert_se((f = strappend(copy_dir, *p)));
123+
assert_se(f = strappend(copy_dir, *p));
124124

125125
assert_se(access(f, F_OK) == 0);
126126
assert_se(read_full_file(f, &buf, &sz) == 0);
@@ -130,8 +130,8 @@ static void test_copy_tree(void) {
130130
STRV_FOREACH_PAIR(link, p, links) {
131131
_cleanup_free_ char *target = NULL, *f, *l;
132132

133-
assert_se((f = strjoin(original_dir, *p)));
134-
assert_se((l = strjoin(copy_dir, *link)));
133+
assert_se(f = strjoin(original_dir, *p));
134+
assert_se(l = strjoin(copy_dir, *link));
135135

136136
assert_se(chase_symlinks(l, NULL, 0, &target) == 1);
137137
assert_se(path_equal(f, target));

src/test/test-dlopen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
int main(int argc, char **argv) {
1414
void *handle;
1515

16-
assert_se((handle = dlopen(argv[1], RTLD_NOW)));
16+
assert_se(handle = dlopen(argv[1], RTLD_NOW));
1717
assert_se(dlclose(handle) == 0);
1818

1919
return EXIT_SUCCESS;

src/test/test-fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static void test_write_string_file_verify(void) {
467467
int r;
468468

469469
assert_se(read_one_line_file("/proc/cmdline", &buf) >= 0);
470-
assert_se((buf2 = strjoin(buf, "\n")));
470+
assert_se(buf2 = strjoin(buf, "\n"));
471471

472472
r = write_string_file("/proc/cmdline", buf, 0);
473473
assert_se(IN_SET(r, -EACCES, -EIO));

src/test/test-hexdecoct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ static void test_unhexmem_one(const char *s, size_t l, int retval) {
8585
if (retval == 0) {
8686
char *answer;
8787

88-
if (l == (size_t) - 1)
88+
if (l == (size_t) -1)
8989
l = strlen(s);
9090

91-
assert_se((hex = hexmem(mem, len)));
91+
assert_se(hex = hexmem(mem, len));
9292
answer = strndupa(s, l);
9393
assert_se(streq(delete_chars(answer, WHITESPACE), hex));
9494
}

src/test/test-nss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int print_gaih_addrtuples(const struct gaih_addrtuple *tuples) {
8787
r = in_addr_to_string(it->family, &u, &a);
8888
assert_se(IN_SET(r, 0, -EAFNOSUPPORT));
8989
if (r == -EAFNOSUPPORT)
90-
assert_se((a = hexmem(it->addr, 16)));
90+
assert_se(a = hexmem(it->addr, 16));
9191

9292
if (it->scopeid == 0)
9393
goto numerical_index;

src/test/test-unit-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ static void test_install_printf(void) {
636636

637637
assert_se(specifier_machine_id('m', NULL, NULL, &mid) >= 0 && mid);
638638
assert_se(specifier_boot_id('b', NULL, NULL, &bid) >= 0 && bid);
639-
assert_se((host = gethostname_malloc()));
640-
assert_se((user = uid_to_name(getuid())));
639+
assert_se(host = gethostname_malloc());
640+
assert_se(user = uid_to_name(getuid()));
641641
assert_se(asprintf(&uid, UID_FMT, getuid()) >= 0);
642642

643643
#define expect(src, pattern, result) \

0 commit comments

Comments
 (0)