From dc33476e0d1fcb44507e19a3fb98498a94c5d583 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 3 Sep 2021 00:45:47 +0200 Subject: [PATCH] Fixed the PIT BCD counter for signedness (bug again found by clang). --- src/pit.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pit.c b/src/pit.c index dd4613d76..582c748a7 100644 --- a/src/pit.c +++ b/src/pit.c @@ -110,20 +110,20 @@ ctr_decrease_count(ctr_t *ctr) { if (ctr->bcd) { ctr->units--; - if (ctr->units == 0xff) { - ctr->units = 9; + if (ctr->units == -1) { + ctr->units = -7; ctr->tens--; - if (ctr->tens == 0xff) { - ctr->tens = 9; + if (ctr->tens == -1) { + ctr->tens = -7; ctr->hundreds--; - if (ctr->hundreds == 0xff) { - ctr->hundreds = 9; + if (ctr->hundreds == -1) { + ctr->hundreds = -7; ctr->thousands--; - if (ctr->thousands == 0xff) { - ctr->thousands = 9; + if (ctr->thousands == -1) { + ctr->thousands = -7; ctr->myriads--; - if (ctr->myriads == 0xff) - ctr->myriads = 0; /* 0 - 1 should wrap around to 9999. */ + if (ctr->myriads == -1) + ctr->myriads = -7; /* 0 - 1 should wrap around to 9999. */ } } }