tree-wide: add a space after if, switch, for, and while

This commit is contained in:
Yu Watanabe 2022-04-01 22:37:21 +09:00
parent 72dce85a60
commit 798931160e
56 changed files with 87 additions and 81 deletions

View file

@ -2,7 +2,7 @@
BEGIN{
print "const char *arphrd_to_name(int id) {"
print " switch(id) {"
print " switch (id) {"
}
!/^HDLC$/ {
printf " case ARPHRD_%s: return \"%s\";\n", $1, $1

View file

@ -162,7 +162,7 @@ struct _packed_ indirect_storage {
unsigned n_buckets; /* number of buckets */
unsigned idx_lowest_entry; /* Index below which all buckets are free.
Makes "while(hashmap_steal_first())" loops
Makes "while (hashmap_steal_first())" loops
O(n) instead of O(n^2) for unordered hashmaps. */
uint8_t _pad[3]; /* padding for the whole HashmapBase */
/* The bitfields in HashmapBase complete the alignment of the whole thing. */

View file

@ -228,7 +228,7 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
({ \
const union sockaddr_union *__sa = &(sa); \
size_t _len; \
switch(__sa->sa.sa_family) { \
switch (__sa->sa.sa_family) { \
case AF_INET: \
_len = sizeof(struct sockaddr_in); \
break; \

View file

@ -113,4 +113,4 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
fputc_unlocked('\n', stdout); \
} \
funlockfile(stdout); \
} while(false)
} while (false)

View file

@ -70,7 +70,7 @@ int getxattr_at_malloc(
by_procfs = true; /* fgetxattr() is not going to work, go via /proc/ link right-away */
}
for(;;) {
for (;;) {
_cleanup_free_ char *v = NULL;
ssize_t n;

View file

@ -35,7 +35,7 @@ static BOOLEAN verify_gpt(union GptHeaderBuffer *gpt_header_buffer, EFI_LBA lba_
h = &gpt_header_buffer->gpt_header;
/* Some superficial validation of the GPT header */
if(CompareMem(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature) != 0))
if (CompareMem(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature) != 0))
return FALSE;
if (h->Header.HeaderSize < 92 || h->Header.HeaderSize > 512)

View file

@ -22,7 +22,7 @@ static int bpf_access_type(const char *acc) {
assert(acc);
for (; *acc; acc++)
switch(*acc) {
switch (*acc) {
case 'r':
r |= BPF_DEVCG_ACC_READ;
break;

View file

@ -2162,7 +2162,7 @@ static int install_error(
for (size_t i = 0; i < n_changes; i++)
switch(changes[i].type_or_errno) {
switch (changes[i].type_or_errno) {
case 0 ... _UNIT_FILE_CHANGE_TYPE_MAX: /* not errors */
continue;

View file

@ -69,7 +69,7 @@ static int audit_callback(
}
static int callback_type_to_priority(int type) {
switch(type) {
switch (type) {
case SELINUX_ERROR:
return LOG_ERR;

View file

@ -304,7 +304,7 @@ int mac_smack_setup(bool *loaded_policy) {
assert(loaded_policy);
r = write_access2_rules("/etc/smack/accesses.d/");
switch(r) {
switch (r) {
case -ENOENT:
log_debug("Smack is not enabled in the kernel.");
return 0;
@ -336,7 +336,7 @@ int mac_smack_setup(bool *loaded_policy) {
#endif
r = write_cipso2_rules("/etc/smack/cipso.d/");
switch(r) {
switch (r) {
case -ENOENT:
log_debug("Smack/CIPSO is not enabled in the kernel.");
return 0;
@ -352,7 +352,7 @@ int mac_smack_setup(bool *loaded_policy) {
}
r = write_netlabel_rules("/etc/smack/netlabel.d/");
switch(r) {
switch (r) {
case -ENOENT:
log_debug("Smack/CIPSO is not enabled in the kernel.");
return 0;
@ -368,7 +368,7 @@ int mac_smack_setup(bool *loaded_policy) {
}
r = write_onlycap_list();
switch(r) {
switch (r) {
case -ENOENT:
log_debug("Smack is not enabled in the kernel.");
break;

View file

@ -439,7 +439,7 @@ static int peer_address_compare_func(const SocketPeer *x, const SocketPeer *y) {
if (r != 0)
return r;
switch(x->peer.sa.sa_family) {
switch (x->peer.sa.sa_family) {
case AF_INET:
return memcmp(&x->peer.in.sin_addr, &y->peer.in.sin_addr, sizeof(x->peer.in.sin_addr));
case AF_INET6:

View file

@ -233,7 +233,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "hA:o:F:1D:rS:U:qn:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return verb_help(0, NULL, NULL);

View file

@ -252,23 +252,23 @@
CASE_F_10,CASE_F_9,CASE_F_8,CASE_F_7,CASE_F_6,CASE_F_5,CASE_F_4,CASE_F_3,CASE_F_2,CASE_F_1) \
(CASE_F,__VA_ARGS__)
#define IN_SET(x, ...) \
({ \
sd_bool _found = sd_false; \
#define IN_SET(x, ...) \
({ \
sd_bool _found = sd_false; \
/* If the build breaks in the line below, you need to extend the case macros. (We use "long double" as \
* type for the array, in the hope that checkers such as ubsan don't complain that the initializers for \
* the array are not representable by the base type. Ideally we'd use typeof(x) as base type, but that \
* doesn't work, as we want to use this on bitfields and gcc refuses typeof() on bitfields.) */ \
static const long double __assert_in_set[] _unused_ = { __VA_ARGS__ }; \
assert_cc(ELEMENTSOF(__assert_in_set) <= 20); \
switch(x) { \
FOR_EACH_MAKE_CASE(__VA_ARGS__) \
_found = sd_true; \
break; \
default: \
break; \
} \
_found; \
assert_cc(ELEMENTSOF(__assert_in_set) <= 20); \
switch (x) { \
FOR_EACH_MAKE_CASE(__VA_ARGS__) \
_found = sd_true; \
break; \
default: \
break; \
} \
_found; \
})
/* Takes inspiration from Rust's Option::take() method: reads and returns a pointer, but at the same time

View file

@ -353,7 +353,7 @@ try_acpi:
* http://www.acpi.info/DOWNLOADS/ACPIspec50.pdf
*/
switch(t) {
switch (t) {
case 1: /* Desktop */
case 3: /* Workstation */

View file

@ -74,7 +74,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "ust:r:h", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -911,7 +911,7 @@ static int parse_argv(int argc, char *argv[]) {
while ((c = getopt_long(argc, argv, "hD:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -858,7 +858,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "ho:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -104,7 +104,7 @@ int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer
const void *key;
int r;
switch(s->split_mode) {
switch (s->split_mode) {
case JOURNAL_WRITE_SPLIT_NONE:
key = "one and only";
break;
@ -495,7 +495,7 @@ static int accept_connection(
return log_error_errno(errno, "accept() on fd:%d failed: %m", fd);
}
switch(socket_address_family(addr)) {
switch (socket_address_family(addr)) {
case AF_INET:
case AF_INET6: {
_cleanup_free_ char *a = NULL;

View file

@ -24,7 +24,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
for (;;) {
switch(u->entry_state) {
switch (u->entry_state) {
case ENTRY_CURSOR: {
u->current_cursor = mfree(u->current_cursor);

View file

@ -668,7 +668,7 @@ static int parse_argv(int argc, char *argv[]) {
opterr = 0;
while ((c = getopt_long(argc, argv, "hu:mM:D:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -772,7 +772,7 @@ static void server_cache_hostname(Server *s) {
}
static bool shall_try_append_again(JournalFile *f, int r) {
switch(r) {
switch (r) {
case -E2BIG: /* Hit configured limit */
case -EFBIG: /* Hit fs limit */

View file

@ -548,7 +548,7 @@ static int dhcp6_option_parse_ia_options(sd_dhcp6_client *client, const uint8_t
assert(buf || buflen == 0);
for(size_t offset = 0; offset < buflen;) {
for (size_t offset = 0; offset < buflen;) {
const uint8_t *data;
size_t data_len;
uint16_t code;
@ -557,7 +557,7 @@ static int dhcp6_option_parse_ia_options(sd_dhcp6_client *client, const uint8_t
if (r < 0)
return r;
switch(code) {
switch (code) {
case SD_DHCP6_OPTION_STATUS_CODE: {
_cleanup_free_ char *msg = NULL;

View file

@ -247,7 +247,7 @@ int sd_dhcp_client_set_request_option(sd_dhcp_client *client, uint8_t option) {
assert_return(client, -EINVAL);
assert_return(IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_STOPPED), -EBUSY);
switch(option) {
switch (option) {
case SD_DHCP_OPTION_PAD:
case SD_DHCP_OPTION_OVERLOAD:

View file

@ -629,7 +629,7 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void
assert(lease);
switch(code) {
switch (code) {
case SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME:
r = lease_parse_u32(option, len, &lease->lifetime, 1);

View file

@ -737,7 +737,7 @@ static int parse_request(uint8_t code, uint8_t len, const void *option, void *us
assert(req);
switch(code) {
switch (code) {
case SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME:
if (len == 4)
req->lifetime = unaligned_read_be32(option);
@ -1096,7 +1096,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz
existing_lease = hashmap_get(server->bound_leases_by_client_id, &req->client_id);
static_lease = hashmap_get(server->static_leases_by_client_id, &req->client_id);
switch(type) {
switch (type) {
case DHCP_DISCOVER: {
be32_t address = INADDR_ANY;

View file

@ -338,7 +338,7 @@ int dhcp6_lease_add_ntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t opt
if (r < 0)
return r;
switch(subopt) {
switch (subopt) {
case DHCP6_NTP_SUBOPTION_SRV_ADDR:
case DHCP6_NTP_SUBOPTION_MC_ADDR:
if (sublen != 16)

View file

@ -156,7 +156,7 @@ static void test_dhcp_identifier_set_iaid(void) {
}
static int check_options(uint8_t code, uint8_t len, const void *option, void *userdata) {
switch(code) {
switch (code) {
case SD_DHCP_OPTION_CLIENT_IDENTIFIER:
{
uint32_t iaid;

View file

@ -53,7 +53,7 @@ static struct option_desc option_tests[] = {
};
static const char *dhcp_type(int type) {
switch(type) {
switch (type) {
case DHCP_DISCOVER:
return "DHCPDISCOVER";
case DHCP_OFFER:
@ -125,7 +125,7 @@ static void test_ignore_opts(uint8_t *descoption, int *descpos, int *desclen) {
assert_se(*descpos >= 0);
while (*descpos < *desclen) {
switch(descoption[*descpos]) {
switch (descoption[*descpos]) {
case SD_DHCP_OPTION_PAD:
*descpos += 1;
break;

View file

@ -29,7 +29,7 @@ static void* basic_request_handler_userdata = (void*) 0xCABCAB;
static void basic_request_handler(sd_ipv4ll *ll, int event, void *userdata) {
assert_se(userdata == basic_request_handler_userdata);
switch(event) {
switch (event) {
case SD_IPV4LL_EVENT_STOP:
basic_request_handler_stop = 1;
break;

View file

@ -1,11 +1,14 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
BEGIN{
print "const char *audit_type_to_string(int type) {\n\tswitch(type) {"
print "const char *audit_type_to_string(int type) {"
print " switch (type) {"
}
{
printf " case AUDIT_%s: return \"%s\";\n", $1, $1
}
END{
print " default: return NULL;\n\t}\n}\n"
print " default: return NULL;"
print " }"
print "}"
}

View file

@ -277,7 +277,7 @@ int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
int r;
assert_return(rtnl_message_type_is_nexthop(nlmsg_type), -EINVAL);
switch(nlmsg_type) {
switch (nlmsg_type) {
case RTM_DELNEXTHOP:
assert_return(nh_family == AF_UNSPEC, -EINVAL);
_fallthrough_;

View file

@ -63,7 +63,7 @@ int type_system_root_get_type_system_and_header_size(
if (IN_SET(type, NLMSG_DONE, NLMSG_ERROR))
nl_type = type_system_get_type(&basic_type_system, type);
else
switch(nl->protocol) {
switch (nl->protocol) {
case NETLINK_ROUTE:
nl_type = rtnl_get_type(type);
break;

View file

@ -516,7 +516,7 @@ static int get_search(uint64_t type, char ***list) {
assert(list);
switch(type) {
switch (type) {
case SD_PATH_SEARCH_BINARIES:
return search_from_environment(list,

View file

@ -165,7 +165,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "hn", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -1,7 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
BEGIN{
print "const char *dns_type_to_string(int type) {\n\tswitch(type) {"
print "const char *dns_type_to_string(int type) {"
print " switch (type) {"
}
{
printf " case DNS_TYPE_%s: return ", $1;
@ -9,5 +10,7 @@ BEGIN{
printf "\"%s\";\n", $1
}
END{
print " default: return NULL;\n\t}\n}\n"
print " default: return NULL;"
print " }"
print "}"
}

View file

@ -136,7 +136,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
arg_mode = _MODE_INVALID;
while ((c = getopt_long(argc, argv, "hadxpfm:uIi:l:Rr:vV", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return resolvconf_help();

View file

@ -2753,7 +2753,7 @@ static int compat_parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "h46i:t:c:p:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return compat_help();
@ -3048,7 +3048,7 @@ static int native_parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "h46i:t:c:p:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return native_help();

View file

@ -102,7 +102,7 @@ void dns_packet_set_flags(DnsPacket *p, bool dnssec_checking_disabled, bool trun
h = DNS_PACKET_HEADER(p);
switch(p->protocol) {
switch (p->protocol) {
case DNS_PROTOCOL_LLMNR:
assert(!truncated);

View file

@ -403,7 +403,7 @@ static DnsResourceRecord* dns_resource_record_free(DnsResourceRecord *rr) {
assert(rr);
if (rr->key) {
switch(rr->key->type) {
switch (rr->key->type) {
case DNS_TYPE_SRV:
free(rr->srv.name);
@ -1166,7 +1166,7 @@ ssize_t dns_resource_record_payload(DnsResourceRecord *rr, void **out) {
assert(rr);
assert(out);
switch(rr->unparsable ? _DNS_TYPE_INVALID : rr->key->type) {
switch (rr->unparsable ? _DNS_TYPE_INVALID : rr->key->type) {
case DNS_TYPE_SRV:
case DNS_TYPE_PTR:
case DNS_TYPE_NS:

View file

@ -185,7 +185,7 @@ ssize_t dnstls_stream_writev(DnsStream *stream, const struct iovec *iov, size_t
ss = gnutls_record_uncork(stream->dnstls_data.session, 0);
if (ss < 0)
switch(ss) {
switch (ss) {
case GNUTLS_E_INTERRUPTED:
return -EINTR;
case GNUTLS_E_AGAIN:
@ -209,7 +209,7 @@ ssize_t dnstls_stream_read(DnsStream *stream, void *buf, size_t count) {
ss = gnutls_record_recv(stream->dnstls_data.session, buf, count);
if (ss < 0)
switch(ss) {
switch (ss) {
case GNUTLS_E_INTERRUPTED:
return -EINTR;
case GNUTLS_E_AGAIN:

View file

@ -1074,7 +1074,7 @@ int config_parse_warn_compat(
Disabled reason = ltype;
switch(reason) {
switch (reason) {
case DISABLED_CONFIGURATION:
log_syntax(unit, LOG_DEBUG, filename, line, 0,

View file

@ -393,7 +393,7 @@ int ethtool_get_permanent_hw_addr(int *ethtool_fd, const char *ifname, struct hw
if (dest != _v) \
updated = true; \
dest = _v; \
} while(false)
} while (false)
#define UPDATE_WITH_MAX(dest, max, val, updated) \
do { \
@ -404,7 +404,7 @@ int ethtool_get_permanent_hw_addr(int *ethtool_fd, const char *ifname, struct hw
if (dest != _v) \
updated = true; \
dest = _v; \
} while(false)
} while (false)
int ethtool_set_wol(
int *ethtool_fd,

View file

@ -108,7 +108,7 @@ int in_addr_prefixes_reduce(Set *prefixes) {
struct in_addr_prefix *p;
SET_FOREACH(p, prefixes)
switch(p->family) {
switch (p->family) {
case AF_INET:
assert(p->prefixlen <= 32);
if (p->prefixlen == 0)
@ -147,7 +147,7 @@ int in_addr_prefixes_reduce(Set *prefixes) {
if (p->prefixlen == 0)
continue;
switch(p->family) {
switch (p->family) {
case AF_INET:
prefixlens = ipv4_prefixlens;
n = &ipv4_n_prefixlens;

View file

@ -330,7 +330,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
for (size_t i = 0; i < n_changes; i++) {
assert(verb || changes[i].type_or_errno >= 0);
switch(changes[i].type_or_errno) {
switch (changes[i].type_or_errno) {
case UNIT_FILE_SYMLINK:
if (!quiet)
log_info("Created symlink %s %s %s.",

View file

@ -281,7 +281,7 @@ static int process_special_field(JournalImporter *imp, char *line) {
int journal_importer_process_data(JournalImporter *imp) {
int r;
switch(imp->state) {
switch (imp->state) {
case IMPORTER_STATE_LINE: {
char *line, *sep;
size_t n = 0;

View file

@ -531,7 +531,7 @@ int mode_to_inaccessible_node(
if (!runtime_dir)
runtime_dir = "/run";
switch(mode & S_IFMT) {
switch (mode & S_IFMT) {
case S_IFREG:
node = "/systemd/inaccessible/reg";
break;

View file

@ -107,7 +107,7 @@ const char* seccomp_arch_to_string(uint32_t c) {
* Names used here should be the same as those used for ConditionArchitecture=,
* except for "subarchitectures" like x32. */
switch(c) {
switch (c) {
case SCMP_ARCH_NATIVE:
return "native";
case SCMP_ARCH_X86:

View file

@ -58,7 +58,7 @@ int service_parse_argv(
assert(argv);
while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help(argv[0], service, description, bus_objects);

View file

@ -79,7 +79,7 @@ bool udev_available(void);
(void) sd_device_get_syspath(_d, &_p); \
(void) sd_device_get_subsystem(_d, &_s); \
STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
} while(false);
} while (false);
#else
#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
#endif

View file

@ -352,7 +352,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'h':
return help();

View file

@ -163,7 +163,7 @@ TEST(auto_erase_memory) {
assert_se(MALLOC_SIZEOF_SAFE(f) >= sizeof(*f) * n); \
assert_se(malloc_usable_size(f) >= sizeof(*f) * n); \
assert_se(__builtin_object_size(f, 0) >= sizeof(*f) * n); \
} while(false)
} while (false)
TEST(malloc_size_safe) {
_cleanup_free_ uint32_t *f = NULL;

View file

@ -51,7 +51,7 @@ static int parse_argv(int argc, char *argv[]) {
assert_se(argv);
while ((c = getopt_long(argc, argv, "r:", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'r':
arg_root = optarg;
break;

View file

@ -541,7 +541,7 @@ static int dvd_ram_media_update_state(Context *c) {
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid format capacities length.");
switch(format[8] & 3) {
switch (format[8] & 3) {
case 1:
/* This means that last format was interrupted or failed, blank dvd-ram discs are
* factory formatted. Take no action here as it takes quite a while to reformat a

View file

@ -61,7 +61,7 @@ int probe_smart_media(int mtd_fd, mtd_info_t* info) {
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"Unexpected sector size: %i", sector_size);
switch(size_in_megs) {
switch (size_in_megs) {
case 1:
case 2:
spare_count = 6;

View file

@ -48,7 +48,7 @@ static int parse_argv(int argc, char *argv[]) {
int c;
while ((c = getopt_long(argc, argv, "ust:r:Vh", options, NULL)) >= 0)
switch(c) {
switch (c) {
case 'u':
arg_update = true;
break;

View file

@ -345,7 +345,7 @@ static int query_device(QueryType query, sd_device* device) {
assert(device);
switch(query) {
switch (query) {
case QUERY_NAME: {
const char *node;