]> granicus.if.org Git - sysstat/commitdiff
Replace index() call with strchr() call
authorTom Hebb <tch@fb.com>
Wed, 3 Jun 2020 18:57:21 +0000 (11:57 -0700)
committerTom Hebb <tch@fb.com>
Wed, 3 Jun 2020 18:57:21 +0000 (11:57 -0700)
According to glibc documentation[1], "index is another name for strchr;
they are exactly the same. New code should always use strchr." The use
of index() breaks compilation for Android targets, which use Bionic
instead of glibc and don't have index().

[1] https://www.gnu.org/software/libc/manual/html_node/Search-Functions.html#index-index

common.c
tests/12.0.1/common.c

index bf55e057b9776b4f0bd942e9f158ba33152e214d..c30bdc8b73ef7a3aa11b43b8c776fe0260668746 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1478,7 +1478,7 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char
                        strncpy(range, t, 16);
                        range[15] = '\0';
                        valstr = t;
-                       if ((s = index(range, '-')) != NULL) {
+                       if ((s = strchr(range, '-')) != NULL) {
                                /* Possible range of values */
                                *s = '\0';
                                if (parse_valstr(range, max_val, &val_low) || (val_low < 0))
index 25ab1fcf0d8399e2766fe66138617fe2932aaeab..b623a4c8b9d3e9223eced398db5f72c2d5ad2b78 100644 (file)
@@ -1403,7 +1403,7 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char
                        strncpy(range, t, 16);
                        range[15] = '\0';
                        valstr = t;
-                       if ((s = index(range, '-')) != NULL) {
+                       if ((s = strchr(range, '-')) != NULL) {
                                /* Possible range of values */
                                *s = '\0';
                                if (parse_valstr(range, max_val, &val_low) || (val_low < 0))