From: Yu Watanabe Date: Sat, 18 Jan 2025 23:28:14 +0000 (+0900) Subject: tree-wide: coding style fixlets done by coccinelle X-Git-Tag: v258-rc1~1561^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F36074%2Fhead;p=thirdparty%2Fsystemd.git tree-wide: coding style fixlets done by coccinelle --- diff --git a/src/boot/boot.c b/src/boot/boot.c index 4ef519d4040..a4e0b5551f4 100644 --- a/src/boot/boot.c +++ b/src/boot/boot.c @@ -1179,12 +1179,11 @@ static void config_add_entry(Config *config, BootEntry *entry) { /* This is just for paranoia. */ assert(config->n_entries < IDX_MAX); - if ((config->n_entries & 15) == 0) { + if ((config->n_entries & 15) == 0) config->entries = xrealloc( config->entries, sizeof(void *) * config->n_entries, sizeof(void *) * (config->n_entries + 16)); - } config->entries[config->n_entries++] = entry; } diff --git a/src/boot/console.c b/src/boot/console.c index 067ee7c091c..b174146cdf0 100644 --- a/src/boot/console.c +++ b/src/boot/console.c @@ -117,10 +117,8 @@ EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) { /* If the extra input device we found returns something, always use that instead * to work around broken firmware freezing on ConIn/ConInEx. */ - if (extraInEx && BS->CheckEvent(extraInEx->WaitForKeyEx) == EFI_SUCCESS) { - conInEx = extraInEx; - extraInEx = NULL; - } + if (extraInEx && BS->CheckEvent(extraInEx->WaitForKeyEx) == EFI_SUCCESS) + conInEx = TAKE_PTR(extraInEx); /* Do not fall back to ConIn if we have a ConIn that supports TextInputEx. * The two may be out of sync on some firmware, giving us double input. */ diff --git a/src/boot/random-seed.c b/src/boot/random-seed.c index 920f55eefc8..88fda5184a8 100644 --- a/src/boot/random-seed.c +++ b/src/boot/random-seed.c @@ -199,7 +199,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir) { EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); if (err != EFI_SUCCESS) { - if (err != EFI_NOT_FOUND && err != EFI_WRITE_PROTECTED) + if (!IN_SET(err, EFI_NOT_FOUND, EFI_WRITE_PROTECTED)) log_error_status(err, "Failed to open random seed file: %m"); return err; } diff --git a/src/boot/splash.c b/src/boot/splash.c index 8daeb71cb25..7cf8d0d0c94 100644 --- a/src/boot/splash.c +++ b/src/boot/splash.c @@ -86,7 +86,7 @@ static EFI_STATUS bmp_parse_header( case 16: case 32: - if (dib->compression != 0 && dib->compression != 3) + if (!IN_SET(dib->compression, 0, 3)) return EFI_UNSUPPORTED; break; diff --git a/src/boot/util.c b/src/boot/util.c index f5f748bc6cf..ae1ad12e7be 100644 --- a/src/boot/util.c +++ b/src/boot/util.c @@ -280,8 +280,7 @@ EFI_STATUS readdir( if (sz == 0) { /* End of directory */ - free(*buffer); - *buffer = NULL; + *buffer = mfree(*buffer); *buffer_size = 0; } @@ -306,8 +305,7 @@ char16_t **strv_free(char16_t **v) { for (char16_t **i = v; *i; i++) free(*i); - free(v); - return NULL; + return mfree(v); } EFI_STATUS open_directory( diff --git a/src/nsresourced/nsresourcework.c b/src/nsresourced/nsresourcework.c index 8c43581d8fe..08277473e26 100644 --- a/src/nsresourced/nsresourcework.c +++ b/src/nsresourced/nsresourcework.c @@ -1422,7 +1422,7 @@ static void hash_ether_addr(UserNamespaceInfo *userns_info, const char *ifname, siphash24_compress_string(strempty(ifname), &state); siphash24_compress_byte(0, &state); /* separator */ n = htole64(n); /* add the 'index' to the mix in an endianess-independent fashion */ - siphash24_compress(&n, sizeof(n), &state); + siphash24_compress_typesafe(n, &state); h = htole64(siphash24_finalize(&state));