Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/affs/amigaffs.c: use va_format instead of buffer/vnsprintf

-Remove ErrorBuffer and use %pV

-Add __printf to enable argument mistmatch warnings

Original patch by Joe Perches.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Fabian Frederick and committed by
Linus Torvalds
1ee54b09 7633978b

+25 -21
+2
fs/affs/affs.h
··· 135 135 extern void secs_to_datestamp(time_t secs, struct affs_date *ds); 136 136 extern umode_t prot_to_mode(u32 prot); 137 137 extern void mode_to_prot(struct inode *inode); 138 + __printf(3, 4) 138 139 extern void affs_error(struct super_block *sb, const char *function, 139 140 const char *fmt, ...); 141 + __printf(3, 4) 140 142 extern void affs_warning(struct super_block *sb, const char *function, 141 143 const char *fmt, ...); 142 144 extern bool affs_nofilenametruncate(const struct dentry *dentry);
+13 -15
fs/affs/amigaffs.c
··· 10 10 11 11 #include "affs.h" 12 12 13 - static char ErrorBuffer[256]; 14 - 15 13 /* 16 14 * Functions for accessing Amiga-FFS structures. 17 15 */ ··· 442 444 void 443 445 affs_error(struct super_block *sb, const char *function, const char *fmt, ...) 444 446 { 445 - va_list args; 447 + struct va_format vaf; 448 + va_list args; 446 449 447 - va_start(args,fmt); 448 - vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); 449 - va_end(args); 450 - 451 - pr_crit("error (device %s): %s(): %s\n", sb->s_id, 452 - function,ErrorBuffer); 450 + va_start(args, fmt); 451 + vaf.fmt = fmt; 452 + vaf.va = &args; 453 + pr_crit("error (device %s): %s(): %pV\n", sb->s_id, function, &vaf); 453 454 if (!(sb->s_flags & MS_RDONLY)) 454 455 pr_warn("Remounting filesystem read-only\n"); 455 456 sb->s_flags |= MS_RDONLY; 457 + va_end(args); 456 458 } 457 459 458 460 void 459 461 affs_warning(struct super_block *sb, const char *function, const char *fmt, ...) 460 462 { 461 - va_list args; 463 + struct va_format vaf; 464 + va_list args; 462 465 463 - va_start(args,fmt); 464 - vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); 466 + va_start(args, fmt); 467 + vaf.fmt = fmt; 468 + vaf.va = &args; 469 + pr_warn("(device %s): %s(): %pV\n", sb->s_id, function, &vaf); 465 470 va_end(args); 466 - 467 - pr_warn("(device %s): %s(): %s\n", sb->s_id, 468 - function,ErrorBuffer); 469 471 } 470 472 471 473 bool
+10 -6
fs/affs/file.c
··· 333 333 334 334 /* store new block */ 335 335 if (bh_result->b_blocknr) 336 - affs_warning(sb, "get_block", "block already set (%x)", bh_result->b_blocknr); 336 + affs_warning(sb, "get_block", "block already set (%lx)", 337 + (unsigned long)bh_result->b_blocknr); 337 338 AFFS_BLOCK(sb, ext_bh, block) = cpu_to_be32(blocknr); 338 339 AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(block + 1); 339 340 affs_adjust_checksum(ext_bh, blocknr - bh_result->b_blocknr + 1); ··· 356 355 return 0; 357 356 358 357 err_big: 359 - affs_error(inode->i_sb,"get_block","strange block request %d", block); 358 + affs_error(inode->i_sb, "get_block", "strange block request %d", 359 + (int)block); 360 360 return -EIO; 361 361 err_ext: 362 362 // unlock cache ··· 847 845 // lock cache 848 846 ext_bh = affs_get_extblock(inode, ext); 849 847 if (IS_ERR(ext_bh)) { 850 - affs_warning(sb, "truncate", "unexpected read error for ext block %u (%d)", 851 - ext, PTR_ERR(ext_bh)); 848 + affs_warning(sb, "truncate", 849 + "unexpected read error for ext block %u (%ld)", 850 + (unsigned int)ext, PTR_ERR(ext_bh)); 852 851 return; 853 852 } 854 853 if (AFFS_I(inode)->i_lc) { ··· 895 892 struct buffer_head *bh = affs_bread_ino(inode, last_blk, 0); 896 893 u32 tmp; 897 894 if (IS_ERR(bh)) { 898 - affs_warning(sb, "truncate", "unexpected read error for last block %u (%d)", 899 - ext, PTR_ERR(bh)); 895 + affs_warning(sb, "truncate", 896 + "unexpected read error for last block %u (%ld)", 897 + (unsigned int)ext, PTR_ERR(bh)); 900 898 return; 901 899 } 902 900 tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next);