Skip to contentSkip to conversation

: warrning fix: unsigned->signed

PATCH In review Tomasz Kvarsin 4 participants 5 messages Feb 6, 2007 – Feb 7, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : warrning fix: unsigned->signed

While compiling my code, I always get bunch of warrning from headers, here is fix for them:
__getblk is alawys called with unsigned argument,
but it takes signed, the same story with __bread,__breadahead and so on.

Signed-off-by Tomasz Kvarsin
include/linux/buffer_head.h +4 -4
Index: linux-2.6.20/include/linux/buffer_head.h
===================================================================
@@ -172,12 +172,12 @@ struct super_block *freeze_bdev(struct b
 void thaw_bdev(struct block_device *, struct super_block *);
 int fsync_super(struct super_block *);
 int fsync_no_super(struct block_device *);
-struct buffer_head *__find_get_block(struct block_device *, sector_t, int);
-struct buffer_head * __getblk(struct block_device *, sector_t, int);
+struct buffer_head *__find_get_block(struct block_device *, sector_t, unsigned int);
+struct buffer_head * __getblk(struct block_device *, sector_t, unsigned int);
 void __brelse(struct buffer_head *);
 void __bforget(struct buffer_head *);
-void __breadahead(struct block_device *, sector_t block, int size);
-struct buffer_head *__bread(struct block_device *, sector_t block, int size);
+void __breadahead(struct block_device *, sector_t block, unsigned int size);
+struct buffer_head *__bread(struct block_device *, sector_t block, unsigned int size);
 struct buffer_head *alloc_buffer_head(gfp_t gfp_flags);
 void free_buffer_head(struct buffer_head * bh);
 void FASTCALL(unlock_buffer(struct buffer_head *bh));
fs/buffer.c +6 -6
Index: linux-2.6.20/fs/buffer.c
===================================================================
@@ -1282,11 +1282,11 @@ static void bh_lru_install(struct buffer
  * Look up the bh in this cpu's LRU.  If it's there, move it to the head.
  */
 static struct buffer_head *
-lookup_bh_lru(struct block_device *bdev, sector_t block, int size)
+lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned int size)
 {
 	struct buffer_head *ret = NULL;
 	struct bh_lru *lru;
-	int i;
+	unsigned int i;
 
 	check_irqs_on();
 	bh_lru_lock();
@@ -1318,7 +1318,7 @@ lookup_bh_lru(struct block_device *bdev,
  * NULL
  */
 struct buffer_head *
-__find_get_block(struct block_device *bdev, sector_t block, int size)
+__find_get_block(struct block_device *bdev, sector_t block, unsigned int size)
 {
 	struct buffer_head *bh = lookup_bh_lru(bdev, block, size);
 
@@ -1346,7 +1346,7 @@ EXPORT_SYMBOL(__find_get_block);
  * attempt is failing.  FIXME, perhaps?
  */
 struct buffer_head *
-__getblk(struct block_device *bdev, sector_t block, int size)
+__getblk(struct block_device *bdev, sector_t block, unsigned int size)
 {
 	struct buffer_head *bh = __find_get_block(bdev, block, size);
 
@@ -1360,7 +1360,7 @@ EXPORT_SYMBOL(__getblk);
 /*
  * Do async read-ahead on a buffer..
  */
-void __breadahead(struct block_device *bdev, sector_t block, int size)
+void __breadahead(struct block_device *bdev, sector_t block, unsigned int size)
 {
 	struct buffer_head *bh = __getblk(bdev, block, size);
 	if (likely(bh)) {
@@ -1380,7 +1380,7 @@ EXPORT_SYMBOL(__breadahead);
  *  It returns NULL if the block was unreadable.
  */
 struct buffer_head *
-__bread(struct block_device *bdev, sector_t block, int size)
+__bread(struct block_device *bdev, sector_t block, unsigned int size)
 {
 	struct buffer_head *bh = __getblk(bdev, block, size);
 
#1 lore raw
Quoted 4 lines · On Wed, 7 Feb 2007 00:39:45 +0300 "Tomasz Kvarsin" <[email protected]> wrote:

While compiling my code, I always get bunch of warrning from headers, here is fix for them:
__getblk is alawys called with unsigned argument,
but it takes signed, the same story with __bread,__breadahead and so on.

The patch seems OK, but I'm curious to know why you're seeing this warning and nobody else is. Are you using a compiler other than gcc? If gcc, which version? Did you add any new compiler options?

Thanks.

#2 lore raw
Quoted 4 lines

From: Andrew Morton
Newsgroups: gmane.linux.kernel
Subject: Re: [PATCH]: warrning fix: unsigned->signed
Date: Tue, 6 Feb 2007 14:09:36 -0800

Mail-Followup-To: LKML <[email protected]>, Oleg Verych <[email protected]>, Andrew Morton <[email protected]>, "Tomasz Kvarsin" <[email protected]>, [email protected], [email protected]

Quoted 11 lines
Quoted 4 lines · On Wed, 7 Feb 2007 00:39:45 +0300 "Tomasz Kvarsin" <[email protected]> wrote:

While compiling my code, I always get bunch of warrning from headers, here is fix for them:
__getblk is alawys called with unsigned argument,
but it takes signed, the same story with __bread,__breadahead and so on.

The patch seems OK, but I'm curious to know why you're seeing this warning and nobody else is. Are you using a compiler other than gcc? If gcc, which version? Did you add any new compiler options?

Andrew, i think it's due to

,-*- quote -*-
| Friends don't let friends use "-W". [0]
`-*-

I get many of them, when compiling external modules with `-Wall', of course ;)

[0] Message-Id: [email protected]

    Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/470736>

____

#3 lore raw
In reply to Andrew Morton

I uses gcc "trunk" with -Wconversion,
because of they finaly implement warrning for such things:
uint16_t a;
uint8_t b;
b = a;
see
http://gcc.gnu.org/wiki/NewWconversion

Quoted 14 lines · Andrew Morton
Quoted 4 lines · On Wed, 7 Feb 2007 00:39:45 +0300 "Tomasz Kvarsin" <[email protected]> wrote:

While compiling my code, I always get bunch of warrning from headers, here is fix for them:
__getblk is alawys called with unsigned argument,
but it takes signed, the same story with __bread,__breadahead and so on.

The patch seems OK, but I'm curious to know why you're seeing this warning and nobody else is. Are you using a compiler other than gcc? If gcc, which version? Did you add any new compiler options?

Thanks.

#4 lore raw
In reply to Andrew Morton
Quoted 11 lines · Andrew Morton
Quoted 4 lines · On Wed, 7 Feb 2007 00:39:45 +0300 "Tomasz Kvarsin" <[email protected]> wrote:

While compiling my code, I always get bunch of warrning from headers, here is fix for them:
__getblk is alawys called with unsigned argument,
but it takes signed, the same story with __bread,__breadahead and so on.

The patch seems OK, but I'm curious to know why you're seeing this warning and nobody else is. Are you using a compiler other than gcc? If gcc, which version? Did you add any new compiler options?

While I'm not a big fan of fixing signed vs unsigned -W generated warnings (they tend to cause more harm than good), this patch looks ok to me as well.

Signature · 1 line
Jens Axboe