diff --git a/libretro-common/encodings/encoding_crc32.c b/libretro-common/encodings/encoding_crc32.c index 85881e521b..9724f3eff7 100644 --- a/libretro-common/encodings/encoding_crc32.c +++ b/libretro-common/encodings/encoding_crc32.c @@ -101,39 +101,40 @@ uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len) * * Returns: the crc32, or 0 if there was an error. */ -uint32_t file_crc32(uint32_t crc, const char *path) { - if(path == NULL) - return 0; - - RFILE *file = NULL; +uint32_t file_crc32(uint32_t crc, const char *path) +{ + unsigned i; + RFILE *file = NULL; unsigned char *buf = NULL; - int i, nread; + if (!path) + return 0; file = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, 0); - if(file == NULL) + if (!file) goto error; - buf = (char *)malloc(CRC32_BUFFER_SIZE); - if(buf == NULL) - goto error; + buf = (unsigned char*)malloc(CRC32_BUFFER_SIZE); + if (!buf) + goto error; - for(i = 0; i < CRC32_MAX_MB; i++) { - nread = filestream_read(file, buf, CRC32_BUFFER_SIZE); - if(nread < 0) - goto error; + for(i = 0; i < CRC32_MAX_MB; i++) + { + int nread = filestream_read(file, buf, CRC32_BUFFER_SIZE); + if (nread < 0) + goto error; crc = encoding_crc32(crc, buf, nread); - if(filestream_eof(file)) + if (filestream_eof(file)) break; } free(buf); filestream_close(file); return crc; - error: - if(buf) - free(buf); - if(file) - filestream_close(file); - return 0; +error: + if (buf) + free(buf); + if (file) + filestream_close(file); + return 0; }