verify_caps_exec: Replace index() with strchr()
PATCH 1/1 verify_caps_exec: Replace index() with strchr()
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.
--- testcases/kernel/security/filecaps/verify_caps_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/security/filecaps/verify_caps_exec.c +1 -1
@@ -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" );
PATCH 1/1 verify_caps_exec: Replace index() with strchr()
Hi Alistair,
Quoted 15 lines
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 <[email protected]>--- testcases/kernel/security/filecaps/verify_caps_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/kernel/security/filecaps/verify_caps_exec.c +0
-0
testcases/kernel/security/filecaps/verify_caps_exec.c static int fork_drop_and_exec(int keepperms, cap_t expected_caps) · line 192
Quoted 8 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1@@ -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
PATCH 1/1 cpuset_lib: Replace index() with strchr()
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.
--- testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c +1 -1
@@ -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++;
PATCH 1/1 pounder21: Replace {r,}index() with str{r,}chr()
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.
--- 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(-)
tools/pounder21/fancy_timed_loop.c +2 -2
@@ -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 {
tools/pounder21/infinite_loop.c +2 -2
@@ -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 {
tools/pounder21/run.c +3 -3
@@ -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
tools/pounder21/timed_loop.c +2 -2
@@ -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 {
PATCH 1/1 pounder21: Replace {r,}index() with str{r,}chr()
Hi Alistair,
Quoted 9 lines
The
index()andrindex()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()andstrrchr()functions from C89.Affects
fancy_timed_loop,infinite_loop, run-helper, andtimed_looptargets.Signed-off-by Alistair Strachan <[email protected]>
Patch merged, thanks!
Kind regards,
Petr
PATCH 1/1 cpuset_lib: Replace index() with strchr()
In reply to Alistair StrachanHi Alistair,
Quoted 6 lines
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 <[email protected]>
Thanks for your patch, pushed!
Kind regards,
Petr