diff options
-rw-r--r-- | CODING_STYLE | 7 | ||||
-rw-r--r-- | hwdb/20-bluetooth-vendor-product.hwdb | 75 | ||||
-rw-r--r-- | src/basic/bitmap.c | 16 | ||||
-rw-r--r-- | src/basic/util.c | 20 | ||||
-rw-r--r-- | src/basic/util.h | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/busctl.c | 24 | ||||
-rw-r--r-- | src/test/test-bitmap.c | 20 | ||||
-rw-r--r-- | src/test/test-util.c | 13 |
8 files changed, 148 insertions, 28 deletions
diff --git a/CODING_STYLE b/CODING_STYLE index dbadfbdb54..a96ddd3598 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -314,3 +314,10 @@ are always defined after more global ones. Thus, our local definitions will never "leak" into the global header files, possibly altering their effect due to #ifdeffery. + +- To implement an endless loop, use "for (;;)" rather than "while + (1)". The latter is a bit ugly anyway, since you probably really + meant "while (true)"... To avoid the discussion what the right + always-true expression for an infinite while() loop is our + recommendation is to simply write it without any such expression by + using "for (;;)". diff --git a/hwdb/20-bluetooth-vendor-product.hwdb b/hwdb/20-bluetooth-vendor-product.hwdb index dccced77da..35ea5e9e52 100644 --- a/hwdb/20-bluetooth-vendor-product.hwdb +++ b/hwdb/20-bluetooth-vendor-product.hwdb @@ -1772,3 +1772,78 @@ bluetooth:v024B* bluetooth:v024C* ID_VENDOR_FROM_DATABASE=Blue Clover Devices + +bluetooth:v024D* + ID_VENDOR_FROM_DATABASE=M-Way Solutions GmbH + +bluetooth:v024E* + ID_VENDOR_FROM_DATABASE=Microtronics Engineering GmbH + +bluetooth:v024F* + ID_VENDOR_FROM_DATABASE=Schneider Schreibgerte GmbH + +bluetooth:v0250* + ID_VENDOR_FROM_DATABASE=Sapphire Circuits LLC + +bluetooth:v0251* + ID_VENDOR_FROM_DATABASE=Lumo Bodytech Inc. + +bluetooth:v0252* + ID_VENDOR_FROM_DATABASE=UKC Technosolution + +bluetooth:v0253* + ID_VENDOR_FROM_DATABASE=Xicato Inc. + +bluetooth:v0254* + ID_VENDOR_FROM_DATABASE=Playbrush + +bluetooth:v0255* + ID_VENDOR_FROM_DATABASE=Dai Nippon Printing Co., Ltd. + +bluetooth:v0256* + ID_VENDOR_FROM_DATABASE=G24 Power Limited + +bluetooth:v0257* + ID_VENDOR_FROM_DATABASE=AdBabble Local Commerce Inc. + +bluetooth:v0258* + ID_VENDOR_FROM_DATABASE=Devialet SA + +bluetooth:v0259* + ID_VENDOR_FROM_DATABASE=ALTYOR + +bluetooth:v025A* + ID_VENDOR_FROM_DATABASE=University of Applied Sciences Valais/Haute Ecole Valaisanne + +bluetooth:v025B* + ID_VENDOR_FROM_DATABASE=Five Interactive, LLC dba Zendo + +bluetooth:v025C* + ID_VENDOR_FROM_DATABASE=NetEase (Hangzhou) Network co.Ltd. + +bluetooth:v025D* + ID_VENDOR_FROM_DATABASE=Lexmark International Inc. + +bluetooth:v025E* + ID_VENDOR_FROM_DATABASE=Fluke Corporation + +bluetooth:v025F* + ID_VENDOR_FROM_DATABASE=Yardarm Technologies + +bluetooth:v0260* + ID_VENDOR_FROM_DATABASE=SensaRx + +bluetooth:v0261* + ID_VENDOR_FROM_DATABASE=SECVRE GmbH + +bluetooth:v0262* + ID_VENDOR_FROM_DATABASE=Glacial Ridge Technologies + +bluetooth:v0263* + ID_VENDOR_FROM_DATABASE=Identiv, Inc. + +bluetooth:v0264* + ID_VENDOR_FROM_DATABASE=DDS, Inc. + +bluetooth:v0265* + ID_VENDOR_FROM_DATABASE=SMK Corporation diff --git a/src/basic/bitmap.c b/src/basic/bitmap.c index bf9d8d4d7c..7ea3357031 100644 --- a/src/basic/bitmap.c +++ b/src/basic/bitmap.c @@ -145,7 +145,10 @@ bool bitmap_isclear(Bitmap *b) { void bitmap_clear(Bitmap *b) { assert(b); + free(b->bitmaps); + b->bitmaps = NULL; b->n_bitmaps = 0; + b->bitmaps_allocated = 0; } bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) { @@ -184,6 +187,9 @@ bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) { } bool bitmap_equal(Bitmap *a, Bitmap *b) { + size_t common_n_bitmaps; + Bitmap *c; + unsigned i; if (!a ^ !b) return false; @@ -191,8 +197,14 @@ bool bitmap_equal(Bitmap *a, Bitmap *b) { if (!a) return true; - if (a->n_bitmaps != b->n_bitmaps) + common_n_bitmaps = MIN(a->n_bitmaps, b->n_bitmaps); + if (memcmp(a->bitmaps, b->bitmaps, sizeof(uint64_t) * common_n_bitmaps) != 0) return false; - return memcmp(a->bitmaps, b->bitmaps, sizeof(uint64_t) * a->n_bitmaps) == 0; + c = a->n_bitmaps > b->n_bitmaps ? a : b; + for (i = common_n_bitmaps; i < c->n_bitmaps; i++) + if (c->bitmaps[i] != 0) + return false; + + return true; } diff --git a/src/basic/util.c b/src/basic/util.c index 1c15fbc172..a968e2156d 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -115,17 +115,23 @@ size_t page_size(void) { return pgsz; } -bool streq_ptr(const char *a, const char *b) { - - /* Like streq(), but tries to make sense of NULL pointers */ +int strcmp_ptr(const char *a, const char *b) { + /* Like strcmp(), but tries to make sense of NULL pointers */ if (a && b) - return streq(a, b); + return strcmp(a, b); - if (!a && !b) - return true; + if (!a && b) + return -1; - return false; + if (a && !b) + return 1; + + return 0; +} + +bool streq_ptr(const char *a, const char *b) { + return strcmp_ptr(a, b) == 0; } char* endswith(const char *s, const char *postfix) { diff --git a/src/basic/util.h b/src/basic/util.h index 06c82665be..88c44273d4 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -71,6 +71,7 @@ size_t page_size(void) _pure_; #define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) bool streq_ptr(const char *a, const char *b) _pure_; +int strcmp_ptr(const char *a, const char *b) _pure_; #define new(t, n) ((t*) malloc_multiply(sizeof(t), (n))) diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 6aaaf0e5ec..1724292bbb 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -656,28 +656,15 @@ static int member_compare_func(const void *a, const void *b) { assert(x->type); assert(y->type); - if (!x->interface && y->interface) - return -1; - if (x->interface && !y->interface) - return 1; - if (x->interface && y->interface) { - d = strcmp(x->interface, y->interface); - if (d != 0) - return d; - } + d = strcmp_ptr(x->interface, y->interface); + if (d != 0) + return d; d = strcmp(x->type, y->type); if (d != 0) return d; - if (!x->name && y->name) - return -1; - if (x->name && !y->name) - return 1; - if (x->name && y->name) - return strcmp(x->name, y->name); - - return 0; + return strcmp_ptr(x->name, y->name); } static int member_compare_funcp(const void *a, const void *b) { @@ -1697,6 +1684,7 @@ static int help(void) { " --acquired Only show acquired names\n" " --activatable Only show activatable names\n" " --match=MATCH Only show matching messages\n" + " --size=SIZE Maximum length of captured packet\n" " --list Don't show tree, but simple object path list\n" " --quiet Don't show method call reply\n" " --verbose Show result values in long format\n" @@ -1837,7 +1825,7 @@ static int parse_argv(int argc, char *argv[]) { case ARG_SIZE: { off_t o; - r = parse_size(optarg, 0, &o); + r = parse_size(optarg, 1024, &o); if (r < 0) { log_error("Failed to parse size: %s", optarg); return r; diff --git a/src/test/test-bitmap.c b/src/test/test-bitmap.c index 96deeded7e..ff22117745 100644 --- a/src/test/test-bitmap.c +++ b/src/test/test-bitmap.c @@ -20,7 +20,7 @@ #include "bitmap.h" int main(int argc, const char *argv[]) { - _cleanup_bitmap_free_ Bitmap *b = NULL; + _cleanup_bitmap_free_ Bitmap *b = NULL, *b2 = NULL; Iterator it; unsigned n = (unsigned) -1, i = 0; @@ -101,5 +101,23 @@ int main(int argc, const char *argv[]) { assert_se(bitmap_set(b, (unsigned) -1) == -ERANGE); + bitmap_free(b); + b = NULL; + assert_se(bitmap_ensure_allocated(&b) == 0); + assert_se(bitmap_ensure_allocated(&b2) == 0); + + assert_se(bitmap_equal(b, b2)); + assert_se(bitmap_set(b, 0) == 0); + bitmap_unset(b, 0); + assert_se(bitmap_equal(b, b2)); + + assert_se(bitmap_set(b, 1) == 0); + bitmap_clear(b); + assert_se(bitmap_equal(b, b2)); + + assert_se(bitmap_set(b, 0) == 0); + assert_se(bitmap_set(b2, 0) == 0); + assert_se(bitmap_equal(b, b2)); + return 0; } diff --git a/src/test/test-util.c b/src/test/test-util.c index fde3fa0988..7619950320 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -2072,6 +2072,18 @@ static void test_tempfn(void) { free(ret); } +static void test_strcmp_ptr(void) { + assert_se(strcmp_ptr(NULL, NULL) == 0); + assert_se(strcmp_ptr("", NULL) > 0); + assert_se(strcmp_ptr("foo", NULL) > 0); + assert_se(strcmp_ptr(NULL, "") < 0); + assert_se(strcmp_ptr(NULL, "bar") < 0); + assert_se(strcmp_ptr("foo", "bar") > 0); + assert_se(strcmp_ptr("bar", "baz") < 0); + assert_se(strcmp_ptr("foo", "foo") == 0); + assert_se(strcmp_ptr("", "") == 0); +} + int main(int argc, char *argv[]) { log_parse_environment(); log_open(); @@ -2158,6 +2170,7 @@ int main(int argc, char *argv[]) { test_shell_maybe_quote(); test_parse_mode(); test_tempfn(); + test_strcmp_ptr(); return 0; } |