strlcpy is smart enough
Subsystems (5)
PATCH 1/1 strlcpy is smart enough
strlcpy already accounts for the trailing zero in its length computation, so there is no need to substract one to the buffer size.
Untested, as I do not have the hardware.
Signed-off-by Jean Delvare <[email protected]>
--- arch/s390/kernel/debug.c | 2 +- arch/xtensa/platform-iss/network.c | 2 +- drivers/net/ehea/ehea_ethtool.c | 4 ++-- sound/aoa/codecs/snd-aoa-codec-onyx.c | 4 ++-- sound/aoa/codecs/snd-aoa-codec-tas.c | 4 ++-- sound/oss/btaudio.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)
arch/s390/kernel/debug.c +1 -1
@@ -268,7 +268,7 @@ debug_info_alloc(char *name, int pages_p rc->level = level; rc->buf_size = buf_size; rc->entry_size =sizeof (debug_entry_t) + buf_size; -strlcpy (rc->name, name,sizeof (rc->name)-1 ); +strlcpy (rc->name, name,sizeof (rc->name));memset (rc->views,0 ,DEBUG_MAX_VIEWS *sizeof (struct debug_view *));memset (rc->debugfs_entries,0 ,DEBUG_MAX_VIEWS *sizeof (struct dentry *));
arch/xtensa/platform-iss/network.c +1 -1
@@ -251,7 +251,7 @@ static int tuntap_open(struct iss_net_prmemset (&ifr,0 ,sizeof ifr); ifr.ifr_flags =IFF_TAP |IFF_NO_PI ; -strlcpy (ifr.ifr_name, dev_name,sizeof ifr.ifr_name -1 ); +strlcpy (ifr.ifr_name, dev_name,sizeof ifr.ifr_name);if ((err =simc_ioctl (fd,TUNSETIFF , (void *) &ifr)) <0 ) { printk("Failed to set interface, returned %d "
drivers/net/ehea/ehea_ethtool.c +2 -2
@@ -144,8 +144,8 @@ static int ehea_nway_reset(struct net_destatic void ehea_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) { -strlcpy (info->driver,DRV_NAME ,sizeof (info->driver) -1 ); -strlcpy (info->version,DRV_VERSION ,sizeof (info->version) -1 ); +strlcpy (info->driver,DRV_NAME ,sizeof (info->driver)); +strlcpy (info->version,DRV_VERSION ,sizeof (info->version)); }static u32 ehea_get_msglevel (struct net_device *dev)
sound/aoa/codecs/snd-aoa-codec-onyx.c +2 -2
@@ -1018,7 +1018,7 @@ static int onyx_create(struct i2c_adapte onyx->i2c.driver = &onyx_driver; onyx->i2c.adapter = adapter; onyx->i2c.addr = addr &0x7f ; -strlcpy (onyx->i2c.name,"onyx audio codec" ,I2C_NAME_SIZE -1 ); +strlcpy (onyx->i2c.name,"onyx audio codec" ,I2C_NAME_SIZE );if (i2c_attach_client (&onyx->i2c)) { printk(KERN_ERR PFX "failed to attach to i2c\n");
@@ -1033,7 +1033,7 @@ static int onyx_create(struct i2c_adapte goto fail; } -strlcpy (onyx->codec.name,"onyx" ,MAX_CODEC_NAME_LEN -1 ); +strlcpy (onyx->codec.name,"onyx" ,MAX_CODEC_NAME_LEN ); onyx->codec.owner =THIS_MODULE ; onyx->codec.init = onyx_init_codec; onyx->codec.exit = onyx_exit_codec;
sound/aoa/codecs/snd-aoa-codec-tas.c +2 -2
@@ -899,14 +899,14 @@ static int tas_create(struct i2c_adapter tas->i2c.addr = addr;/* seems that half is a saner default */ tas->drc_range =TAS3004_DRC_MAX /2 ; -strlcpy (tas->i2c.name,"tas audio codec" ,I2C_NAME_SIZE -1 ); +strlcpy (tas->i2c.name,"tas audio codec" ,I2C_NAME_SIZE );if (i2c_attach_client (&tas->i2c)) { printk(KERN_ERR PFX "failed to attach to i2c\n"); goto fail; } -strlcpy (tas->codec.name,"tas" ,MAX_CODEC_NAME_LEN -1 ); +strlcpy (tas->codec.name,"tas" ,MAX_CODEC_NAME_LEN ); tas->codec.owner =THIS_MODULE ; tas->codec.init = tas_init_codec; tas->codec.exit = tas_exit_codec;
sound/oss/btaudio.c +1 -1
@@ -344,7 +344,7 @@ static int btaudio_mixer_ioctl(struct inif (cmd ==SOUND_OLD_MIXER_INFO ) {_old_mixer_info info;memset (&info,0 ,sizeof (info)); -strlcpy (info.id,"bt878" ,sizeof (info.id)-1 ); +strlcpy (info.id,"bt878" ,sizeof (info.id));strlcpy (info.name,"Brooktree Bt878 audio" ,sizeof (info.name));if (copy_to_user (argp, &info,sizeof (info)))return -EFAULT ;
Signature · 1 line
Jean Delvare