[oe] [PATCH] libmimetic: Fix ordrered comparision between pointer and zero

Khem Raj raj.khem at gmail.com
Sat Feb 15 01:15:27 UTC 2020


Found with clang

Signed-off-by: Khem Raj <raj.khem at gmail.com>
Cc: asmitha <asmithakarun at gmail.com>
---
 ...eck-for-MMAP_FAILED-return-from-mmap.patch | 49 +++++++++++++++++++
 .../libmimetic/libmimetic_0.9.8.bb            |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 meta-oe/recipes-support/libmimetic/libmimetic/0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch

diff --git a/meta-oe/recipes-support/libmimetic/libmimetic/0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch b/meta-oe/recipes-support/libmimetic/libmimetic/0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch
new file mode 100644
index 0000000000..c7c8d62aaa
--- /dev/null
+++ b/meta-oe/recipes-support/libmimetic/libmimetic/0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch
@@ -0,0 +1,49 @@
+From f8ab2b1aaa37f6ba9d527a99cb37b6ac2171e122 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at 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 at 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
+
diff --git a/meta-oe/recipes-support/libmimetic/libmimetic_0.9.8.bb b/meta-oe/recipes-support/libmimetic/libmimetic_0.9.8.bb
index fd65db2d39..d0fe498adc 100644
--- a/meta-oe/recipes-support/libmimetic/libmimetic_0.9.8.bb
+++ b/meta-oe/recipes-support/libmimetic/libmimetic_0.9.8.bb
@@ -12,6 +12,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b49da7df0ca479ef01ff7f2d799eabee"
 SRCREV = "50486af99b4f9b35522d7b3de40b6ce107505279"
 SRC_URI += "git://github.com/LadislavSopko/mimetic/ \
             file://0001-libmimetic-Removing-test-directory-from-the-Makefile.patch \
+            file://0001-mimetic-Check-for-MMAP_FAILED-return-from-mmap.patch \
            "
 
 S = "${WORKDIR}/git"
-- 
2.25.0



More information about the Openembedded-devel mailing list