use memcpy rather than strncpy to avoid compiler warnings

This commit is contained in:
Richard Frith-Macdonald 2020-12-03 11:59:37 -05:00
parent f18594ff3e
commit 379f5f0040

View file

@ -91,8 +91,8 @@ SetValueForKey(NSObject *self, id anObject, const char *key, unsigned size)
char lo;
char hi;
strncpy(buf, "_set", 4);
strncpy(&buf[4], key, size);
memcpy(buf, "_set", 4);
memcpy(&buf[4], key, size);
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
@ -163,8 +163,8 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strncpy(buf, "_get", 4);
strncpy(&buf[4], key, size);
memcpy(buf, "_get", 4);
memcpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
@ -474,12 +474,12 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
SEL sel;
BOOL (*imp)(id,SEL,id*,id*);
strncpy(name, "validate", 8);
memcpy(name, "validate", 8);
[aKey getCString: &name[8]
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(&name[8]);
strncpy(&name[size + 8], ":error:", 7);
memcpy(&name[size + 8], ":error:", 7);
name[size + 15] = '\0';
if (islower(name[8]))
{
@ -611,12 +611,12 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strncpy(buf, "_get", 4);
memcpy(buf, "_get", 4);
[aKey getCString: key
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(key);
strncpy(&buf[4], key, size);
memcpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
@ -696,12 +696,12 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strncpy(buf, "_set", 4);
memcpy(buf, "_set", 4);
[aKey getCString: key
maxLength: size + 1
encoding: NSUTF8StringEncoding];
size = strlen(key);
strncpy(&buf[4], key, size);
memcpy(&buf[4], key, size);
buf[size + 4] = '\0';
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
@ -819,8 +819,8 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
char lo;
char hi;
strncpy(buf, "_set", 4);
strncpy(&buf[4], key, size);
memcpy(buf, "_set", 4);
memcpy(&buf[4], key, size);
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;