lkml.org 
[lkml]   [2010]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/6] fs/affs: Add printf format/argument verification and fix fallout
From
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
\
 
 \ /
  Last update: 2010-11-11 10:23    [W:0.062 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site