fix build error in latest git (unsigned/signed comparison)
PATCH 1/1 fix build error in latest git (unsigned/signed comparison)
From 67e49b800a14363c93eeab362e202e68362b7775 Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Sat, 8 Aug 2009 19:54:35 -0400
Subject: [PATCH] Fix signed/unsigned comparison build error
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Latest git has the following issue when building:
cc -DHAVE_CONFIG_H -I. -I.. -I../include -I.. -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I../gdbus -I../gatchat -I.. -DPLUGINDIR=\""/home/dilinger/ofono/plugins/.libs"\" -g -O2 -g -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -MT sim.o -MD -MP -MF .deps/sim.Tpo -c -o sim.o sim.c
cc1: warnings being treated as errorssim.c: In function ‘sim_op_check_cached’:
sim.c:795: error: comparison between signed and unsigned
The code in question is:
if (TFR(read(fd, buffer, file_length)) < file_length)
The fix for this is to simply cast the result to unsigned after ensuring that it's not negative.
--- src/sim.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
src/sim.c +2 -1
@@ -792,7 +792,8 @@ static gboolean sim_op_check_cached(struct ofono_modem *modem) buffer =g_malloc (file_length); -if (TFR (read (fd, buffer, file_length)) < file_length) + len =TFR (read (fd, buffer, file_length)); +if (len <0 || ((unsigned int ) len < file_length)) goto cleanup;for (record =0 ; record < file_length / record_length; record++) {
Signature · 1 line
1.6.3.3