The len variable is used later on. Introduce a new one (debug length) to
limit the amount of characters written to stderr.
Could be further improved with %.*s but let's keep it as simple as
possible, since DEBUG is not default and has to be manually set in
line 89.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
#if DEBUG
{
char buff[1024];
- if (len > (int)(sizeof(buff)-1))
- len = (int)(sizeof(buff)-1);
- strncpy(buff, s, len);
- buff[len] = 0;
- fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff);
+ size_t dlen = len;
+ if (dlen > sizeof(buff) - 1)
+ dlen = sizeof(buff) - 1;
+ strncpy(buff, s, dlen);
+ buff[dlen] = 0;
+ fprintf(stderr, "\tlen=%zu:\"%s\"\n", dlen, buff);
}
#endif
switch (xar->xmlsts) {