Merge pull request #12049 from keszybz/assorted-fixups

Assorted fixups
This commit is contained in:
Lennart Poettering 2019-03-20 18:27:34 +01:00 committed by GitHub
commit 4bf953d91b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 6 deletions

4
TODO
View file

@ -700,6 +700,10 @@ Features:
- honor language efi variables for default language selection (if there are any?)
- honor timezone efi variables for default timezone selection (if there are any?)
- change bootctl to be backed by systemd-bootd to control temporary and persistent default boot goal plus efi variables
* bootctl
- verify that the files boot entries point to exist
- recognize the case when not booted on EFI
- specify paths for boot entries
* maybe do not install getty@tty1.service symlink in /etc but in /usr?

View file

@ -1744,7 +1744,9 @@ static int add_object_vtable_internal(
assert_return(interface_name_is_valid(interface), -EINVAL);
assert_return(vtable, -EINVAL);
assert_return(vtable[0].type == _SD_BUS_VTABLE_START, -EINVAL);
assert_return(IN_SET(vtable[0].x.start.element_size, VTABLE_ELEMENT_SIZE_ORIGINAL, VTABLE_ELEMENT_SIZE), -EINVAL);
assert_return(vtable[0].x.start.element_size == VTABLE_ELEMENT_SIZE_ORIGINAL ||
vtable[0].x.start.element_size == VTABLE_ELEMENT_SIZE,
-EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!streq(interface, "org.freedesktop.DBus.Properties") &&
!streq(interface, "org.freedesktop.DBus.Introspectable") &&

View file

@ -160,7 +160,6 @@ static int bus_socket_write_auth(sd_bus *b) {
static int bus_socket_auth_verify_client(sd_bus *b) {
char *d, *e, *f, *start;
sd_id128_t peer;
unsigned i;
int r;
assert(b);
@ -205,9 +204,8 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
*/
if (memcmp(b->rbuffer, "OK ", 3))
return -EPERM;
} else {
} else
return -EPERM;
}
/* Now check the OK line. */
@ -219,7 +217,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
b->auth = b->anonymous_auth ? BUS_AUTH_ANONYMOUS : BUS_AUTH_EXTERNAL;
for (i = 0; i < 32; i += 2) {
for (unsigned i = 0; i < 32; i += 2) {
int x, y;
x = unhexchar(d[2 + 3 + i]);

View file

@ -19,6 +19,25 @@ static void test_alloca(void) {
assert_se(!memcmp(t, zero, 997));
}
static void test_GREEDY_REALLOC(void) {
_cleanup_free_ int *a = NULL, *b = NULL;
size_t n_allocated = 0, i;
/* Give valgrind a chance to verify our realloc operations */
for (i = 0; i < 2048; i++) {
assert_se(GREEDY_REALLOC(a, n_allocated, i + 1));
a[i] = i;
assert_se(GREEDY_REALLOC(a, n_allocated, i / 2));
}
for (i = 30, n_allocated = 0; i < 2048; i+=7) {
assert_se(GREEDY_REALLOC(b, n_allocated, i + 1));
b[i] = i;
assert_se(GREEDY_REALLOC(b, n_allocated, i / 2));
}
}
static void test_memdup_multiply_and_greedy_realloc(void) {
int org[] = {1, 2, 3};
_cleanup_free_ int *dup;
@ -74,6 +93,7 @@ static void test_bool_assign(void) {
int main(int argc, char *argv[]) {
test_alloca();
test_GREEDY_REALLOC();
test_memdup_multiply_and_greedy_realloc();
test_bool_assign();

View file

@ -629,6 +629,10 @@ static void test_tempfn(void) {
static const char chars[] =
"Aąę„”\n\377";
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
static void test_fgetc(void) {
_cleanup_fclose_ FILE *f = NULL;
char c;
@ -640,7 +644,7 @@ static void test_fgetc(void) {
assert_se(safe_fgetc(f, &c) == 1);
assert_se(c == chars[i]);
/* EOF is -1, and hence we can't push value 255 in this way */
/* EOF is -1, and hence we can't push value 255 in this way if char is signed */
assert_se(ungetc(c, f) != EOF || c == EOF);
assert_se(c == EOF || safe_fgetc(f, &c) == 1);
assert_se(c == chars[i]);
@ -654,6 +658,8 @@ static void test_fgetc(void) {
assert_se(safe_fgetc(f, &c) == 0);
}
#pragma GCC diagnostic pop
static const char buffer[] =
"Some test data\n"
"루Non-ascii chars: ąę„”\n"