diff mbox series

verify_caps_exec: Replace index() with strchr()

Message ID 20180624203456.30476-1-astrachan@google.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series verify_caps_exec: Replace index() with strchr() | expand

Commit Message

Alistair Strachan June 24, 2018, 8:34 p.m. UTC
The index() function was removed in POSIX.2008. It is not implemented by
Android's bionic C library for 64-bit platforms.

Use the more portable strchr() function from C89.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/kernel/security/filecaps/verify_caps_exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel July 3, 2018, 9:10 a.m. UTC | #1
Hi Alistair,

> The index() function was removed in POSIX.2008. It is not implemented by
> Android's bionic C library for 64-bit platforms.

> Use the more portable strchr() function from C89.

> Signed-off-by: Alistair Strachan <astrachan@google.com>
> ---
>  testcases/kernel/security/filecaps/verify_caps_exec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c b/testcases/kernel/security/filecaps/verify_caps_exec.c
> index 2c5cc0b2a..7183d8b4a 100644
> --- a/testcases/kernel/security/filecaps/verify_caps_exec.c
> +++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
> @@ -186,7 +186,7 @@ static int fork_drop_and_exec(int keepperms, cap_t expected_caps)
>  				 "got a bad seqno (c=%d, s=%d, seqno=%d)", c, s,
>  				 seqno);
>  		}
> -		p = index(buf, '.');
> +		p = strchr(buf, '.');
>  		if (!p)
>  			tst_brkm(TFAIL, NULL,
>  				 "got a bad message from print_caps\n");

Thanks for your patch, merged.

BTW there are more uses of index() / rindex() in the project.


Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c b/testcases/kernel/security/filecaps/verify_caps_exec.c
index 2c5cc0b2a..7183d8b4a 100644
--- a/testcases/kernel/security/filecaps/verify_caps_exec.c
+++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
@@ -186,7 +186,7 @@  static int fork_drop_and_exec(int keepperms, cap_t expected_caps)
 				 "got a bad seqno (c=%d, s=%d, seqno=%d)", c, s,
 				 seqno);
 		}
-		p = index(buf, '.');
+		p = strchr(buf, '.');
 		if (!p)
 			tst_brkm(TFAIL, NULL,
 				 "got a bad message from print_caps\n");