ptgen: add Chromium OS kernel partition support
[project/firmware-utils.git] / src / spw303v.c
index 654d68db2b08eedb3ee55d1edb52bc999460f59f..3244a73a2f71da6b33b5189624841b11ae20aec7 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * spw303v.c - partially based on OpenWrt's imagetag.c and addpattern.c
  *
  * Copyright (C) 2011  Jonas Gorski <jonas.gorski@gmail.com>
- *
- * 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
  */
 
 #include <arpa/inet.h>
@@ -23,7 +10,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <time.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
@@ -118,10 +104,12 @@ static char fake_data[] = {
 };
 
 
-uint32_t crc32(uint32_t crc, uint8_t *data, size_t len)
+uint32_t crc32(uint32_t crc, const void *data, size_t len)
 {
+       const uint8_t *in = data;
+
        while (len--)
-               crc = (crc >> 8) ^ crc32tab[(crc ^ *data++) & 0xFF];
+               crc = (crc >> 8) ^ crc32tab[(crc ^ *in++) & 0xFF];
 
        return crc;
 }
@@ -168,7 +156,6 @@ int main(int argc, char **argv)
        char *ifn = NULL;
        char *ofn = NULL;
        int c;
-       int v0, v1, v2;
        size_t n;
        int first_block = 1;