mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-07-24 09:58:16 +00:00
logsys.c: avoid an unnecessary strlen call
* exec/logsys.c (strcpy_cutoff): Use strlen, then memcpy, not strcpy, then strlen. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2143 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
8abcce36f6
commit
0b264ba292
@ -279,12 +279,12 @@ do { \
|
||||
*/
|
||||
static inline int strcpy_cutoff (char *dest, const char *src, int cutoff)
|
||||
{
|
||||
unsigned int len;
|
||||
|
||||
if (cutoff <= 0) {
|
||||
strcpy (dest, src);
|
||||
return (strlen (dest));
|
||||
size_t len = strlen (src);
|
||||
memcpy (dest, src, len + 1);
|
||||
return (len);
|
||||
} else {
|
||||
size_t len;
|
||||
strncpy (dest, src, cutoff);
|
||||
dest[cutoff] = '\0';
|
||||
len = strlen (dest);
|
||||
|
Loading…
Reference in New Issue
Block a user