On Mon, May 29, 2023 at 11:41 PM He Zhe <zhe...@windriver.com> wrote: > > Sorry for messy encoding... > > > We met the following warning when build linux-yocto v6.1, introduced by > latter diff. It perhaps miscalculates the buf length.
Are you only seeing it with gcc-13 ? That fix follows the same pattern as many other parts of the kernel, and checking the 6.1 branch, those other subsystems still have similar sprintf() changes in place: i.e.: switch (cmd) { case BLKTRACESETUP: snprintf(b, sizeof(b), "%pg", bdev); So I don't see a miscalculation of the buffer length in the snippet you have below. The callers of yaffs_devname declare "buf" to be a char array, just as the other kernel references I mentioned do. The different being that yaffs_devname is an inline function, where the other reference changes are not. What happens if you take the code from the inline function and implement it in the calling function, does the warning go away ? Bruce > > fs/yaffs2/yaffs_vfs.c:122:29: warning: argument to 'sizeof' in 'snprintf' > call is the same expression as the destination; did you mean to provide an > explicit length? [-Wsizeof-pointer-memaccess] > > --- a/fs/yaffs2/yaffs_vfs.c > +++ b/fs/yaffs2/yaffs_vfs.c > @@ -117,7 +117,11 @@ > #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) > > /* FIXME: use sb->s_id instead ? */ > -#define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) > +//#define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) > +static inline char* yaffs_devname(struct super_block *sb, char *buf) { > + snprintf(buf, sizeof(buf), "%pg", sb->s_bdev); > + return buf; > +} > > #else > > > > Thanks, > Zhe > > On 5/30/23 11:34, He Zhe via lists.yoctoproject.org wrote: > > |Hi Bruce, We met the following warning when build linux-yocto v6.1, > > introduced by latter diff. It perhaps miscalculates the buf length. > > fs/yaffs2/yaffs_vfs.c:122:29: warning: argument to 'sizeof' in 'snprintf' > > call is the same expression as the destination; did you mean to provide an > > explicit length? [-Wsizeof-pointer-memaccess] --- a/fs/yaffs2/yaffs_vfs.c > > +++ b/fs/yaffs2/yaffs_vfs.c @@ -117,7 +117,11 @@ #define > > Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) /* FIXME: use > > sb->s_id instead ? */ -#define yaffs_devname(sb, buf) bdevname(sb->s_bdev, > > buf) +//#define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) +static > > inline char* yaffs_devname(struct super_block *sb, char *buf) { + > > snprintf(buf, sizeof(buf), "%pg", sb->s_bdev); + return buf; +} > > #else Thanks, Zhe | > > > > > > > > > -- - Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#12664): https://lists.yoctoproject.org/g/linux-yocto/message/12664 Mute This Topic: https://lists.yoctoproject.org/mt/99213494/21656 Group Owner: linux-yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/leave/6687884/21656/624485779/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-