public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] verify_caps_exec: Replace index() with strchr()
@ 2018-06-24 20:34 Alistair Strachan
  2018-07-03  9:10 ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Alistair Strachan @ 2018-06-24 20:34 UTC (permalink / raw)
  To: ltp

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");

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH] verify_caps_exec: Replace index() with strchr()
  2018-06-24 20:34 [LTP] [PATCH] verify_caps_exec: Replace index() with strchr() Alistair Strachan
@ 2018-07-03  9:10 ` Petr Vorel
  2018-07-11 16:49   ` [LTP] [PATCH] cpuset_lib: " Alistair Strachan
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2018-07-03  9:10 UTC (permalink / raw)
  To: ltp

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH] cpuset_lib: Replace index() with strchr()
  2018-07-03  9:10 ` Petr Vorel
@ 2018-07-11 16:49   ` Alistair Strachan
  2018-07-11 16:49     ` [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr() Alistair Strachan
  2018-07-23 11:54     ` [LTP] [PATCH] cpuset_lib: Replace index() with strchr() Petr Vorel
  0 siblings, 2 replies; 6+ messages in thread
From: Alistair Strachan @ 2018-07-11 16:49 UTC (permalink / raw)
  To: ltp

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/controllers/cpuset/cpuset_lib/cpuinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
index c2a60b683..575a61bcd 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
@@ -59,7 +59,7 @@ static int get_cpu_baseinfo(void)
 	/* get cpuinfo */
 	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		istr = strtok_r(buf, "\t", &saveptr);
-		valstr = index(saveptr, ':');
+		valstr = strchr(saveptr, ':');
 		if (valstr == NULL)
 			continue;
 		valstr++;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr()
  2018-07-11 16:49   ` [LTP] [PATCH] cpuset_lib: " Alistair Strachan
@ 2018-07-11 16:49     ` Alistair Strachan
  2018-07-23 12:06       ` Petr Vorel
  2018-07-23 11:54     ` [LTP] [PATCH] cpuset_lib: Replace index() with strchr() Petr Vorel
  1 sibling, 1 reply; 6+ messages in thread
From: Alistair Strachan @ 2018-07-11 16:49 UTC (permalink / raw)
  To: ltp

The index() and rindex() functions were removed in POSIX.2008. They are
not implemented by Android's bionic C library for 64-bit platforms.

Use the more portable strchr() and strrchr() functions from C89.

Affects fancy_timed_loop, infinite_loop, run-helper, and timed_loop
targets.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 tools/pounder21/fancy_timed_loop.c | 4 ++--
 tools/pounder21/infinite_loop.c    | 4 ++--
 tools/pounder21/run.c              | 6 +++---
 tools/pounder21/timed_loop.c       | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/pounder21/fancy_timed_loop.c b/tools/pounder21/fancy_timed_loop.c
