embryo - embryo_cc - one more warning bites the dust

This commit is contained in:
Carsten Haitzler 2021-05-26 13:50:07 +01:00
parent 0dab01b44d
commit 26ea0eaac2
1 changed files with 12 additions and 13 deletions

View File

@ -3032,22 +3032,21 @@ insert_constval(constvalue * prev, constvalue * next, char *name,
cell val, short idx) cell val, short idx)
{ {
constvalue *cur; constvalue *cur;
// char *s, *d; char *s, *d;
if (!(cur = calloc(1, sizeof(constvalue)))) if (!(cur = calloc(1, sizeof(constvalue))))
error(103); /* insufficient memory (fatal error) */ error(103); /* insufficient memory (fatal error) */
strncpy(cur->name, name, sizeof(cur->name) - 1);
// I'm forced to do the below as new gcc warnings I can't seem to shut up // new gcc's want to warn about this.. it doesn't make sense... but if i
// complain so implement in full to get some silence. // implement strncpy inline to get some peace and quiet
// for (d = cur->name, s = name; ; ) // strncpy(cur->name, name, sizeof(cur->name) - 1);
// { for (s = name, d = cur->name; ; )
// *d++ = *s; {
// if ((size_t)(s - name) < (size_t)(sizeof(cur->name) - 1)) *d = *s;
// { if (*s) s++;
// if (*s) s++; if ((d - cur->name) == (sizeof(cur->name) - 1)) break;
// } d++;
// else break; }
// }
cur->name[sizeof(cur->name) - 1] = 0; cur->name[sizeof(cur->name) - 1] = 0;
cur->value = val; cur->value = val;
cur->index = idx; cur->index = idx;