fix return value to reflect final string length

This commit is contained in:
HummyPkg 2017-03-09 20:11:34 +00:00
parent 4002df3b86
commit 92adb68964
2 changed files with 4 additions and 4 deletions

6
test.c
View File

@ -53,14 +53,14 @@ int
main() main()
{ {
char buf[0x200]; char buf[0x200];
int i; int i, l;
for (i = 0; teststr[i]; i++) for (i = 0; teststr[i]; i++)
{ {
hexdump(teststr[i], 0); hexdump(teststr[i], 0);
if (xconv(teststr[i], buf, sizeof(buf))) if ((l = xconv(teststr[i], buf, sizeof(buf))))
hexdump(buf, 0); hexdump(buf, l);
else else
printf("Unchanged.\n"); printf("Unchanged.\n");

View File

@ -107,6 +107,6 @@ xconv(char *src, char *dst, size_t dstlen)
return 0; return 0;
*d = '\0'; *d = '\0';
return dstlen - len; return dstlen - len - 1;
} }