]> git.sur5r.net Git - u-boot/blobdiff - tools/mkimage.c
License cleanup: remove unintended "All Rights Reserved" notices.
[u-boot] / tools / mkimage.c
index ea7a826f8c2292d666fba8b53643b0fc29ce095a..7fd9fd1aeb88abb108fc0a7d042e69a723dbe176 100644 (file)
@@ -4,7 +4,6 @@
  * (C) Copyright 2000-2004
  * DENX Software Engineering
  * Wolfgang Denk, wd@denx.de
- * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
 #include "mkimage.h"
 #include <image.h>
 
-extern int errno;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (-1)
-#endif
-
 extern unsigned long   crc32 (unsigned long crc, const char *buf, unsigned int len);
 static void            copy_file (int, const char *, int);
 static void            usage (void);
@@ -218,9 +211,8 @@ NXTARG:             ;
                        exit (EXIT_FAILURE);
                }
 
-               ptr = (unsigned char *)mmap(0, sbuf.st_size,
-                                           PROT_READ, MAP_SHARED, ifd, 0);
-               if ((caddr_t)ptr == (caddr_t)-1) {
+               ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, ifd, 0);
+               if (ptr == MAP_FAILED) {
                        fprintf (stderr, "%s: Can't read %s: %s\n",
                                cmdname, imagefile, strerror(errno));
                        exit (EXIT_FAILURE);
@@ -330,9 +322,8 @@ NXTARG:             ;
                exit (EXIT_FAILURE);
        }
 
-       ptr = (unsigned char *)mmap(0, sbuf.st_size,
-                                   PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0);
-       if (ptr == (unsigned char *)MAP_FAILED) {
+       ptr = mmap(0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0);
+       if (ptr == MAP_FAILED) {
                fprintf (stderr, "%s: Can't map %s: %s\n",
                        cmdname, imagefile, strerror(errno));
                exit (EXIT_FAILURE);
@@ -410,9 +401,8 @@ copy_file (int ifd, const char *datafile, int pad)
                exit (EXIT_FAILURE);
        }
 
-       ptr = (unsigned char *)mmap(0, sbuf.st_size,
-                                   PROT_READ, MAP_SHARED, dfd, 0);
-       if (ptr == (unsigned char *)MAP_FAILED) {
+       ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, dfd, 0);
+       if (ptr == MAP_FAILED) {
                fprintf (stderr, "%s: Can't read %s: %s\n",
                        cmdname, datafile, strerror(errno));
                exit (EXIT_FAILURE);
@@ -505,7 +495,7 @@ image_verify_header (char *ptr, int image_size)
         */
        memcpy (hdr, ptr, sizeof(image_header_t));
 
-       if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+       if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
                fprintf (stderr,
                        "%s: Bad Magic Number: \"%s\" is no valid image\n",
                        cmdname, imagefile);
@@ -515,8 +505,8 @@ image_verify_header (char *ptr, int image_size)
        data = (char *)hdr;
        len  = sizeof(image_header_t);
 
-       checksum = ntohl(hdr->ih_hcrc);
-       hdr->ih_hcrc = htonl(0);        /* clear for re-calculation */
+       checksum = be32_to_cpu(hdr->ih_hcrc);
+       hdr->ih_hcrc = cpu_to_be32(0);  /* clear for re-calculation */
 
        if (crc32 (0, data, len) != checksum) {
                fprintf (stderr,
@@ -528,7 +518,7 @@ image_verify_header (char *ptr, int image_size)
        data = ptr + sizeof(image_header_t);
        len  = image_size - sizeof(image_header_t) ;
 
-       if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+       if (crc32 (0, data, len) != be32_to_cpu(hdr->ih_dcrc)) {
                fprintf (stderr,
                        "%s: ERROR: \"%s\" has corrupted data!\n",
                        cmdname, imagefile);
@@ -594,9 +584,8 @@ static void fit_handle_file (void)
                exit (EXIT_FAILURE);
        }
 
-       ptr = (unsigned char *)mmap (0, sbuf.st_size,
-                       PROT_READ|PROT_WRITE, MAP_SHARED, tfd, 0);
-       if ((caddr_t)ptr == (caddr_t)-1) {
+       ptr = mmap (0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, tfd, 0);
+       if (ptr == MAP_FAILED) {
                fprintf (stderr, "%s: Can't read %s: %s\n",
                                cmdname, tmpfile, strerror(errno));
                unlink (tmpfile);