From 5f1d6ebd2a10799bdc17649857b721e9faf15d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 30 Nov 2021 18:42:32 +0100 Subject: [PATCH 1/4] oomd: use type suffix instead of casting The end result is the same. --- src/oom/oomd-manager.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c index b0d365e46b..9f4f083ab9 100644 --- a/src/oom/oomd-manager.c +++ b/src/oom/oomd-manager.c @@ -108,10 +108,7 @@ static int process_managed_oom_message(Manager *m, uid_t uid, JsonVariant *param if (streq(message.property, "ManagedOOMMemoryPressure") && message.limit > 0) { int permyriad = UINT32_SCALE_TO_PERMYRIAD(message.limit); - r = store_loadavg_fixed_point( - (unsigned long) permyriad / 100, - (unsigned long) permyriad % 100, - &limit); + r = store_loadavg_fixed_point(permyriad / 100LU, permyriad % 100LU, &limit); if (r < 0) continue; } From 75c293f37df7e12b6fbc8fdcbdc21092de44dd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 26 Nov 2021 10:28:18 +0100 Subject: [PATCH 2/4] test-sizeof: show stack and heap randomization It's useful to reassure yourself those those things actually work ;) --- src/test/test-sizeof.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c index e86844b8ce..f349852553 100644 --- a/src/test/test-sizeof.c +++ b/src/test/test-sizeof.c @@ -93,5 +93,13 @@ int main(void) { printf("timeval: %zu\n", sizeof(struct timeval)); printf("timespec: %zu\n", sizeof(struct timespec)); + + void *x = malloc(100); + + printf("local variable: %p\n", &function_pointer); + printf("glibc function: %p\n", memcpy); + printf("heap allocation: %p\n", x); + free(x); + return 0; } From baf60a80b590c390347862dbaba56c2aaa37f86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 28 Nov 2021 12:30:52 +0100 Subject: [PATCH 3/4] man: prettify line number handling in python example This way the 'line_number' variable contains the actual line number as we think of it, instead of adjusting it on output. --- man/check-os-release.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/check-os-release.py b/man/check-os-release.py index 009eb8e4d5..dbac79fd70 100644 --- a/man/check-os-release.py +++ b/man/check-os-release.py @@ -13,7 +13,7 @@ def read_os_release(): filename = '/usr/lib/os-release' f = open(filename) - for line_number, line in enumerate(f): + for line_number, line in enumerate(f, start=1): line = line.rstrip() if not line or line.startswith('#'): continue @@ -23,7 +23,7 @@ def read_os_release(): val = ast.literal_eval(val) yield name, val else: - print(f'{filename}:{line_number + 1}: bad line {line!r}', + print(f'{filename}:{line_number}: bad line {line!r}', file=sys.stderr) os_release = dict(read_os_release()) From 160dadc0350c77d612aa9d5569f57d9bc84c3dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 23 Nov 2021 15:05:58 +0100 Subject: [PATCH 4/4] tmpfiles: 'st' may have been used uninitialized --- src/shared/rm-rf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/rm-rf.c b/src/shared/rm-rf.c index a8693660fa..81ee5c37ba 100644 --- a/src/shared/rm-rf.c +++ b/src/shared/rm-rf.c @@ -129,7 +129,9 @@ static int rm_rf_children_inner( assert(fd >= 0); assert(fname); - if (is_dir < 0 || (is_dir > 0 && (root_dev || (flags & REMOVE_SUBVOLUME)))) { + if (is_dir < 0 || + root_dev || + (is_dir > 0 && (root_dev || (flags & REMOVE_SUBVOLUME)))) { r = fstatat_harder(fd, fname, &st, AT_SYMLINK_NOFOLLOW, flags); if (r < 0)