all/systemd: reformat ./{shared,src}/systemd/ with new clang-format style

./contrib/scripts/nm-code-format.sh -i
This commit is contained in:
Thomas Haller
2020-09-28 19:57:20 +02:00
parent 8435deecfa
commit 2bc3588c1d
12 changed files with 332 additions and 309 deletions

View File

@@ -10,9 +10,7 @@
/*****************************************************************************/
gboolean
_nm_log_enabled_impl (gboolean mt_require_locking,
NMLogLevel level,
NMLogDomain domain)
_nm_log_enabled_impl(gboolean mt_require_locking, NMLogLevel level, NMLogDomain domain)
{
return FALSE;
}
@@ -29,12 +27,10 @@ _nm_log_impl (const char *file,
const char *con_uuid,
const char *fmt,
...)
{
}
{}
void
_nm_utils_monotonic_timestamp_initialized(const struct timespec *tp,
gint64 offset_sec,
gboolean is_boottime)
{
}
{}

View File

@@ -44,8 +44,7 @@ nm_sd_utils_path_startswith (const char *path, const char *prefix)
int
nm_sd_utils_unbase64char(char ch, gboolean accept_padding_equal)
{
if ( ch == '='
&& accept_padding_equal)
if (ch == '=' && accept_padding_equal)
return G_MAXINT;
return unbase64char(ch);
}
@@ -69,29 +68,25 @@ nm_sd_utils_unbase64char (char ch, gboolean accept_padding_equal)
* function fail.
*/
int
nm_sd_utils_unbase64mem (const char *p,
size_t l,
gboolean secure,
guint8 **mem,
size_t *len)
nm_sd_utils_unbase64mem(const char *p, size_t l, gboolean secure, guint8 **mem, size_t *len)
{
return unbase64mem_full(p, l, secure, (void **) mem, len);
}
int nm_sd_dns_name_to_wire_format (const char *domain,
guint8 *buffer,
size_t len,
gboolean canonical)
int
nm_sd_dns_name_to_wire_format(const char *domain, guint8 *buffer, size_t len, gboolean canonical)
{
return dns_name_to_wire_format(domain, buffer, len, canonical);
}
int nm_sd_dns_name_is_valid (const char *s)
int
nm_sd_dns_name_is_valid(const char *s)
{
return dns_name_is_valid(s);
}
gboolean nm_sd_hostname_is_valid (const char *s, bool allow_trailing_dot)
gboolean
nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot)
{
return hostname_is_valid(s, allow_trailing_dot);
}
@@ -101,12 +96,10 @@ gboolean nm_sd_hostname_is_valid (const char *s, bool allow_trailing_dot)
static gboolean
_http_url_is_valid(const char *url, gboolean only_https)
{
if ( !url
|| !url[0])
if (!url || !url[0])
return FALSE;
if ( !only_https
&& NM_STR_HAS_PREFIX (url, "http://"))
if (!only_https && NM_STR_HAS_PREFIX(url, "http://"))
url += NM_STRLEN("http://");
else if (NM_STR_HAS_PREFIX(url, "https://"))
url += NM_STRLEN("https://");

View File

@@ -18,18 +18,12 @@ const char *nm_sd_utils_path_startswith (const char *path, const char *prefix);
int nm_sd_utils_unbase64char(char ch, gboolean accept_padding_equal);
int nm_sd_utils_unbase64mem (const char *p,
size_t l,
gboolean secure,
guint8 **mem,
size_t *len);
int nm_sd_utils_unbase64mem(const char *p, size_t l, gboolean secure, guint8 **mem, size_t *len);
/*****************************************************************************/
int nm_sd_dns_name_to_wire_format (const char *domain,
guint8 *buffer,
size_t len,
gboolean canonical);
int
nm_sd_dns_name_to_wire_format(const char *domain, guint8 *buffer, size_t len, gboolean canonical);
int nm_sd_dns_name_is_valid(const char *s);
gboolean nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot);

View File

