diff mbox

Remove index defines

Message ID AM5PR0802MB261063CC8262F5A1F093623983670@AM5PR0802MB2610.eurprd08.prod.outlook.com
State Superseded
Headers show

Commit Message

Wilco Dijkstra Jan. 10, 2017, 5:23 p.m. UTC
As a minor cleanup remove the (r)index defines from include/string.h as they are only
used internally in a few places.  Rename a few uses that occur in libc.so.

ChangeLog:
2017-01-10  Wilco Dijkstra  <wdijkstr@arm.com>

	* include/string.h (index): Remove define.
	(rindex): Likewise.
	* misc/getttyent.c (__getttyent): Rename index to strchr.
	* misc/ttyslot.c (ttyslot): Rename rindex to strrchr.
--

Comments

Joseph Myers Jan. 10, 2017, 5:32 p.m. UTC | #1
On Tue, 10 Jan 2017, Wilco Dijkstra wrote:

> As a minor cleanup remove the (r)index defines from include/string.h as 
> they are only used internally in a few places.  Rename a few uses that 
> occur in libc.so.

How did you identify where should be changed?  Did you make sure installed 
stripped shared libraries were unchanged by the patch?

I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to 
be similarly changed.
Wilco Dijkstra Jan. 10, 2017, 6:12 p.m. UTC | #2
Joseph Myers wrote:
> On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
>
> > As a minor cleanup remove the (r)index defines from include/string.h as 
> > they are only used internally in a few places.  Rename a few uses that 
> > occur in libc.so.
>
> How did you identify where should be changed?  Did you make sure installed 
> stripped shared libraries were unchanged by the patch?
>
> I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to 
> be similarly changed.

I checked there are no local plt failures and no uses of it in the libc/libm.so. 
sunrpc/rpc_main.c seems to be an application, so it's OK to use (r)index.

I can't find the functions in hurd/path-lookup.c in any .so, in fact none of the
files in hurd seem to be built.  Is it dead or only used for a subset of targets?

Wilco
Joseph Myers Jan. 10, 2017, 6:36 p.m. UTC | #3
On Tue, 10 Jan 2017, Wilco Dijkstra wrote:

> Joseph Myers wrote:
> > On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
> >
> > > As a minor cleanup remove the (r)index defines from include/string.h as 
> > > they are only used internally in a few places.  Rename a few uses that 
> > > occur in libc.so.
> >
> > How did you identify where should be changed?  Did you make sure installed 
> > stripped shared libraries were unchanged by the patch?
> >
> > I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to 
> > be similarly changed.
> 
> I checked there are no local plt failures and no uses of it in the libc/libm.so. 
> sunrpc/rpc_main.c seems to be an application, so it's OK to use (r)index.

That doesn't mean it's a good idea for it to use those obsolete symbols.

> I can't find the functions in hurd/path-lookup.c in any .so, in fact 
> none of the files in hurd seem to be built.  Is it dead or only used for 
> a subset of targets?

It's built, as you would expect, for Hurd targets.  Hurd and NaCl people 
have not yet contributed build-many-glibcs.py patches to build unmodified 
sources for those targets (or pointed to sufficiently clear instructions 
on kernel headers etc. for someone unfamiliar with those targets to add 
support), so they are not yet covered by that script.
diff mbox

Patch

diff --git a/include/string.h b/include/string.h
index e145bfdb4cb781fbced37634410dd2b844571f16..89e4bc4c91b0aea9480b21d43f95c75554d50383 100644
--- a/include/string.h
+++ b/include/string.h
@@ -149,15 +149,6 @@  extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
 extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
 #endif
 
-# ifndef _ISOMAC
-#  ifndef index
-#   define index(s, c)	(strchr ((s), (c)))
-#  endif
-#  ifndef rindex
-#   define rindex(s, c)	(strrchr ((s), (c)))
-#  endif
-# endif
-
 extern void *__memcpy_chk (void *__restrict __dest,
 			   const void *__restrict __src, size_t __len,
 			   size_t __destlen) __THROW;
diff --git a/misc/getttyent.c b/misc/getttyent.c
index d2af87012343b0596d50dfdecff14ecf55c16732..73002f52d10dc30af95d3163bc5f7a1992fe9dce 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -78,7 +78,7 @@  __getttyent (void)
 			return (NULL);
 		}
 		/* skip lines that are too big */
-		if (!index(p, '\n')) {
+		if (!strchr (p, '\n')) {
 			while ((c = getc_unlocked(tf)) != '\n' && c != EOF)
 				;
 			continue;
@@ -127,7 +127,7 @@  __getttyent (void)
 	tty.ty_comment = p;
 	if (*p == 0)
 		tty.ty_comment = 0;
-	if ((p = index(p, '\n')))
+	if ((p = strchr (p, '\n')))
 		*p = '\0';
 	return (&tty);
 }
@@ -179,7 +179,7 @@  internal_function
 value (char *p)
 {
 
-	return ((p = index(p, '=')) ? ++p : NULL);
+	return ((p = strchr (p, '=')) ? ++p : NULL);
 }
 
 int
diff --git a/misc/ttyslot.c b/misc/ttyslot.c
index 0ed14d73ea53e7ed09c58717316fea20fa0177eb..2f3c7953d75c8522f3b6447c43a9e33aa19e8f72 100644
--- a/misc/ttyslot.c
+++ b/misc/ttyslot.c
@@ -56,7 +56,7 @@  ttyslot (void)
 	__setttyent();
 	for (cnt = 0; cnt < 3; ++cnt)
 		if (__ttyname_r (cnt, name, buflen) == 0) {
-			if ((p = rindex(name, '/')))
+			if ((p = strrchr (name, '/')))
 				++p;
 			else
 				p = name;