X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fmkenvimage.c;h=bbd3041e36f4e5a2ac909fbe101ecfdd91b6345b;hb=ce3ca05d77a0b7e80afa111080b16d9d61a88a59;hp=3a20b23ed16eb856613b4f571c6c257eb31a4732;hpb=dc6449a9d8c27899b9bbdaaf49d1535f7a41fd8e;p=u-boot diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 3a20b23ed1..bbd3041e36 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -6,28 +6,9 @@ * (C) Copyright 2001 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ -/* We want the GNU version of basename() */ -#define _GNU_SOURCE - #include #include #include @@ -35,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -213,7 +195,7 @@ int main(int argc, char **argv) filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ, MAP_PRIVATE, txt_fd, 0); if (filebuf == MAP_FAILED) { - fprintf(stderr, "mmap (%ld bytes) failed: %s\n", + fprintf(stderr, "mmap (%zu bytes) failed: %s\n", sizeof(*envptr) * filesize, strerror(errno)); fprintf(stderr, "Falling back to read()\n"); @@ -221,7 +203,7 @@ int main(int argc, char **argv) filebuf = malloc(sizeof(*envptr) * filesize); ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize); if (ret != sizeof(*envptr) * filesize) { - fprintf(stderr, "Can't read the whole input file (%ld bytes): %s\n", + fprintf(stderr, "Can't read the whole input file (%zu bytes): %s\n", sizeof(*envptr) * filesize, strerror(errno)); @@ -285,7 +267,9 @@ int main(int argc, char **argv) crc = crc32(0, envptr, envsize); targetendian_crc = bigendian ? cpu_to_be32(crc) : cpu_to_le32(crc); - memcpy(dataptr, &targetendian_crc, sizeof(uint32_t)); + memcpy(dataptr, &targetendian_crc, sizeof(targetendian_crc)); + if (redundant) + dataptr[sizeof(targetendian_crc)] = 1; if (!bin_filename || strcmp(bin_filename, "-") == 0) { bin_fd = STDOUT_FILENO;