summaryrefslogtreecommitdiffstats
path: root/external/meta-openembedded/meta-oe/recipes-support/libmimetic/libmimetic/0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch
blob: c7c8d62aaafda9377411d1fb545bd5a30643fd31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From f8ab2b1aaa37f6ba9d527a99cb37b6ac2171e122 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 14 Feb 2020 17:03:12 -0800
Subject: [PATCH] mimetic: Check for MMAP_FAILED return from mmap()

Avoids using greater than zero comparision on pointers

Fixes
mimetic/os/mmfile.cxx:60:14: error: ordered comparison between pointer and zero ('char *' and 'int')

if(m_beg > 0)
~~~~ ^ ~

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 mimetic/os/mmfile.cxx | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/mimetic/os/mmfile.cxx b/mimetic/os/mmfile.cxx
index dfc95b7..ed4ff55 100644
--- a/mimetic/os/mmfile.cxx
+++ b/mimetic/os/mmfile.cxx
@@ -57,15 +57,13 @@ bool MMFile::open(int mode)
 bool MMFile::map()
 {
     m_beg = (char*) mmap(0, m_st.st_size, PROT_READ, MAP_SHARED,m_fd,0);
-    if(m_beg > 0)
-    {
-        m_end = m_beg + m_st.st_size;
-        #if HAVE_MADVISE
-        madvise(m_beg, m_st.st_size, MADV_SEQUENTIAL);
-        #endif
-        return true;
-    }
-    return false;
+    if(m_beg == MAP_FAILED)
+        return false;
+    m_end = m_beg + m_st.st_size;
+    #if HAVE_MADVISE
+    madvise(m_beg, m_st.st_size, MADV_SEQUENTIAL);
+    #endif
+    return true;
 }
 
 MMFile::~MMFile()
-- 
2.25.0