comparison was always false due to limited range of data types.
authorEric Andersen <andersen@codepoet.org>
Mon, 15 Sep 2003 08:11:29 +0000 (08:11 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 15 Sep 2003 08:11:29 +0000 (08:11 -0000)
Carefully cast to unsigned long long prior to multiply to get
the expected result.

init/init.c

index 8da358cb51b9e0468965272d1f0ae5caf3235e0f..85792c9b7f1fe1a4263a7d2c3793e7428a42d838 100644 (file)
@@ -333,7 +333,7 @@ static unsigned int check_free_memory(void)
                s--;
        }
        result = (info.totalram >> s) + (info.totalswap >> s);
-       if ((unsigned long long) (result * u) > UINT_MAX) {
+       if (((unsigned long long)result * (unsigned long long)u) > UINT_MAX) {
                return(UINT_MAX);
        } else {
                return(result * u);