1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
From 9d513fe3480fdaf0c3ec4bd89ed2eb66f96cd957 Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars.kanis@sincnovation.com>
Date: Thu, 13 Feb 2025 10:13:11 +0100
Subject: [PATCH 08/10] Avoid compiler warning:
warning: comparison of integer expressions of different signedness: "int" and "long unsigned int" [-Wsign-compare]
if (num_port < 0 || num_port > sizeof(ports) / sizeof(ports[0]))
---
ext/native/posix_serialport_impl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ext/native/posix_serialport_impl.c b/ext/native/posix_serialport_impl.c
index 3d40232..0681131 100644
--- a/ext/native/posix_serialport_impl.c
+++ b/ext/native/posix_serialport_impl.c
@@ -75,7 +75,7 @@ int get_fd_helper(VALUE io)
VALUE sp_create_impl(VALUE class, VALUE _port)
{
int fd;
- int num_port;
+ long num_port;
const char *port;
const char *ports[] = {
#if defined(OS_LINUX) || defined(OS_CYGWIN)
@@ -101,8 +101,8 @@ VALUE sp_create_impl(VALUE class, VALUE _port)
switch(TYPE(_port))
{
case T_FIXNUM:
- num_port = FIX2INT(_port);
- if (num_port < 0 || num_port > sizeof(ports) / sizeof(ports[0]))
+ num_port = FIX2LONG(_port);
+ if (num_port < 0 || num_port > (long)(sizeof(ports) / sizeof(ports[0])))
{
rb_raise(rb_eArgError, "illegal port number");
}
--
2.39.5
|