From patchwork Sun Oct 14 20:32:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 191414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 1AB0A2C008A for ; Mon, 15 Oct 2012 07:32:41 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TNUrX-0006EK-UO; Sun, 14 Oct 2012 20:32:39 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TNUrR-0006D8-8f for fwts-devel@lists.ubuntu.com; Sun, 14 Oct 2012 20:32:33 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TNUrR-0003sp-66 for fwts-devel@lists.ubuntu.com; Sun, 14 Oct 2012 20:32:33 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 26/26] lib: fwts_alloc: use ptrdiff_t to ensure non-mixed type comparison Date: Sun, 14 Oct 2012 21:32:18 +0100 Message-Id: <1350246738-31699-27-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1350246738-31699-1-git-send-email-colin.king@canonical.com> References: <1350246738-31699-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King When comparing difference of two pointers we should compare to a ptrdiff_t to avoid any messy non-mixed type comparisons. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- src/lib/src/fwts_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/src/fwts_alloc.c b/src/lib/src/fwts_alloc.c index 4495ad4..5c61478 100644 --- a/src/lib/src/fwts_alloc.c +++ b/src/lib/src/fwts_alloc.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "fwts_alloc.h" @@ -75,7 +76,7 @@ static void *fwts_low_mmap(const size_t requested_size) if ((last_addr_end != NULL) && (last_addr_end < (void*)LIMIT_2GB)) { - if ((addr_start - last_addr_end) > requested_size) { + if ((addr_start - last_addr_end) > (ptrdiff_t)requested_size) { void *addr = last_addr_end; ret = mmap(addr, requested_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);