From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH v3 1/3] imd: replace magicvalue with sizeof(struct)
Date: Mon, 20 Jan 2020 15:58:19 +0100 [thread overview]
Message-ID: <20200120145821.22899-1-s.trumtrar@pengutronix.de> (raw)
Instead of using "8" as the size of an imd_header, use the sizeof operator.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
common/imd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/imd.c b/common/imd.c
index 913a01de87bf..e0dab69644c0 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -41,7 +41,7 @@ const struct imd_header *imd_next(const struct imd_header *imd)
length = imd_read_length(imd);
length = ALIGN(length, 4);
- length += 8;
+ length += sizeof(struct imd_header);
return (const void *)imd + length;
}
@@ -63,14 +63,14 @@ static int imd_next_validate(const void *buf, int bufsize, int start_ofs)
size = bufsize - start_ofs;
- if (size < 8) {
+ if (size < sizeof(struct imd_header)) {
debug("trunkated tag at offset %dd\n", start_ofs);
return -EINVAL;
}
length = imd_read_length(imd);
length = ALIGN(length, 4);
- length += 8;
+ length += sizeof(struct imd_header);
if (size < length) {
debug("tag at offset %d with size %d exceeds bufsize %d\n",
--
2.25.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2020-01-20 14:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 14:58 Steffen Trumtrar [this message]
2020-01-20 14:58 ` [PATCH v3 2/3] imd: add support for checksum generation/verification Steffen Trumtrar
2020-01-22 8:46 ` Sascha Hauer
2020-01-20 14:58 ` [PATCH v3 3/3] commands: bbu: add support for imd checksum Steffen Trumtrar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200120145821.22899-1-s.trumtrar@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox