Fix some compilation warnings for better ANSI C compliance
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 26 Jun 2018 10:37:36 +0300
changeset 2227 f150783ee8e7
parent 2192 09d5d1456616
child 2228 12cb48823b8c
Fix some compilation warnings for better ANSI C compliance
targets/Linux/plc_Linux_main_retain.c
targets/Win32/plc_Win32_main_retain.c
--- a/targets/Linux/plc_Linux_main_retain.c	Sat Jun 23 09:17:20 2018 +0200
+++ b/targets/Linux/plc_Linux_main_retain.c	Tue Jun 26 10:37:36 2018 +0300
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #include "iec_types.h"
 
-int GetRetainSize();
+int GetRetainSize(void);
 
 /* Retain buffer.  */
 FILE *retain_buffer;
--- a/targets/Win32/plc_Win32_main_retain.c	Sat Jun 23 09:17:20 2018 +0200
+++ b/targets/Win32/plc_Win32_main_retain.c	Tue Jun 26 10:37:36 2018 +0300
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #include "iec_types.h"
 
-int GetRetainSize();
+int GetRetainSize(void);
 
 /* Retain buffer.  */
 FILE *retain_buffer;
@@ -79,7 +79,7 @@
 
 	while(!feof(file_buffer)){
 		if (fread(&data_block, sizeof(data_block), 1, file_buffer))
-			calc_crc32 = GenerateCRC32Sum(&data_block, sizeof(char), calc_crc32);
+			calc_crc32 = GenerateCRC32Sum(&data_block, sizeof(data_block), calc_crc32);
 	}
 
 	/* Compare crc result with a magic number.  */
@@ -89,7 +89,7 @@
 /* Compare current hash with hash from file byte by byte.  */
 int CheckFilehash(void)
 {
-	int k;
+	unsigned int k;
 	int offset = sizeof(retain_info.retain_size);
 
 	rewind(retain_buffer);
@@ -102,7 +102,7 @@
 
 	for(k = 0; k < retain_info.hash_size; k++){
 		uint8_t file_digit;
-		fread(&file_digit, sizeof(char), 1, retain_buffer);
+		fread(&file_digit, sizeof(file_digit), 1, retain_buffer);
 		if (file_digit != *(retain_info.hash+k))
 			return 0;
 	}
@@ -112,7 +112,7 @@
 
 void InitRetain(void)
 {
-	int i;
+	unsigned int i;
 
 	/* Generate CRC32 lookup table.  */
 	GenerateCRC32Table();
@@ -249,7 +249,7 @@
 
 	/* Add retain data CRC to the end of buffer file.  */
 	fseek(retain_buffer, 0, SEEK_END);
-	fwrite(&retain_crc, sizeof(uint32_t), 1, retain_buffer);
+	fwrite(&retain_crc, sizeof(retain_crc), 1, retain_buffer);
 
 	/* Sync file buffer and close file.  */
 #ifdef __WIN32