From: Alistair Strachan <astrachan@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr()
Date: Wed, 11 Jul 2018 09:49:25 -0700 [thread overview]
Message-ID: <20180711164925.65342-2-astrachan@google.com> (raw)
In-Reply-To: <20180711164925.65342-1-astrachan@google.com>
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 {
next prev parent reply other threads:[~2018-07-11 16:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Alistair Strachan [this message]
2018-07-23 12:06 ` [LTP] [PATCH] pounder21: Replace {r,}index() with str{r,}chr() Petr Vorel
2018-07-23 11:54 ` [LTP] [PATCH] cpuset_lib: Replace index() with strchr() Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180711164925.65342-2-astrachan@google.com \
--to=astrachan@google.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox