This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] SPU strncpy fix


Patch checked in.

-- Jeff J.

Ken Werner wrote:
On Thursday 17 July 2008 17:15, Jeff Johnston wrote:
Yes, go ahead.

-- Jeff J.
Ken Werner wrote:
Hi,

according to the C standard strncpy should pad null bytes if the length
of the "src" string is less than "n". Ok to Apply?

Ken
Jeff,

the previous fix doesn't work properly because I mixed the curlen up - sorry. The appended patch fixes that. It applies on top of the preceding patch. The string-opt-5 test (gcc/testsuite/gcc.c-torture/execute/string-opt-5.c) of the GCC testsuite passes now.
Thanks.
Ken


newlib/ChangeLog:

2008-07-18 Ken Werner <ken.werner@de.ibm.com>

* libc/machine/spu/strcpy.h: Fixes null byte padding.

Index: src/newlib/libc/machine/spu/strcpy.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/strcpy.h,v
retrieving revision 1.2
diff -u -r1.2 strcpy.h
--- src/newlib/libc/machine/spu/strcpy.h 17 Jul 2008 19:00:44 -0000 1.2
+++ src/newlib/libc/machine/spu/strcpy.h 18 Jul 2008 15:32:03 -0000
@@ -178,7 +178,7 @@
}
/* Pad null bytes if the length of the "src" is less than "n" (strncpy). */
- if (checklen && !lastzero && (maxlen != spu_extract(curlen,0)))
- memset(dest + spu_extract(curlen, 0), 0, maxlen - spu_extract(curlen, 0));
+ if (checklen && !lastzero && spu_extract(curlen, 0))
+ memset(dest + maxlen - spu_extract(curlen, 0), 0, spu_extract(curlen, 0));
return (dest);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]