From f1a13749dff97b026163ce2ecc385adbec013661 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 2 Feb 2022 16:45:29 +0000 Subject: [PATCH] genprotimg: pv_comp: remove useless function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The endianness handling is already done before, so there is no need for this function. Let's remove the useless `uint64_to_uint8_buf` function. Suggested-by: Steffen Eiden Signed-off-by: Marc Hartmayer Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- genprotimg/src/pv/pv_comp.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/genprotimg/src/pv/pv_comp.c b/genprotimg/src/pv/pv_comp.c index f37210c8..41c4b8d8 100644 --- a/genprotimg/src/pv/pv_comp.c +++ b/genprotimg/src/pv/pv_comp.c @@ -248,19 +248,6 @@ gint pv_component_align(PvComponent *component, const gchar *tmp_path, g_assert_not_reached(); } -/* Convert uint64_t address to byte array */ -static void uint64_to_uint8_buf(uint8_t dst[8], uint64_t addr) -{ - uint8_t *p = (uint8_t *)&addr; - - g_assert(dst); - - for (gint i = 0; i < 8; i++) { - /* cppcheck-suppress objectIndex */ - dst[i] = p[i]; - } -} - int64_t pv_component_update_ald(const PvComponent *comp, EVP_MD_CTX *ctx, GError **err) { @@ -273,11 +260,8 @@ int64_t pv_component_update_ald(const PvComponent *comp, EVP_MD_CTX *ctx, do { uint64_t cur_be = GUINT64_TO_BE(cur); - uint8_t addr_buf[8]; - uint64_to_uint8_buf(addr_buf, cur_be); - - if (EVP_DigestUpdate(ctx, addr_buf, sizeof(addr_buf)) != 1) { + if (EVP_DigestUpdate(ctx, &cur_be, sizeof(cur_be)) != 1) { g_set_error(err, PV_CRYPTO_ERROR, PV_CRYPTO_ERROR_INTERNAL, _("EVP_DigestUpdate failed"));