mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Juhl <juhl-lkml@dif.dk>
To: Andrew Morton <akpm@osdl.org>
Cc: Walt Drummond <drummond@valinux.com>,
	David Mosberger-Tang <davidm@hpl.hp.com>,
	Stephane Eranian <eranian@hpl.hp.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [resend][PATCH] avoid signed vs unsigned comparison in efi_range_is_wc()
Date: Thu, 16 Jun 2005 22:21:50 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.62.0506162219040.2477@dragon.hyggekrogen.localhost> (raw)

I send in the patch below a while back but never recieved any response.
Now I'm resending it in the hope that it might be added to -mm.
The patch still applies cleanly to 2.6.12-rc6-mm1

-- 
Jesper Juhl


---------- Forwarded message ----------
Date: Fri, 18 Mar 2005 00:43:33 +0100 (CET)
From: Jesper Juhl <juhl-lkml@dif.dk>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Walt Drummond <drummond@valinux.com>,
    David Mosberger-Tang <davidm@hpl.hp.com>,
    Stephane Eranian <eranian@hpl.hp.com>
Subject: [PATCH] avoid signed vs unsigned comparison in efi_range_is_wc()


This little function in include/linux/efi.h :

static inline int efi_range_is_wc(unsigned long start, unsigned long len)
{
        int i;

        for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
                unsigned long paddr = __pa(start + i);
                if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC))
                        return 0;
        }
        /* The range checked out */
        return 1;
}

generates this warning when building with gcc -W : 

include/linux/efi.h: In function `efi_range_is_wc':
include/linux/efi.h:320: warning: comparison between signed and unsigned

It looks to me like a significantly large 'len' passed in could cause the 
loop to never end. Isn't it safer to make 'i' an unsigned long as well? 
Like this little patch below (which of course also kills the warning) :


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.11-mm4-orig/include/linux/efi.h linux-2.6.11-mm4/include/linux/efi.h
--- linux-2.6.11-mm4-orig/include/linux/efi.h	2005-03-16 15:45:35.000000000 +0100
+++ linux-2.6.11-mm4/include/linux/efi.h	2005-03-18 00:34:36.000000000 +0100
@@ -315,7 +315,7 @@ extern struct efi_memory_map memmap;
  */
 static inline int efi_range_is_wc(unsigned long start, unsigned long len)
 {
-	int i;
+	unsigned long i;
 
 	for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
 		unsigned long paddr = __pa(start + i);





             reply	other threads:[~2005-06-16 20:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-16 20:21 Jesper Juhl [this message]
2005-06-16 20:41 ` Andrew Morton
2005-06-16 21:02   ` Jesper Juhl
2005-06-16 21:48     ` Arnd Bergmann
2005-06-16 22:24       ` Jesper Juhl
2005-06-16 20:45 ` Richard B. Johnson
2005-06-16 21:07   ` Jesper Juhl
2005-06-16 21:32     ` Arnd Bergmann
2005-06-16 21:01 ` David Mosberger
2005-06-20 17:00   ` Jesse Barnes
2005-06-17  0:25 Arnd Bergmann <arnd@arndb.de>
2005-06-17 17:04 ` Jesper Juhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.62.0506162219040.2477@dragon.hyggekrogen.localhost \
    --to=juhl-lkml@dif.dk \
    --cc=akpm@osdl.org \
    --cc=davidm@hpl.hp.com \
    --cc=drummond@valinux.com \
    --cc=eranian@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®