pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

The shmat() error return is (apparently) -1 as a pointer. Some compilers (E.g. clang on MacOS) refuse to consider testing if a pointer is less than zero as legal code. Fix compilation by converting to explicit tests for particular values that might make sense.



Module Name:	pkgsrc-wip
Committed By:	davidsainty <david.sainty%gmail.com@localhost>
Pushed By:	dsainty
Date:		Thu Jan 20 13:54:23 2022 +1300
Changeset:	b7ab201c1ac8627507c5261bc7ac3d58b7a510bd

Modified Files:
	zoneminder/patches/patch-src_zm__monitor.cpp

Log Message:
The shmat() error return is (apparently) -1 as a pointer.  Some compilers
(E.g. clang on MacOS) refuse to consider testing if a pointer is less than
zero as legal code.  Fix compilation by converting to explicit tests for
particular values that might make sense.

This is also a slight correction over the existing Pkgsrc patch - we should
be checking for both NULL and -1 the way this code is currently written.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=b7ab201c1ac8627507c5261bc7ac3d58b7a510bd

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 zoneminder/patches/patch-src_zm__monitor.cpp | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diffs:
diff --git a/zoneminder/patches/patch-src_zm__monitor.cpp b/zoneminder/patches/patch-src_zm__monitor.cpp
index ca36f490e7..983d86480e 100644
--- a/zoneminder/patches/patch-src_zm__monitor.cpp
+++ b/zoneminder/patches/patch-src_zm__monitor.cpp
@@ -1,12 +1,15 @@
 $NetBSD: patch-src_zm__monitor.cpp,v 1.1 2017/02/15 00:54:25 joerg Exp $
 
-\todo Explain mem_ptr change.
+The shmat() error return is (apparently) -1 as a pointer.  Some compilers
+(E.g. clang on MacOS) refuse to consider testing if a pointer is less than
+zero as legal code.  Fix compilation by converting to explicit tests for
+particular values that might make sense.
 
 Avoid type error (suseconds_t is not long).  To be addressed upstream once caught up.
 
---- src/zm_monitor.cpp.orig	2019-02-22 15:38:47.000000000 +0000
-+++ src/zm_monitor.cpp
-@@ -160,7 +160,7 @@ bool Monitor::MonitorLink::connect()
+--- src/zm_monitor.cpp.orig	2019-02-23 04:38:47.000000000 +1300
++++ src/zm_monitor.cpp	2022-01-19 21:56:47.000000000 +1300
+@@ -160,7 +160,7 @@
        return( false );
      }
      mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
@@ -15,7 +18,16 @@ Avoid type error (suseconds_t is not long).  To be addressed upstream once caugh
      {
        Debug( 3, "Can't shmat link memory: %s", strerror(errno) );
        connected = false;
-@@ -3175,7 +3175,7 @@ void Monitor::TimestampImage( Image *ts_
+@@ -194,7 +194,7 @@
+     connected = false;
+ 
+ #if ZM_MEM_MAPPED
+-    if ( mem_ptr > 0 )
++    if ( mem_ptr != 0 && mem_ptr != (void *)-1 )
+     {
+       msync( mem_ptr, mem_size, MS_ASYNC );
+       munmap( mem_ptr, mem_size );
+@@ -3175,7 +3175,7 @@
              found_macro = true;
              break;
            case 'f' :


Home | Main Index | Thread Index | Old Index