Fix -Wsign-compare trouble

Mostly by changing to `unsigned` types where applicable, sometimes
`signed` types, and casting as a last resort.

Change-Id: I08895543ffb7a48058bcf91ef6500ca113f2d305
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
diff --git a/at45db.c b/at45db.c
index 38c0685..5f949bb 100644
--- a/at45db.c
+++ b/at45db.c
@@ -463,9 +463,9 @@
 	}
 
 	/* Create a suitable buffer to store opcode, address and data chunks for buffer1. */
-	const int max_data_write = flash->mst->spi.max_data_write - 4;
-	const unsigned int max_chunk = (max_data_write > 0 && max_data_write <= page_size) ?
-				       max_data_write : page_size;
+	const unsigned int max_data_write = flash->mst->spi.max_data_write;
+	const unsigned int max_chunk = max_data_write > 4 && max_data_write - 4 <= page_size ?
+				       max_data_write - 4 : page_size;
 	uint8_t buf[4 + max_chunk];
 
 	buf[0] = AT45DB_BUFFER1_WRITE;