Merge pull request #31124 from keszybz/various-small-tweaks

Various small tweaks
This commit is contained in:
Lennart Poettering 2024-01-30 17:08:21 +01:00 committed by GitHub
commit f65d44d1f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 29 deletions

View file

@ -37,9 +37,7 @@
<refsect1>
<title>Description</title>
<para>These configuration files control global network parameters.
Currently the DHCP Unique Identifier (DUID).</para>
<para>These configuration files control global network parameters.</para>
</refsect1>
<xi:include href="standard-conf.xml" xpointer="main-conf" />

View file

@ -20,7 +20,7 @@ typedef void* (*mfree_func_t)(void *p);
* proceeding and smashing the stack limits. Note that by default RLIMIT_STACK is 8M on Linux. */
#define ALLOCA_MAX (4U*1024U*1024U)
#define new(t, n) ((t*) malloc_multiply((n), sizeof(t)))
#define new(t, n) ((t*) malloc_multiply(n, sizeof(t)))
#define new0(t, n) ((t*) calloc((n) ?: 1, sizeof(t)))
@ -45,9 +45,9 @@ typedef void* (*mfree_func_t)(void *p);
(t*) alloca0((sizeof(t)*_n_)); \
})
#define newdup(t, p, n) ((t*) memdup_multiply(p, (n), sizeof(t)))
#define newdup(t, p, n) ((t*) memdup_multiply(p, n, sizeof(t)))
#define newdup_suffix0(t, p, n) ((t*) memdup_suffix0_multiply(p, (n), sizeof(t)))
#define newdup_suffix0(t, p, n) ((t*) memdup_suffix0_multiply(p, n, sizeof(t)))
#define malloc0(n) (calloc(1, (n) ?: 1))
@ -237,7 +237,7 @@ static inline size_t malloc_sizeof_safe(void **xp) {
#define strndupa_safe(s, n) \
({ \
const char *_t = (s); \
(char*) memdupa_suffix0(_t, strnlen(_t, (n))); \
(char*) memdupa_suffix0(_t, strnlen(_t, n)); \
})
/* Free every element of the array. */

View file

@ -103,7 +103,7 @@ static int acquire_first_emergency_log_message(char **ret) {
if (r < 0)
return log_error_errno(r, "Failed to read journal message: %m");
message = memdup_suffix0((const char*)d + STRLEN("MESSAGE="), l - STRLEN("MESSAGE="));
message = memdup_suffix0((const char*)d + strlen("MESSAGE="), l - strlen("MESSAGE="));
if (!message)
return log_oom();

View file

@ -2507,7 +2507,7 @@ int server_new(Server **ret) {
int server_init(Server *s, const char *namespace) {
const char *native_socket, *syslog_socket, *stdout_socket, *varlink_socket, *e;
_cleanup_fdset_free_ FDSet *fds = NULL;
int n, r, fd, varlink_fd = -EBADF;
int n, r, varlink_fd = -EBADF;
bool no_sockets;
assert(s);
@ -2575,7 +2575,7 @@ int server_init(Server *s, const char *namespace) {
syslog_socket = strjoina(s->runtime_directory, "/dev-log");
varlink_socket = strjoina(s->runtime_directory, "/io.systemd.journal");
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) {
for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++)
if (sd_is_socket_unix(fd, SOCK_DGRAM, -1, native_socket, 0) > 0) {
@ -2628,7 +2628,6 @@ int server_init(Server *s, const char *namespace) {
if (r < 0)
return log_oom();
}
}
/* Try to restore streams, but don't bother if this fails */
(void) server_restore_streams(s, fds);

View file

@ -56,9 +56,9 @@ typedef enum PStoreStorage {
} PStoreStorage;
static const char* const pstore_storage_table[_PSTORE_STORAGE_MAX] = {
[PSTORE_STORAGE_NONE] = "none",
[PSTORE_STORAGE_NONE] = "none",
[PSTORE_STORAGE_EXTERNAL] = "external",
[PSTORE_STORAGE_JOURNAL] = "journal",
[PSTORE_STORAGE_JOURNAL] = "journal",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(pstore_storage, PStoreStorage);
@ -279,6 +279,7 @@ static int process_dmesg_files(PStoreList *list) {
} else
log_debug("Unknown backend, ignoring \"%s\".", pe->dirent.d_name);
}
return 0;
}

View file

@ -294,14 +294,12 @@ void print_separator(void) {
* one line filled with spaces with ANSI underline set, followed by a second (empty) line. */
if (underline_enabled()) {
size_t i, c;
c = columns();
size_t c = columns();
flockfile(stdout);
fputs_unlocked(ANSI_UNDERLINE, stdout);
for (i = 0; i < c; i++)
for (size_t i = 0; i < c; i++)
fputc_unlocked(' ', stdout);
fputs_unlocked(ANSI_NORMAL "\n\n", stdout);
@ -350,24 +348,17 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection,
if (path_equal(n, "udev/hwdb.d"))
ext = ".hwdb";
if (path_equal(n, "udev/rules.d"))
else if (path_equal(n, "udev/rules.d"))
ext = ".rules";
if (path_equal(n, "kernel/install.d"))
else if (path_equal(n, "kernel/install.d"))
ext = ".install";
if (path_equal(n, "systemd/ntp-units.d")) {
else if (path_equal(n, "systemd/ntp-units.d")) {
coll = true;
ext = ".list";
}
if (path_equal(n, "systemd/relabel-extra.d")) {
} else if (path_equal(n, "systemd/relabel-extra.d")) {
coll = run = true;
ext = ".relabel";
}
if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) {
} else if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) {
coll = true;
ext = ".preset";
}