From 0a69639e6f9812c9e3742b74e283a79f2df1a392 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 6 Apr 2019 05:41:28 -0400 Subject: [PATCH] [Coverity] Ensure that we never return -1 from pagesize operation, helps eliminate many false positives (mono/mono#13863) Commit migrated from https://github.com/mono/mono/commit/8567415aea784cff65c51d5347870a14c2605956 --- src/mono/mono/utils/mono-mmap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mono/mono/utils/mono-mmap.c b/src/mono/mono/utils/mono-mmap.c index a1dc4e8..35e5174 100644 --- a/src/mono/mono/utils/mono-mmap.c +++ b/src/mono/mono/utils/mono-mmap.c @@ -181,6 +181,15 @@ mono_pagesize (void) saved_pagesize = getpagesize (); #endif + + // While this could not happen in any of the Mono supported + // systems, this ensures this function never returns -1, and + // reduces the number of false positives + // that Coverity finds in consumer code. + + if (saved_pagesize == -1) + return 64*1024; + return saved_pagesize; } -- 2.7.4