Merge pull request #10825 from keszybz/advertize-followup

udev link advertizing followup
This commit is contained in:
Lennart Poettering
2018-11-19 11:05:18 +01:00
committed by GitHub
7 changed files with 82 additions and 33 deletions
-7
View File
@@ -1577,11 +1577,4 @@ enum ethtool_link_mode_bit_indices {
#endif
#endif
/* Strictly speaking, this is not a missing field. Just for our convention. */
#if !HAVE_ETHTOOL_LINK_MODE_FEC_NONE_BIT
#define _ETHTOOL_LINK_MODE_MAX 52
#else
#define _ETHTOOL_LINK_MODE_MAX (__ETHTOOL_LINK_MODE_LAST + 1)
#endif
#include "missing_syscall.h"
+22
View File
@@ -165,6 +165,28 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
return NULL;
}
bool memeqzero(const void *data, size_t length) {
/* Does the buffer consist entirely of NULs?
* Copied from https://github.com/systemd/casync/, copied in turn from
* https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92,
* which is licensed CC-0.
*/
const uint8_t *p = data;
size_t i;
/* Check first 16 bytes manually */
for (i = 0; i < 16; i++, length--) {
if (length == 0)
return true;
if (p[i])
return false;
}
/* Now we know first 16 bytes are NUL, memcmp with self. */
return memcmp(data, p + i, length) == 0;
}
int on_ac_power(void) {
bool found_offline = false, found_online = false;
_cleanup_closedir_ DIR *d = NULL;
+4
View File
@@ -159,6 +159,10 @@ int on_ac_power(void);
#define zero(x) (memzero(&(x), sizeof(x)))
bool memeqzero(const void *data, size_t length);
#define eqzero(x) memeqzero(x, sizeof(x))
static inline void *mempset(void *s, int c, size_t n) {
memset(s, c, n);
return (uint8_t*)s + n;