mirror of
https://github.com/systemd/systemd
synced 2026-03-28 09:44:50 +01:00
Compare commits
No commits in common. "940e26c19c84c8b4fb01edb3439196cc53234b2b" and "53405835a2aa6e360863660f1e0e4d9a9688085f" have entirely different histories.
940e26c19c
...
53405835a2
@ -23,7 +23,7 @@
|
||||
#include "virt.h"
|
||||
|
||||
static int parse_chid_type(const char *s, size_t *ret) {
|
||||
const char *e;
|
||||
char *e;
|
||||
unsigned u;
|
||||
int r;
|
||||
|
||||
|
||||
@ -163,7 +163,9 @@ int proc_cmdline_strv(char ***ret) {
|
||||
}
|
||||
|
||||
static char *mangle_word(const char *word, ProcCmdlineFlags flags) {
|
||||
char *c = (char*) startswith(word, "rd.");
|
||||
char *c;
|
||||
|
||||
c = startswith(word, "rd.");
|
||||
if (c) {
|
||||
/* Filter out arguments that are intended only for the initrd */
|
||||
|
||||
@ -180,8 +182,6 @@ static char *mangle_word(const char *word, ProcCmdlineFlags flags) {
|
||||
return (char*) word;
|
||||
}
|
||||
|
||||
#define mangle_word(word, flags) const_generic(word, mangle_word(word, flags))
|
||||
|
||||
static int proc_cmdline_parse_strv(char **args, proc_cmdline_parse_t parse_item, void *data, ProcCmdlineFlags flags) {
|
||||
int r;
|
||||
|
||||
|
||||
@ -1869,7 +1869,7 @@ int vsock_parse_cid(const char *s, unsigned *ret) {
|
||||
int socket_address_parse_vsock(SocketAddress *ret_address, const char *s) {
|
||||
/* AF_VSOCK socket in vsock:cid:port notation */
|
||||
_cleanup_free_ char *n = NULL;
|
||||
const char *e, *cid_start;
|
||||
char *e, *cid_start;
|
||||
unsigned port, cid;
|
||||
int type, r;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* bsearch_safe_internal(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
|
||||
void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
|
||||
/**
|
||||
* Normal bsearch requires base to be nonnull. Here were require
|
||||
* that only if nmemb > 0.
|
||||
@ -40,7 +40,7 @@ void* bsearch_safe_internal(const void *key, const void *base, size_t nmemb, siz
|
||||
return NULL;
|
||||
|
||||
assert(base);
|
||||
return (void*) bsearch(key, base, nmemb, size, compar);
|
||||
return bsearch(key, base, nmemb, size, compar);
|
||||
}
|
||||
|
||||
void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
|
||||
|
||||
@ -13,9 +13,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
|
||||
(typeof((b)[0])*) xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \
|
||||
})
|
||||
|
||||
void* bsearch_safe_internal(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar);
|
||||
#define bsearch_safe(key, base, nmemb, size, compar) \
|
||||
const_generic((base), bsearch_safe_internal(key, base, nmemb, size, compar))
|
||||
void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar);
|
||||
|
||||
#define typesafe_bsearch(k, b, n, func) \
|
||||
({ \
|
||||
|
||||
@ -1339,14 +1339,16 @@ char* strdupcspn(const char *a, const char *reject) {
|
||||
return strndup(a, strcspn(a, reject));
|
||||
}
|
||||
|
||||
char* find_line_startswith_internal(const char *haystack, const char *needle) {
|
||||
char* find_line_startswith(const char *haystack, const char *needle) {
|
||||
char *p;
|
||||
|
||||
assert(haystack);
|
||||
assert(needle);
|
||||
|
||||
/* Finds the first line in 'haystack' that starts with the specified string. Returns a pointer to the
|
||||
* first character after it */
|
||||
|
||||
char *p = (char*) strstr(haystack, needle);
|
||||
p = strstr(haystack, needle);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
@ -1360,14 +1362,16 @@ char* find_line_startswith_internal(const char *haystack, const char *needle) {
|
||||
return p + strlen(needle);
|
||||
}
|
||||
|
||||
char* find_line_internal(const char *haystack, const char *needle) {
|
||||
char* find_line(const char *haystack, const char *needle) {
|
||||
char *p;
|
||||
|
||||
assert(haystack);
|
||||
assert(needle);
|
||||
|
||||
/* Finds the first line in 'haystack' that match the specified string. Returns a pointer to the
|
||||
* beginning of the line */
|
||||
|
||||
char *p = (char*) find_line_startswith(haystack, needle);
|
||||
p = find_line_startswith(haystack, needle);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
@ -1377,14 +1381,16 @@ char* find_line_internal(const char *haystack, const char *needle) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* find_line_after_internal(const char *haystack, const char *needle) {
|
||||
char* find_line_after(const char *haystack, const char *needle) {
|
||||
char *p;
|
||||
|
||||
assert(haystack);
|
||||
assert(needle);
|
||||
|
||||
/* Finds the first line in 'haystack' that match the specified string. Returns a pointer to the
|
||||
* next line after it */
|
||||
|
||||
char *p = (char*) find_line_startswith(haystack, needle);
|
||||
p = find_line_startswith(haystack, needle);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
@ -1484,7 +1490,7 @@ ssize_t strlevenshtein(const char *x, const char *y) {
|
||||
return t1[yl];
|
||||
}
|
||||
|
||||
char* strrstr_internal(const char *haystack, const char *needle) {
|
||||
char* strrstr(const char *haystack, const char *needle) {
|
||||
/* Like strstr() but returns the last rather than the first occurrence of "needle" in "haystack". */
|
||||
|
||||
if (!haystack || !needle)
|
||||
@ -1493,7 +1499,7 @@ char* strrstr_internal(const char *haystack, const char *needle) {
|
||||
/* Special case: for the empty string we return the very last possible occurrence, i.e. *after* the
|
||||
* last char, not before. */
|
||||
if (*needle == 0)
|
||||
return (char*) strchr(haystack, 0);
|
||||
return strchr(haystack, 0);
|
||||
|
||||
for (const char *p = strstr(haystack, needle), *q; p; p = q) {
|
||||
q = strstr(p + 1, needle);
|
||||
|
||||
@ -7,28 +7,24 @@
|
||||
#include "forward.h"
|
||||
#include "string-util-fundamental.h" /* IWYU pragma: export */
|
||||
|
||||
static inline char* strstr_ptr_internal(const char *haystack, const char *needle) {
|
||||
static inline char* strstr_ptr(const char *haystack, const char *needle) {
|
||||
if (!haystack || !needle)
|
||||
return NULL;
|
||||
return (char*) strstr(haystack, needle);
|
||||
return strstr(haystack, needle);
|
||||
}
|
||||
|
||||
#define strstr_ptr(haystack, needle) \
|
||||
const_generic(haystack, strstr_ptr_internal(haystack, needle))
|
||||
static inline char* strstrafter(const char *haystack, const char *needle) {
|
||||
char *p;
|
||||
|
||||
static inline char* strstrafter_internal(const char *haystack, const char *needle) {
|
||||
/* Returns NULL if not found, or pointer to first character after needle if found */
|
||||
|
||||
char *p = (char*) strstr_ptr(haystack, needle);
|
||||
p = strstr_ptr(haystack, needle);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
return p + strlen(needle);
|
||||
}
|
||||
|
||||
#define strstrafter(haystack, needle) \
|
||||
const_generic(haystack, strstrafter_internal(haystack, needle))
|
||||
|
||||
static inline const char* strnull(const char *s) {
|
||||
return s ?: "(null)";
|
||||
}
|
||||
@ -290,25 +286,15 @@ char* strdupcspn(const char *a, const char *reject);
|
||||
(char*) memdupa_suffix0(_t, strnlen(_t, n)); \
|
||||
})
|
||||
|
||||
char* find_line_startswith_internal(const char *haystack, const char *needle);
|
||||
#define find_line_startswith(haystack, needle) \
|
||||
const_generic(haystack, find_line_startswith_internal(haystack, needle))
|
||||
|
||||
char* find_line_internal(const char *haystack, const char *needle);
|
||||
#define find_line(haystack, needle) \
|
||||
const_generic(haystack, find_line_internal(haystack, needle))
|
||||
|
||||
char* find_line_after_internal(const char *haystack, const char *needle);
|
||||
#define find_line_after(haystack, needle) \
|
||||
const_generic(haystack, find_line_after_internal(haystack, needle))
|
||||
char* find_line_startswith(const char *haystack, const char *needle);
|
||||
char* find_line(const char *haystack, const char *needle);
|
||||
char* find_line_after(const char *haystack, const char *needle);
|
||||
|
||||
bool version_is_valid(const char *s) _pure_;
|
||||
bool version_is_valid_versionspec(const char *s) _pure_;
|
||||
|
||||
ssize_t strlevenshtein(const char *x, const char *y);
|
||||
|
||||
char* strrstr_internal(const char *haystack, const char *needle) _pure_;
|
||||
#define strrstr(haystack, needle) \
|
||||
const_generic(haystack, strrstr_internal(haystack, needle))
|
||||
char* strrstr(const char *haystack, const char *needle) _pure_;
|
||||
|
||||
size_t str_common_prefix(const char *a, const char *b) _pure_;
|
||||
|
||||
@ -921,9 +921,9 @@ int strv_extendf(char ***l, const char *format, ...) {
|
||||
return strv_consume(l, x);
|
||||
}
|
||||
|
||||
char* startswith_strv_internal(const char *s, char * const *l) {
|
||||
char* startswith_strv(const char *s, char * const *l) {
|
||||
STRV_FOREACH(i, l) {
|
||||
char *found = (char*) startswith(s, *i);
|
||||
char *found = startswith(s, *i);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
@ -931,9 +931,9 @@ char* startswith_strv_internal(const char *s, char * const *l) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* endswith_strv_internal(const char *s, char * const *l) {
|
||||
char* endswith_strv(const char *s, char * const *l) {
|
||||
STRV_FOREACH(i, l) {
|
||||
char *found = (char*) endswith(s, *i);
|
||||
char *found = endswith(s, *i);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -150,14 +150,12 @@ static inline void strv_print(char * const *l) {
|
||||
strv_print_full(l, NULL);
|
||||
}
|
||||
|
||||
char* startswith_strv_internal(const char *s, char * const *l);
|
||||
#define startswith_strv(s, l) const_generic(s, startswith_strv_internal(s, l))
|
||||
char* startswith_strv(const char *s, char * const *l);
|
||||
|
||||
#define STARTSWITH_SET(p, ...) \
|
||||
startswith_strv(p, STRV_MAKE(__VA_ARGS__))
|
||||
|
||||
char* endswith_strv_internal(const char *s, char * const *l);
|
||||
#define endswith_strv(s, l) const_generic(s, endswith_strv_internal(s, l))
|
||||
char* endswith_strv(const char *s, char * const *l);
|
||||
|
||||
#define ENDSWITH_SET(p, ...) \
|
||||
endswith_strv(p, STRV_MAKE(__VA_ARGS__))
|
||||
|
||||
@ -1119,7 +1119,9 @@ static const char* extract_multiplier(const char *p, usec_t *ret) {
|
||||
assert(ret);
|
||||
|
||||
FOREACH_ELEMENT(i, table) {
|
||||
const char *e = startswith(p, i->suffix);
|
||||
char *e;
|
||||
|
||||
e = startswith(p, i->suffix);
|
||||
if (e) {
|
||||
*ret = i->usec;
|
||||
return e;
|
||||
@ -1295,7 +1297,9 @@ static const char* extract_nsec_multiplier(const char *p, nsec_t *ret) {
|
||||
assert(ret);
|
||||
|
||||
FOREACH_ELEMENT(i, table) {
|
||||
const char *e = startswith(p, i->suffix);
|
||||
char *e;
|
||||
|
||||
e = startswith(p, i->suffix);
|
||||
if (e) {
|
||||
*ret = i->nsec;
|
||||
return e;
|
||||
|
||||
@ -213,7 +213,7 @@ UnitType unit_name_to_type(const char *n) {
|
||||
int unit_name_change_suffix(const char *n, const char *suffix, char **ret) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
size_t a, b;
|
||||
const char *e;
|
||||
char *e;
|
||||
|
||||
assert(n);
|
||||
assert(suffix);
|
||||
@ -521,7 +521,7 @@ int unit_name_template(const char *f, char **ret) {
|
||||
}
|
||||
|
||||
bool unit_name_is_hashed(const char *name) {
|
||||
const char *s;
|
||||
char *s;
|
||||
|
||||
if (!unit_name_is_valid(name, UNIT_NAME_PLAIN))
|
||||
return false;
|
||||
@ -544,7 +544,7 @@ bool unit_name_is_hashed(const char *name) {
|
||||
|
||||
int unit_name_hash_long(const char *name, char **ret) {
|
||||
_cleanup_free_ char *n = NULL, *hash = NULL;
|
||||
const char *suffix;
|
||||
char *suffix;
|
||||
le64_t h;
|
||||
size_t len;
|
||||
|
||||
@ -834,7 +834,7 @@ int slice_build_subslice(const char *slice, const char *name, char **ret) {
|
||||
if (streq(slice, SPECIAL_ROOT_SLICE))
|
||||
subslice = strjoin(name, ".slice");
|
||||
else {
|
||||
const char *e;
|
||||
char *e;
|
||||
|
||||
assert_se(e = endswith(slice, ".slice"));
|
||||
|
||||
|
||||
@ -1024,7 +1024,6 @@ _used_ void *memcpy(void * restrict dest, const void * restrict src, size_t n);
|
||||
_used_ void *memset(void *p, int c, size_t n);
|
||||
#else
|
||||
/* And for userspace unit testing we need to give them an efi_ prefix. */
|
||||
# undef memchr
|
||||
# define memchr efi_memchr
|
||||
# define memcmp efi_memcmp
|
||||
# define memcpy efi_memcpy
|
||||
|
||||
@ -2116,7 +2116,7 @@ static int build_environment(
|
||||
}
|
||||
|
||||
if (!sd_id128_is_null(p->invocation_id)) {
|
||||
assert(!isempty(p->invocation_id_string));
|
||||
assert(p->invocation_id_string);
|
||||
|
||||
x = strjoin("INVOCATION_ID=", p->invocation_id_string);
|
||||
if (!x)
|
||||
|
||||
@ -1778,7 +1778,7 @@ int config_parse_exec_root_hash_sig(
|
||||
void *userdata) {
|
||||
|
||||
_cleanup_free_ void *roothash_sig_decoded = NULL;
|
||||
const char *value;
|
||||
char *value;
|
||||
ExecContext *c = ASSERT_PTR(data);
|
||||
size_t roothash_sig_decoded_size = 0;
|
||||
int r;
|
||||
|
||||
@ -798,9 +798,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
static int add_crypttab_device(const char *name, const char *device, const char *keyspec, const char *options) {
|
||||
_cleanup_free_ char *keyfile = NULL, *keydev = NULL, *headerdev = NULL, *filtered_header = NULL;
|
||||
crypto_device *d = NULL;
|
||||
char *uuid;
|
||||
int r;
|
||||
|
||||
const char *uuid = startswith(device, "UUID=");
|
||||
uuid = startswith(device, "UUID=");
|
||||
if (!uuid)
|
||||
uuid = path_startswith(device, "/dev/disk/by-uuid/");
|
||||
if (!uuid)
|
||||
|
||||
@ -482,10 +482,3 @@ assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1);
|
||||
#else
|
||||
# define ENUM_TYPE_S64(id) id
|
||||
#endif
|
||||
|
||||
/* This macro is used to have a const-returning and non-const returning version of a function based on
|
||||
* whether its first argument is const or not (e.g. strstr()). */
|
||||
#define const_generic(ptr, call) \
|
||||
_Generic(0 ? (ptr) : (void*) 1, \
|
||||
const void*: (const typeof(*call)*) (call), \
|
||||
void*: (call))
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include "macro-fundamental.h"
|
||||
#include "string-util-fundamental.h"
|
||||
|
||||
sd_char *startswith_internal(const sd_char *s, const sd_char *prefix) {
|
||||
sd_char *startswith(const sd_char *s, const sd_char *prefix) {
|
||||
size_t l;
|
||||
|
||||
assert(s);
|
||||
@ -16,7 +16,7 @@ sd_char *startswith_internal(const sd_char *s, const sd_char *prefix) {
|
||||
return (sd_char*) s + l;
|
||||
}
|
||||
|
||||
sd_char *startswith_no_case_internal(const sd_char *s, const sd_char *prefix) {
|
||||
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
|
||||
size_t l;
|
||||
|
||||
assert(s);
|
||||
@ -29,7 +29,7 @@ sd_char *startswith_no_case_internal(const sd_char *s, const sd_char *prefix) {
|
||||
return (sd_char*) s + l;
|
||||
}
|
||||
|
||||
sd_char* endswith_internal(const sd_char *s, const sd_char *suffix) {
|
||||
sd_char* endswith(const sd_char *s, const sd_char *suffix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
@ -50,7 +50,7 @@ sd_char* endswith_internal(const sd_char *s, const sd_char *suffix) {
|
||||
return (sd_char*) s + sl - pl;
|
||||
}
|
||||
|
||||
sd_char* endswith_no_case_internal(const sd_char *s, const sd_char *suffix) {
|
||||
sd_char* endswith_no_case(const sd_char *s, const sd_char *suffix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
|
||||
@ -77,17 +77,10 @@ static inline size_t strlen_ptr(const sd_char *s) {
|
||||
return strlen(s);
|
||||
}
|
||||
|
||||
sd_char *startswith_internal(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
#define startswith(s, prefix) const_generic(s, startswith_internal(s, prefix))
|
||||
|
||||
sd_char *startswith_no_case_internal(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
#define startswith_no_case(s, prefix) const_generic(s, startswith_no_case_internal(s, prefix))
|
||||
|
||||
sd_char *endswith_internal(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
#define endswith(s, suffix) const_generic(s, endswith_internal(s, suffix))
|
||||
|
||||
sd_char *endswith_no_case_internal(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
#define endswith_no_case(s, suffix) const_generic(s, endswith_no_case_internal(s, suffix))
|
||||
sd_char *startswith(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
sd_char *endswith(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
sd_char *endswith_no_case(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
|
||||
static inline bool isempty(const sd_char *a) {
|
||||
return !a || a[0] == '\0';
|
||||
|
||||
@ -861,7 +861,7 @@ static int manager_assess_image(
|
||||
const char *dir_path,
|
||||
const char *dentry_name) {
|
||||
|
||||
const char *luks_suffix, *directory_suffix;
|
||||
char *luks_suffix, *directory_suffix;
|
||||
_cleanup_free_ char *path = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@ -151,8 +151,9 @@ int get_possible_units(
|
||||
|
||||
SD_JOURNAL_FOREACH_UNIQUE(j, data, size) {
|
||||
_cleanup_free_ char *u = NULL;
|
||||
char *eq;
|
||||
|
||||
const char *eq = memchr(data, '=', size);
|
||||
eq = memchr(data, '=', size);
|
||||
if (eq) {
|
||||
size -= eq - (char*) data + 1;
|
||||
data = ++eq;
|
||||
|
||||
@ -1437,7 +1437,7 @@ _public_ int sd_bus_open_user(sd_bus **ret) {
|
||||
|
||||
int bus_set_address_system_remote(sd_bus *b, const char *host) {
|
||||
_cleanup_free_ char *e = NULL;
|
||||
const char *m = NULL, *c = NULL, *a, *rbracket = NULL, *p = NULL;
|
||||
char *m = NULL, *c = NULL, *a, *rbracket = NULL, *p = NULL;
|
||||
|
||||
assert(b);
|
||||
assert(host);
|
||||
@ -1475,7 +1475,7 @@ int bus_set_address_system_remote(sd_bus *b, const char *host) {
|
||||
/* Let's see if a port was given */
|
||||
m = strchr(rbracket ? rbracket + 1 : host, ':');
|
||||
if (m) {
|
||||
const char *t;
|
||||
char *t;
|
||||
bool got_forward_slash = false;
|
||||
|
||||
p = m + 1;
|
||||
@ -1521,15 +1521,14 @@ interpret_port_as_machine_old_syntax:
|
||||
if (!ssh_escaped)
|
||||
return -ENOMEM;
|
||||
|
||||
char *address = strjoin(
|
||||
"unixexec:path=", ssh_escaped, ",argv1=-xT",
|
||||
p ? ",argv2=-p,argv3=" : "", strempty(p),
|
||||
",argv", p ? "4" : "2", "=--,argv", p ? "5" : "3", "=", e,
|
||||
",argv", p ? "6" : "4", "=systemd-stdio-bridge", c);
|
||||
if (!address)
|
||||
a = strjoin("unixexec:path=", ssh_escaped, ",argv1=-xT",
|
||||
p ? ",argv2=-p,argv3=" : "", strempty(p),
|
||||
",argv", p ? "4" : "2", "=--,argv", p ? "5" : "3", "=", e,
|
||||
",argv", p ? "6" : "4", "=systemd-stdio-bridge", c);
|
||||
if (!a)
|
||||
return -ENOMEM;
|
||||
|
||||
return free_and_replace(b->address, address);
|
||||
return free_and_replace(b->address, a);
|
||||
}
|
||||
|
||||
_public_ int sd_bus_open_system_remote(sd_bus **ret, const char *host) {
|
||||
|
||||
@ -95,7 +95,7 @@ static int trie_children_cmp_f(const void *v1, const void *v2) {
|
||||
}
|
||||
|
||||
static const struct trie_node_f *node_lookup_f(sd_hwdb *hwdb, const struct trie_node_f *node, uint8_t c) {
|
||||
const struct trie_child_entry_f *child;
|
||||
struct trie_child_entry_f *child;
|
||||
struct trie_child_entry_f search;
|
||||
|
||||
search.c = c;
|
||||
|
||||
@ -210,21 +210,23 @@ static int finish_item(
|
||||
}
|
||||
|
||||
int catalog_file_lang(const char *filename, char **ret) {
|
||||
char *beg, *end, *lang;
|
||||
|
||||
assert(filename);
|
||||
assert(ret);
|
||||
|
||||
const char *end = endswith(filename, ".catalog");
|
||||
end = endswith(filename, ".catalog");
|
||||
if (!end)
|
||||
return 0;
|
||||
|
||||
const char *beg = end - 1;
|
||||
beg = end - 1;
|
||||
while (beg > filename && !IN_SET(*beg, '.', '/') && end - beg < 32)
|
||||
beg--;
|
||||
|
||||
if (*beg != '.' || end <= beg + 1)
|
||||
return 0;
|
||||
|
||||
char *lang = strndup(beg + 1, end - beg - 1);
|
||||
lang = strndup(beg + 1, end - beg - 1);
|
||||
if (!lang)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -551,8 +553,7 @@ static int open_mmap(const char *database, int *ret_fd, struct stat *ret_st, voi
|
||||
}
|
||||
|
||||
static const char* find_id(const void *p, sd_id128_t id) {
|
||||
CatalogItem key = { .id = id };
|
||||
const CatalogItem *f = NULL;
|
||||
CatalogItem *f = NULL, key = { .id = id };
|
||||
const CatalogHeader *h = ASSERT_PTR(p);
|
||||
const char *loc;
|
||||
|
||||
|
||||
@ -786,6 +786,7 @@ int config_parse_dhcp_server_relay_agent_suboption(
|
||||
void *userdata) {
|
||||
|
||||
char **suboption_value = data;
|
||||
char* p;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -796,7 +797,7 @@ int config_parse_dhcp_server_relay_agent_suboption(
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *p = startswith(rvalue, "string:");
|
||||
p = startswith(rvalue, "string:");
|
||||
if (!p) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Failed to parse %s=%s'. Invalid format, ignoring.", lvalue, rvalue);
|
||||
|
||||
@ -1639,6 +1639,7 @@ static int bus_append_root_hash(sd_bus_message *m, const char *field, const char
|
||||
}
|
||||
|
||||
static int bus_append_root_hash_signature(sd_bus_message *m, const char *field, const char *eq) {
|
||||
char *value;
|
||||
_cleanup_free_ void *roothash_sig_decoded = NULL;
|
||||
size_t roothash_sig_decoded_size = 0;
|
||||
int r;
|
||||
@ -1647,8 +1648,7 @@ static int bus_append_root_hash_signature(sd_bus_message *m, const char *field,
|
||||
if (path_is_absolute(eq))
|
||||
return bus_append_string(m, "RootHashSignaturePath", eq);
|
||||
|
||||
const char *value = startswith(eq, "base64:");
|
||||
if (!value)
|
||||
if (!(value = startswith(eq, "base64:")))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to decode %s value '%s': neither a path nor starts with 'base64:'.",
|
||||
field, eq);
|
||||
|
||||
@ -298,7 +298,7 @@ bool pager_have(void) {
|
||||
|
||||
int show_man_page(const char *desc, bool null_stdio) {
|
||||
const char *args[4] = { "man", NULL, NULL, NULL };
|
||||
const char *e = NULL;
|
||||
char *e = NULL;
|
||||
pid_t pid;
|
||||
size_t k;
|
||||
int r;
|
||||
|
||||
@ -2391,7 +2391,7 @@ uint32_t scmp_act_kill_process(void) {
|
||||
|
||||
int parse_syscall_and_errno(const char *in, char **name, int *error) {
|
||||
_cleanup_free_ char *n = NULL;
|
||||
const char *p;
|
||||
char *p;
|
||||
int e = -1;
|
||||
|
||||
assert(in);
|
||||
|
||||
@ -343,7 +343,7 @@ static int make_choice(
|
||||
unsigned found_tries_done = UINT_MAX, found_tries_left = UINT_MAX;
|
||||
_cleanup_free_ char *dname = NULL;
|
||||
size_t found_architecture_index = SIZE_MAX;
|
||||
char *e;
|
||||
const char *e;
|
||||
|
||||
dname = strdup((*entry)->d_name);
|
||||
if (!dname)
|
||||
|
||||
@ -922,7 +922,7 @@ static int names_pci(UdevEvent *event, const char *prefix) {
|
||||
}
|
||||
|
||||
static int get_usb_specifier(sd_device *dev, char **ret) {
|
||||
char *ports, *config, *interf, *buf;
|
||||
char *ports, *config, *interf, *s, *buf;
|
||||
const char *sysname;
|
||||
int r;
|
||||
|
||||
@ -934,26 +934,26 @@ static int get_usb_specifier(sd_device *dev, char **ret) {
|
||||
return log_device_debug_errno(dev, r, "Failed to get sysname: %m");
|
||||
|
||||
/* get USB port number chain, configuration, interface */
|
||||
const char *s = strchr(sysname, '-');
|
||||
s = strchr(sysname, '-');
|
||||
if (!s)
|
||||
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sysname \"%s\" does not have '-' in the expected place.", sysname);
|
||||
|
||||
ports = strdupa_safe(s + 1);
|
||||
char *t = strchr(ports, ':');
|
||||
s = strchr(ports, ':');
|
||||
if (!s)
|
||||
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sysname \"%s\" does not have ':' in the expected place.", sysname);
|
||||
|
||||
*t = '\0';
|
||||
config = t + 1;
|
||||
*s = '\0';
|
||||
config = s + 1;
|
||||
s = strchr(config, '.');
|
||||
if (!s)
|
||||
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sysname \"%s\" does not have '.' in the expected place.", sysname);
|
||||
|
||||
*t = '\0';
|
||||
interf = t + 1;
|
||||
*s = '\0';
|
||||
interf = s + 1;
|
||||
|
||||
/* prefix every port number in the chain with "u" */
|
||||
string_replace_char(ports, '.', 'u');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user