diff --git a/programs/cmp_io.c b/programs/cmp_io.c
index 4f6ee25cbd0a3ee909f243722f61cc7e0275864e..7aae26ff5978403bba72c35ef6345c7583e9d842 100644
--- a/programs/cmp_io.c
+++ b/programs/cmp_io.c
@@ -1393,7 +1393,7 @@ ssize_t read_file_data(const char *file_name, enum cmp_data_type data_type,
 	int err;
 
 	size = read_file8(file_name, (uint8_t *)buf, buf_size, flags);
-	if (size > UINT32_MAX)
+	if (size > INT32_MAX)
 		return -1;
 
 	if (size < 0)
diff --git a/programs/cmp_tool.c b/programs/cmp_tool.c
index 0c8df20d866cee0bb910353a2e84c1b0a010fe93..1d7aee352bf1aec9169810c97d6c303adff7ddd2 100644
--- a/programs/cmp_tool.c
+++ b/programs/cmp_tool.c
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
 				int32_t samples;
 
 				size = read_file_data(data_file_name, cfg.data_type, NULL, 0, io_flags);
-				if (size <= 0 || size > UINT32_MAX) /* empty file is treated as an error */
+				if (size <= 0 || size > INT32_MAX) /* empty file is treated as an error */
 					goto fail;
 				samples = cmp_input_size_to_samples((uint32_t)size, cfg.data_type);
 				if (samples < 0)
@@ -374,7 +374,7 @@ int main(int argc, char **argv)
 			input_size = cmp_cal_size_of_data(cfg.samples, cfg.data_type);
 		} else {
 			size  = read_file_data(data_file_name, cfg.data_type, NULL, 0, io_flags);
-			if (size <= 0 || size > UINT32_MAX) /* empty file is treated as an error */
+			if (size <= 0 || size > INT32_MAX) /* empty file is treated as an error */
 				goto fail;
 			input_size = (uint32_t)size;
 		}
@@ -433,7 +433,7 @@ int main(int argc, char **argv)
 
 			printf("Importing compressed data file %s ... ", data_file_name);
 			size = read_file_cmp_entity(data_file_name, NULL, 0, io_flags);
-			if (size < 0 || size > UINT32_MAX)
+			if (size < 0 || size > INT32_MAX)
 				goto fail;
 			/* to be save allocate at least the size of the cmp_entity struct */
 			buf_size = (size_t)size;