summaryrefslogtreecommitdiff
path: root/util/kbc1126
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2017-08-12 09:20:55 +0800
committerMartin Roth <martinroth@google.com>2017-08-18 15:32:08 +0000
commit457fba6be5c2b31f6fc50a5e6feabf73a2663330 (patch)
treee305cc79c187c56396a97adcf6e6b547ca7f5088 /util/kbc1126
parent728d488ab39c44721300588f81626263e538cae5 (diff)
downloadcoreboot-457fba6be5c2b31f6fc50a5e6feabf73a2663330.tar.xz
kbc1126_ec_dump: fix some errors
- fix the error caused by signed integer extension - fix fopen mode - one minor style fix Change-Id: Iacc4ea50515ea219bc1868dae0446d576e8dce0c Signed-off-by: Iru Cai <mytbk920423@gmail.com> Reviewed-on: https://review.coreboot.org/21013 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'util/kbc1126')
-rw-r--r--util/kbc1126/kbc1126_ec_dump.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/util/kbc1126/kbc1126_ec_dump.c b/util/kbc1126/kbc1126_ec_dump.c
index 7470012799..124a475a28 100644
--- a/util/kbc1126/kbc1126_ec_dump.c
+++ b/util/kbc1126/kbc1126_ec_dump.c
@@ -49,9 +49,9 @@ void dump_fw(FILE *dst, FILE *src, long offset)
fread(&cksum, 2, 1, src);
fread(buf, len, 1, src);
- for (size_t i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++)
_cksum += buf[i];
- }
+
if (_cksum == cksum) {
puts("checksum ok");
} else {
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
if (argc != 2)
usage(argv[0]);
- FILE *fp = fopen(argv[1], "rb+");
+ FILE *fp = fopen(argv[1], "rb");
if (fp == NULL) {
puts("Error opening file!");
@@ -89,8 +89,8 @@ int main(int argc, char *argv[])
strcat(fn1, ".fw1");
strcat(fn2, ".fw2");
- FILE *fw1 = fopen(fn1, "wb+");
- FILE *fw2 = fopen(fn2, "wb+");
+ FILE *fw1 = fopen(fn1, "wb");
+ FILE *fw2 = fopen(fn2, "wb");
long romsz;
FseekEnd(fp, -1);
@@ -103,14 +103,14 @@ int main(int argc, char *argv[])
}
/* read offset of fw1 and fw2 */
- char offs[8];
+ unsigned char offs[8];
FseekEnd(fp, -0x100);
fread(offs, 8, 1, fp);
- assert(offs[0] + offs[2] == '\xff');
- assert(offs[1] + offs[3] == '\xff');
- assert(offs[4] + offs[6] == '\xff');
- assert(offs[5] + offs[7] == '\xff');
+ assert(offs[0] + offs[2] == 0xff);
+ assert(offs[1] + offs[3] == 0xff);
+ assert(offs[4] + offs[6] == 0xff);
+ assert(offs[5] + offs[7] == 0xff);
long offw1 = (offs[0] << 16) | (offs[1] << 8);
long offw2 = (offs[4] << 16) | (offs[5] << 8);