@@ -44,26 +44,68 @@ _nm_log_get_max_level_realm (void)
if (_nm_log_enabled_impl(!(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD)) { \
const char *_nm_location = strrchr(("" file), '/'); \
\
_nm_log_impl (_nm_location ? _nm_location + 1 : (""file), (line), (func), !(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD, _nm_e, NULL, NULL, ("%s"format), "libsystemd: ", ## __VA_ARGS__); \
_nm_log_impl(_nm_location ? _nm_location + 1 : ("" file), \
(line), \
(func), \
!(NM_THREAD_SAFE_ON_MAIN_THREAD), \
_nm_l, \
LOGD_SYSTEMD, \
_nm_e, \
NULL, \
NULL, \
("%s" format), \
"libsystemd: ", \
##__VA_ARGS__); \
} \
(_nm_e > 0 ? -_nm_e : _nm_e); \
})
#define log_assert_failed(text, file, line, func) \
G_STMT_START { \
log_internal (LOG_CRIT, 0, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.", text, file, line, func); \
G_STMT_START \
{ \
log_internal(LOG_CRIT, \
0, \
file, \
line, \
func, \
"Assertion '%s' failed at %s:%u, function %s(). Aborting.", \
text, \
file, \
line, \
func); \
g_assert_not_reached(); \
} G_STMT_END
} \
G_STMT_END
#define log_assert_failed_unreachable(text, file, line, func) \
G_STMT_START { \
log_internal (LOG_CRIT, 0, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.", text, file, line, func); \
G_STMT_START \
{ \
log_internal(LOG_CRIT, \
0, \
file, \
line, \
func, \
"Code should not be reached '%s' at %s:%u, function %s(). Aborting.", \
text, \
file, \
line, \
func); \
g_assert_not_reached(); \
} G_STMT_END
} \
G_STMT_END
#define log_assert_failed_return(text, file, line, func) \
({ \
log_internal (LOG_DEBUG, 0, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Ignoring.", text, file, line, func); \
log_internal(LOG_DEBUG, \
0, \
file, \
line, \
func, \
"Assertion '%s' failed at %s:%u, function %s(). Ignoring.", \
text, \
file, \
line, \
func); \
g_return_if_fail_warning(G_LOG_DOMAIN, G_STRFUNC, text); \
(void) 0; \
})
@@ -99,7 +141,8 @@ NM_PRAGMA_WARNING_DISABLE ("-Wdeclaration-after-statement")
/*****************************************************************************/
static inline pid_t
raw_getpid (void) {
raw_getpid(void)
{
#if defined(__alpha__)
return (pid_t) syscall(__NR_getxpid);
#else
@@ -107,7 +150,9 @@ raw_getpid (void) {
#endif
}
static inline pid_t _nm_gettid(void) {
static inline pid_t
_nm_gettid(void)
{
return (pid_t) syscall(SYS_gettid);
}
#define gettid() _nm_gettid()

View File

@@ -29,7 +29,8 @@ nm_sd_dhcp_lease_get_private_options (sd_dhcp_lease *lease, nm_sd_dhcp_option **
*out_options = g_new(nm_sd_dhcp_option, cnt);
cnt = 0;
LIST_FOREACH (options, raw_option, lease->private_options) {
LIST_FOREACH(options, raw_option, lease->private_options)
{
(*out_options)[cnt].code = raw_option->tag;
(*out_options)[cnt].data = raw_option->data;
(*out_options)[cnt].data_len = raw_option->length;

View File

@@ -14,7 +14,6 @@ typedef struct {
void * data;
} nm_sd_dhcp_option;
int
nm_sd_dhcp_lease_get_private_options (sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options);
int nm_sd_dhcp_lease_get_private_options(sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options);
#endif /* __NETWORKMANAGER_DHCP_SYSTEMD_UTILS_H__ */

View File

@@ -68,9 +68,7 @@ event_create_source (sd_event *event)
source = (SDEventSource *) g_source_new((GSourceFuncs *) &event_funcs, sizeof(SDEventSource));
source->event = is_default_event
? g_steal_pointer (&event)
: sd_event_ref (event);
source->event = is_default_event ? g_steal_pointer(&event) : sd_event_ref(event);
source->pollfd = (GPollFD){
.fd = sd_event_get_fd(source->event),
@@ -113,4 +111,3 @@ nm_sd_event_attach_default (void)
#include "dhcp-lease-internal.h"
/*****************************************************************************/

View File

@@ -27,4 +27,3 @@ int dhcp_lease_save(struct sd_dhcp_lease *lease, const char *lease_file);
int dhcp_lease_load(struct sd_dhcp_lease **ret, const char *lease_file);
#endif /* __NM_SD_H__ */

View File

@@ -12,10 +12,10 @@
/*****************************************************************************/
int
asynchronous_close (int fd) {
asynchronous_close(int fd)
{
safe_close(fd);
return -1;
}
/*****************************************************************************/

View File

@@ -83,4 +83,3 @@ sd_notify (int unset_environment, const char *state)
#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
#endif /* __NM_SD_ADAPT_CORE_H__ */