On 28-Jul-01 David O'Brien wrote:
> I'd like to apply this patch to pkg_add which reduces the amount of code
> the compiler generates, and improves the clarity of the code.
>
> 1. s_strl* is obvious some form of "safe" strl{cpy,cat}. But *WHAT*
> does it make "safe"? Isn't obvious w/o having to track down the
> s_strl{cat,cpy} function definitions.
>
> 2. The current code has more function call overhead than is needed. And
> it reduces the size of the basic block for the optimizer to work on.
> It also potentially has cache miss penalties.
static __inline int
s_strlcpy(char *dst, const char *src, size_t size)
{
return (strlcpy(dst, src, size) >= size);
}
and the same for s_strlcat() is a much shorter patch :) while still being
slightly more readable. Not to mention your patch broke one case by using
'>' instead of '>=' for the test, while just making the functions inline
wouldn't have this problem. :)
> - if (s_strlcpy(FirstPen, optarg, sizeof(FirstPen)))
> + if (strlcpy(FirstPen, optarg, sizeof(FirstPen)) > sizeof(FirstPen))
Should be >=.
--
John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message