add memccpy.c

Not sure if this is worth the added bin size yet but I will
see where I can use it to try and make it worth it

Change-Id: Icc299d3986172ff224a14be48da3bf065d728a66
This commit is contained in:
William Wilgus 2022-11-14 10:01:14 -05:00 committed by William Wilgus
parent 034b6d5bfb
commit b25a9d8f99
6 changed files with 139 additions and 5 deletions

View file

@ -1627,7 +1627,9 @@ static int ata_smart_attr_to_string(
if (len >= name_sz) len = name_sz-1;
slen += len;
}
snprintf(str+slen, size-slen, "%s", buf);
if (!memccpy (str+slen, buf, '\0', size-slen))
(str+slen)[size-slen - 1] = '\0';
}
return 1; /* ok */