--- a/src/fiemap.cc
+++ b/src/fiemap.cc
@@ -28,7 +28,8 @@ main(int argc, char **argv)
 		if (argc > 2) { fm.fm_start = stoull(argv[2], nullptr, 0); }
 		if (argc > 3) { fm.fm_length = stoull(argv[3], nullptr, 0); }
 		if (argc > 4) { fm.fm_flags = stoull(argv[4], nullptr, 0); }
-		fm.fm_length = min(fm.fm_length, FIEMAP_MAX_OFFSET - fm.fm_start);
+		using FU = decltype(fm.fm_length);
+		fm.fm_length = min(FU(fm.fm_length), FU(FIEMAP_MAX_OFFSET - fm.fm_start));
 		uint64_t stop_at = fm.fm_start + fm.fm_length;
 		uint64_t last_byte = fm.fm_start;
 		do {
