Merge pull request #16057 from keszybz/resolvectl-sorted-no-nta
Drop NTA lists from resolvectl status and sort output by link number
This commit is contained in:
@@ -39,7 +39,7 @@ static inline void* bsearch_safe(const void *key, const void *base,
|
||||
* Normal qsort requires base to be nonnull. Here were require
|
||||
* that only if nmemb > 0.
|
||||
*/
|
||||
static inline void qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn_t compar) {
|
||||
static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn_t compar) {
|
||||
if (nmemb <= 1)
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,7 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn
|
||||
#define typesafe_qsort(p, n, func) \
|
||||
({ \
|
||||
int (*_func_)(const typeof(p[0])*, const typeof(p[0])*) = func; \
|
||||
qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \
|
||||
_qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \
|
||||
})
|
||||
|
||||
static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) {
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
#include "util.h"
|
||||
|
||||
int strcmp_ptr(const char *a, const char *b) {
|
||||
|
||||
/* Like strcmp(), but tries to make sense of NULL pointers */
|
||||
|
||||
if (a && b)
|
||||
return strcmp(a, b);
|
||||
return CMP(a, b); /* Direct comparison of pointers, one of which is NULL */
|
||||
}
|
||||
|
||||
if (!a && b)
|
||||
return -1;
|
||||
int strcasecmp_ptr(const char *a, const char *b) {
|
||||
/* Like strcasecmp(), but tries to make sense of NULL pointers */
|
||||
|
||||
if (a && !b)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
if (a && b)
|
||||
return strcasecmp(a, b);
|
||||
return CMP(a, b); /* Direct comparison of pointers, one of which is NULL */
|
||||
}
|
||||
|
||||
char* endswith(const char *s, const char *postfix) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
|
||||
|
||||
int strcmp_ptr(const char *a, const char *b) _pure_;
|
||||
int strcasecmp_ptr(const char *a, const char *b) _pure_;
|
||||
|
||||
static inline bool streq_ptr(const char *a, const char *b) {
|
||||
return strcmp_ptr(a, b) == 0;
|
||||
|
||||
Reference in New Issue
Block a user