From b312114719aed5aa1ba8cafa16e1cde3a3d25af6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jan 2016 06:41:45 +1030 Subject: [PATCH] pkt: don't convert endian on header. This is now only used for internal tests, so endian conversion is overkill. Signed-off-by: Rusty Russell --- pkt.c | 7 +++---- pkt.h | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkt.c b/pkt.c index 0814baa66..7c350d9fd 100644 --- a/pkt.c +++ b/pkt.c @@ -10,7 +10,7 @@ size_t pkt_totlen(const struct pkt *pkt) { - return sizeof(pkt->len) + le32_to_cpu(pkt->len); + return sizeof(pkt->len) + pkt->len; } static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg) @@ -25,7 +25,7 @@ static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg) len = pkt__get_packed_size(&p); ret = (struct pkt *)tal_arr(ctx, u8, sizeof(ret->len) + len); - ret->len = cpu_to_le32(len); + ret->len = len; pkt__pack(&p, ret->data); return ret; @@ -84,8 +84,7 @@ Pkt *any_pkt_from_file(const char *filename) err(1, "Opening %s", filename); len = tal_count(pkt) - 1; - if (len < sizeof(pkt->len) - || len != sizeof(pkt->len) + le32_to_cpu(pkt->len)) + if (len < sizeof(pkt->len) || len != sizeof(pkt->len) + pkt->len) errx(1, "%s length is wrong", filename); len -= sizeof(pkt->len); diff --git a/pkt.h b/pkt.h index eacc9a44f..b0f6b2f85 100644 --- a/pkt.h +++ b/pkt.h @@ -8,13 +8,12 @@ * insisted on "prettifing" the names they generate into CamelCase. */ #include "lightning.pb-c.h" -#include #include #include /* A packet, ready to be de-protobuf'ed. */ struct pkt { - le32 len; + u32 len; u8 data[]; };