]> granicus.if.org Git - recode/commitdiff
test: Fix signedness mismatch
authorPetr Písař <ppisar@redhat.com>
Thu, 12 Sep 2019 10:43:56 +0000 (12:43 +0200)
committerPetr Písař <ppisar@redhat.com>
Thu, 12 Sep 2019 10:52:00 +0000 (12:52 +0200)
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.

tests/Recode.pyx

index a7982a2ce29f2d6de48b26565885f9b896646baa..545c1a131f030cf33f4709e32a1c531a9ad5ec39 100644 (file)
@@ -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))