From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, Roman Zippel <zippel@linux-m68k.org>
Subject: Re: [PATCH 2/6] fs/affs: Add printf format/argument verification and fix fallout
Date: Thu, 11 Nov 2010 10:20:30 +0100 [thread overview]
Message-ID: <AANLkTikQJS8GGEYoVRqGHkMCdw4p89ROBgvGMcJOWXwt@mail.gmail.com> (raw)
In-Reply-To: <61b367bd6aa6fc5664bce431f91f25f5cb2489f5.1289432524.git.joe@perches.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 3823 bytes --]
On Thu, Nov 11, 2010 at 00:46, Joe Perches <joe@perches.com> wrote:
> Add __attribute__((format... to affs_error and affs_warning.
Thanks, nice catch!
> Change formats to match types of arguments.
You didn't fix any formats, you just added casts to silence the warnings?
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -355,7 +355,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
>
> Â Â Â Â Â Â Â Â /* store new block */
> Â Â Â Â Â Â Â Â if (bh_result->b_blocknr)
> - Â Â Â Â Â Â Â Â Â Â Â affs_warning(sb, "get_block", "block already set (%x)", bh_result->b_blocknr);
> + Â Â Â Â Â Â Â Â Â Â Â affs_warning(sb, "get_block", "block already set (%lx)",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (unsigned long)bh_result->b_blocknr);
struct buffer_head.b_blocknr is sector_t, which can be either u64 or
unsigned long.
So casting it to unsigned long may truncate it.
Please cast to unsigned long long instead, and use %llx.
> Â Â Â Â Â Â Â Â AFFS_BLOCK(sb, ext_bh, block) = cpu_to_be32(blocknr);
> Â Â Â Â Â Â Â Â AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(block + 1);
> Â Â Â Â Â Â Â Â affs_adjust_checksum(ext_bh, blocknr - bh_result->b_blocknr + 1);
> @@ -377,7 +378,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
> Â Â Â Â return 0;
>
> Â err_big:
> - Â Â Â affs_error(inode->i_sb,"get_block","strange block request %d", block);
> + Â Â Â affs_error(inode->i_sb,"get_block","strange block request %d",
> + Â Â Â Â Â Â Â Â Â (int)block);
Same here, block is sector_t.
> Â Â Â Â return -EIO;
> Â err_ext:
> Â Â Â Â // unlock cache
> @@ -848,8 +850,8 @@ affs_truncate(struct inode *inode)
> Â Â Â Â // lock cache
> Â Â Â Â ext_bh = affs_get_extblock(inode, ext);
> Â Â Â Â if (IS_ERR(ext_bh)) {
> - Â Â Â Â Â Â Â affs_warning(sb, "truncate", "unexpected read error for ext block %u (%d)",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â ext, PTR_ERR(ext_bh));
> + Â Â Â Â Â Â Â affs_warning(sb, "truncate", "unexpected read error for ext block %u (%ld)",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â (unsigned int)ext, PTR_ERR(ext_bh));
Do you really need the cast here? ext is u32, which is unsigned int.
> Â Â Â Â Â Â Â Â return;
> Â Â Â Â }
> Â Â Â Â if (AFFS_I(inode)->i_lc) {
> @@ -895,8 +897,8 @@ affs_truncate(struct inode *inode)
> Â Â Â Â Â Â Â Â Â Â Â Â struct buffer_head *bh = affs_bread_ino(inode, last_blk, 0);
> Â Â Â Â Â Â Â Â Â Â Â Â u32 tmp;
> Â Â Â Â Â Â Â Â Â Â Â Â if (IS_ERR(bh)) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â affs_warning(sb, "truncate", "unexpected read error for last block %u (%d)",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ext, PTR_ERR(bh));
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â affs_warning(sb, "truncate", "unexpected read error for last block %u (%ld)",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (unsigned int)ext, PTR_ERR(bh));
ext is u32.
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return;
> Â Â Â Â Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â Â Â Â Â tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next);
Gr{oetje,eeting}s,
            Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                 -- Linus Torvalds
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next prev parent reply other threads:[~2010-11-11 9:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 23:46 [PATCH 0/6] fs: Add printf format/argument verification Joe Perches
2010-11-10 23:46 ` [PATCH 1/6] fs/adfs: Add printf format/argument verification and fix fallout Joe Perches
2010-11-10 23:46 ` [PATCH 2/6] fs/affs: " Joe Perches
2010-11-11 9:20 ` Geert Uytterhoeven [this message]
2010-11-11 10:14 ` [PATCH] fs/affs/file.c: Use appropriate format types and casts Joe Perches
2010-11-10 23:46 ` [PATCH 3/6] fs/befs: Add printf format/argument verification and fix fallout Joe Perches
2010-11-10 23:46 ` [PATCH 4/6] fs/ecryptfs: " Joe Perches
2010-11-16 3:28 ` Tyler Hicks
2010-11-10 23:46 ` [PATCH 5/6] fs/jfs: Add printf format/argument verification Joe Perches
2010-11-11 15:31 ` [Jfs-discussion] " Dave Kleikamp
2010-11-12 8:53 ` Joe Perches
2010-11-10 23:46 ` [PATCH 6/6] fs/udf: " Joe Perches
2010-11-11 9:55 ` Jan Kara
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=AANLkTikQJS8GGEYoVRqGHkMCdw4p89ROBgvGMcJOWXwt@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.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;
as well as URLs for NNTP newsgroup(s).