This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch] eliminate use-cases of obsolete functions
- From: Ralf Corsepius <ralf dot corsepius at rtems dot org>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Tue, 23 Aug 2011 07:09:10 +0200
- Subject: [patch] eliminate use-cases of obsolete functions
Hi,
The patch below is aiming at eliminating two use-cases of functions
POSIX has declared obsolete.
Ralf
NB.: I am not sure, if using memcpy instead of bcopy is correct or if
this bcopy should better be replaced with memmove, because I don't know
if setenv_r's src/dst memory areas may overlap or not.
2011-08-23 Ralf Corsépius <ralf.corsepius@rtems.org>
* libc/stdlib/putenv_r.c: Use "strchr" instead of obsolete "index".
* libc/stdlib/setenv_r.c: Use "memcpy" instead of obsolete "bcopy".
Index: libc/stdlib/putenv_r.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/putenv_r.c,v
retrieving revision 1.4
diff -u -r1.4 putenv_r.c
--- libc/stdlib/putenv_r.c 24 Nov 2004 22:34:14 -0000 1.4
+++ libc/stdlib/putenv_r.c 23 Aug 2011 04:57:09 -0000
@@ -43,7 +43,7 @@
if (!p)
return 1;
- if (!(equal = index (p, '=')))
+ if (!(equal = strchr (p, '=')))
{
(void) _free_r (reent_ptr, p);
return 1;
Index: libc/stdlib/setenv_r.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/setenv_r.c,v
retrieving revision 1.8
diff -u -r1.8 setenv_r.c
--- libc/stdlib/setenv_r.c 25 Sep 2008 03:00:04 -0000 1.8
+++ libc/stdlib/setenv_r.c 23 Aug 2011 04:57:09 -0000
@@ -110,7 +110,7 @@
ENV_UNLOCK;
return (-1);
}
- bcopy ((char *) *p_environ, (char *) P, cnt * sizeof (char *));
+ memcpy((char *) P,(char *) *p_environ, cnt * sizeof (char *));
*p_environ = P;
}
(*p_environ)[cnt + 1] = NULL;