index ac3e204d1..f88be3df8 100644
--- a/tools/pounder21/fancy_timed_loop.c
+++ b/tools/pounder21/fancy_timed_loop.c
@@ -93,14 +93,14 @@ int main(int argc, char *argv[])
 	out = stdout;
 
 	if (use_max_failures) {
-		progname = rindex(argv[7], '/');
+		progname = strrchr(argv[7], '/');
 		if (progname == NULL) {
 			progname = argv[7];
 		} else {
 			progname++;
 		}
 	} else {
-		progname = rindex(argv[5], '/');
+		progname = strrchr(argv[5], '/');
 		if (progname == NULL) {
 			progname = argv[5];
 		} else {
diff --git a/tools/pounder21/infinite_loop.c b/tools/pounder21/infinite_loop.c
index fbe4289ac..e1a0d3dfb 100644
--- a/tools/pounder21/infinite_loop.c
+++ b/tools/pounder21/infinite_loop.c
@@ -78,14 +78,14 @@ int main(int argc, char *argv[])
 	out = stdout;
 
 	if (use_max_failures) {
-		progname = rindex(argv[3], '/');
+		progname = strrchr(argv[3], '/');
 		if (progname == NULL) {
 			progname = argv[3];
 		} else {
 			progname++;
 		}
 	} else {
-		progname = rindex(argv[1], '/');
+		progname = strrchr(argv[1], '/');
 		if (progname == NULL) {
 			progname = argv[1];
 		} else {
diff --git a/tools/pounder21/run.c b/tools/pounder21/run.c
index dec2d3fe7..5f5903c45 100644
--- a/tools/pounder21/run.c
+++ b/tools/pounder21/run.c
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
 		retcode = process_dir(argv[1]);
 	} else {
 		if (is_executable(argv[1])) {
-			c = rindex(argv[1], '/');
+			c = strrchr(argv[1], '/');
 			c++;
 
 			// Start the test
@@ -495,7 +495,7 @@ static pid_t spawn_test(char *fname)
 			 getenv("POUNDER_LOGDIR"), fname);
 
 		fd = strlen(buf2);
-		for (tmp = (index(buf2, '|') - buf2); tmp < fd; tmp++) {
+		for (tmp = (strchr(buf2, '|') - buf2); tmp < fd; tmp++) {
 			if (buf2[tmp] == '/') {
 				buf2[tmp] = '-';
 			} else if (buf2[tmp] == '|') {
@@ -541,7 +541,7 @@ static pid_t spawn_test(char *fname)
 		snprintf(buf2, TEST_PATH_LEN, "%s/%s", buf, fname);
 
 		// find the location of the last slash
-		last_slash = rindex(buf2, '/');
+		last_slash = strrchr(buf2, '/');
 
 		if (last_slash != NULL) {
 			// copy the filename part into a new buffer
diff --git a/tools/pounder21/timed_loop.c b/tools/pounder21/timed_loop.c
index 51ceac5f2..3dffba0dc 100644
--- a/tools/pounder21/timed_loop.c
+++ b/tools/pounder21/timed_loop.c
@@ -95,14 +95,14 @@ int main(int argc, char *argv[])
 	out = stdout;
 
 	if (use_max_failures) {
-		progname = rindex(argv[4], '/');
+		progname = strrchr(argv[4], '/');
 		if (progname == NULL) {
 			progname = argv[4];
 		} else {
 			progname++;
 		}
 	} else {
-		progname = rindex(argv[2], '/');
+		progname = strrchr(argv[2], '/');
 		if (progname == NULL) {
 			progname = argv[2];
 		} else {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH] cpuset_lib: Replace index() with strchr()
  2018-07-11 16:49   ` [LTP] [PATCH] cpuset_lib: " Alistair Strachan
  2018-07-11 16:49     ` [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr() Alistair Strachan
@ 2018-07-23 11:54     ` Petr Vorel
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2018-07-23 11:54 UTC (permalink / raw)
  To: ltp

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>

Thanks for your patch, pushed!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr()
  2018-07-11 16:49     ` [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr() Alistair Strachan
@ 2018-07-23 12:06       ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2018-07-23 12:06 UTC (permalink / raw)
  To: ltp

Hi Alistair,

> The index() and rindex() functions were removed in POSIX.2008. They are
> not implemented by Android's bionic C library for 64-bit platforms.

> Use the more portable strchr() and strrchr() functions from C89.

> Affects fancy_timed_loop, infinite_loop, run-helper, and timed_loop
> targets.

> Signed-off-by: Alistair Strachan <astrachan@google.com>

Patch merged, thanks!


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-23 12:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-24 20:34 [LTP] [PATCH] verify_caps_exec: Replace index() with strchr() Alistair Strachan
2018-07-03  9:10 ` Petr Vorel
2018-07-11 16:49   ` [LTP] [PATCH] cpuset_lib: " Alistair Strachan
2018-07-11 16:49     ` [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr() Alistair Strachan
2018-07-23 12:06       ` Petr Vorel
2018-07-23 11:54     ` [LTP] [PATCH] cpuset_lib: Replace index() with strchr() Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox