Re: [PATCH] partitions: Prefer strlcpy() over snprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andries,

On Thu, 10 Jul 2008 14:28:01 +0200, Andries E. Brouwer wrote:
> On Thu, Jul 10, 2008 at 01:30:04PM +0200, Jean Delvare wrote:
> > Subject: partitions: Prefer strlcpy() over snprintf()
> > 
> > strlcpy is faster than snprintf when you don't use the returned value.
> 
> >  	if (!part)
> > -		snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
> > +		strlcpy(buf, hd->disk_name, BDEVNAME_SIZE);
> >  	else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
> >  		snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, part);
> >  	else
> 
> Yecch. There is a parallelism between the two cases
> which makes the source nice and readable.
> You want to destroy the parallelism for no gain.
> Different functions, different parameter order. Ach.

At the moment I hit "Send" I thought about that and suspected that
someone would object for that reason. And that makes sense, indeed.
Just scratch this patch, sorry for the noise.

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux