File 0001-build-resolve-compiler-warnings-and-errors-with-ptli.patch of Package t38modem

From 98786058110416c18096fba9945d7a86917580c2 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Sat, 2 Apr 2022 16:04:40 +0200
Subject: [PATCH] build: resolve compiler warnings and errors with ptlib-2.18.8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
References: https://github.com/T38Modem/t38modem/pull/2
References: https://github.com/T38Modem/t38modem/pull/2#pullrequestreview-1861559363 incorporated

The definition of PINDEX changed in ptlib commit
6629d94fcb3cfd369a9629399a20a217429b4d60 .

dle.cxx: In member function ‘int DLEData::GetDleData(void*, PINDEX)’:
dle.cxx:180:13: error: narrowing conversion of ‘-1’ from ‘int’ to
‘long unsigned int’ [-Wnarrowing]
  180 |       case -1:
pmutils.cxx: In member function ‘int ChunkStream::write(const void*, PINDEX)’:
pmutils.cxx:129:11: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘PINDEX’ {aka ‘long unsigned int’} [-Wsign-compare]
  129 |   if (len > count)
pmutils.cxx: In member function ‘int ChunkStream::read(void*, PINDEX)’:
pmutils.cxx:145:11: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘PINDEX’ {aka ‘long unsigned int’} [-Wsign-compare]
  145 |   if (len > count)
---
 dle.cxx     |   10 +++++-----
 pmutils.cxx |    4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

Index: t38modem-4.6.0/dle.cxx
===================================================================
--- t38modem-4.6.0.orig/dle.cxx
+++ t38modem-4.6.0/dle.cxx
@@ -176,16 +176,16 @@ int DLEData::GetDleData(void *pBuf, PIND
     if (cGet > (PINDEX)sizeof(tmp))
       cGet = sizeof(tmp);
 
-    switch( cGet = GetData(tmp, cGet) ) {
-      case -1:
+    int ret = GetData(tmp, cGet);
+    if (ret < 0) {
         *p++ = DLE;
         *p++ = ETX;
         recvEtx = TRUE;
         return int(p - (BYTE *)pBuf);
-      case 0:
+    } else if (ret == 0) {
         return int(p - (BYTE *)pBuf);
-      default:
-        for( PINDEX i = 0 ; i < cGet ; i++ ) {
+    } else {
+        for( PINDEX i = 0 ; i < (unsigned int)ret ; i++ ) {
           BYTE b = bitRev ? BitRevTable[tmp[i]] : tmp[i];
           if( b == DLE )
             *p++ = DLE;
Index: t38modem-4.6.0/pmutils.cxx
===================================================================
--- t38modem-4.6.0.orig/pmutils.cxx
+++ t38modem-4.6.0/pmutils.cxx
@@ -121,7 +121,7 @@ void ModemThreadChild::SignalStop()
 ///////////////////////////////////////////////////////////////
 int ChunkStream::write(const void *pBuf, PINDEX count)
 {
-  int len = sizeof(data) - last;
+  size_t len = sizeof(data) - last;
 
   if (!len)
     return -1;
@@ -142,7 +142,7 @@ int ChunkStream::read(void *pBuf, PINDEX
 
   int len = last - first;
 
-  if (len > count)
+  if (len > 0 && static_cast<size_t>(len) > count)
     len = count;
 
   memcpy(pBuf, data + first, len);
openSUSE Build Service is sponsored by