Fix a type mismatch in tests

This commit is contained in:
Petr Písař 2019-09-12 13:32:14 +02:00
parent 980edaa463
commit 306d21033c
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From d007389422007adf9cee50830b8dae9884802d77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 12 Sep 2019 12:43:56 +0200
Subject: [PATCH] test: Fix signedness mismatch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC 9.2.1 warns:
Recode.c: In function __pyx_pf_6Recode_7Request_8pair_sequence:
Recode.c:3096:45: warning: comparison of integer expressions of different signedness: unsigned int and short int [-Wsign-compare]
3096 | for (__pyx_v_counter = 0; __pyx_v_counter < __pyx_t_2; __pyx_v_counter++) {
| ^
A comparison between differently signed variable is dangerous because the
signed value is converted to an unsigned value of the same width and that
mangles the value and leads to comparing unintended values.
This patch fixes it.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
tests/Recode.pyx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Recode.pyx b/tests/Recode.pyx
index a7982a2..545c1a1 100644
--- a/tests/Recode.pyx
+++ b/tests/Recode.pyx
@@ -604,7 +604,7 @@ cdef class Request:
def pair_sequence(self):
list = []
cdef recode_step step
- cdef unsigned counter
+ cdef short counter
for counter from 0 <= counter < self.request.sequence_length:
step = self.request.sequence_array[counter]
list.append((step.before.name, step.after.name))
--
2.21.0

View File

@ -61,6 +61,8 @@ Patch0: recode-3.7.1-Rename-coliding-hash-functions.patch
# Fix a possible buffer overflow in transform_utf16_java(), # Fix a possible buffer overflow in transform_utf16_java(),
# in upstream after 3.7.5 # in upstream after 3.7.5
Patch1: recode-3.7.5-Fix-a-couple-of-potential-buffer-overflows.patch Patch1: recode-3.7.5-Fix-a-couple-of-potential-buffer-overflows.patch
# Fix a type mismatch in tests, <https://github.com/rrthomas/recode/pull/23>
Patch2: recode-3.7.5-test-Fix-signedness-mismatch.patch
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: automake BuildRequires: automake
BuildRequires: coreutils BuildRequires: coreutils
@ -100,6 +102,7 @@ This package provides deader files for recode library.
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%patch2 -p1
autoreconf -fi autoreconf -fi
%build %build
@ -150,6 +153,7 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la
* Thu Sep 12 2019 Petr Pisar <ppisar@redhat.com> - 3.7.5-1 * Thu Sep 12 2019 Petr Pisar <ppisar@redhat.com> - 3.7.5-1
- 3.7.5 bump - 3.7.5 bump
- Fix a possible buffer overflow in transform_utf16_java() - Fix a possible buffer overflow in transform_utf16_java()
- Fix a type mismatch in tests
* Mon Sep 02 2019 Petr Pisar <ppisar@redhat.com> - 3.7.4-1 * Mon Sep 02 2019 Petr Pisar <ppisar@redhat.com> - 3.7.4-1
- 3.7.4 bump - 3.7.4 bump