]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount, eject: replace index() and rindex() with strrch() or strrchr()
authorSami Kerola <kerolasa@iki.fi>
Fri, 12 Oct 2012 19:23:54 +0000 (20:23 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Oct 2012 08:13:32 +0000 (10:13 +0200)
Both index() and rindex() are legacy functions which may be withdrawn in
a future.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/index.html
Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/rindex.html
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libmount/src/tab_parse.c
sys-utils/eject.c

index 463c884e3be865bf98b8800d66fe0b0cd9d40099..2cae750dc2336ae7f363129f7ce8a775bf7a3c50 100644 (file)
@@ -362,14 +362,14 @@ next_line:
                if (fgets(buf, sizeof(buf), f) == NULL)
                        return -EINVAL;
                ++*nlines;
-               s = index (buf, '\n');
+               s = strchr (buf, '\n');
                if (!s) {
                        /* Missing final newline?  Otherwise extremely */
                        /* long line - assume file was corrupted */
                        if (feof(f)) {
                                DBG(TAB, mnt_debug_h(tb,
                                        "%s: no final newline", filename));
-                               s = index (buf, '\0');
+                               s = strchr (buf, '\0');
                        } else {
                                DBG(TAB, mnt_debug_h(tb,
                                        "%s:%d: missing newline at line",
index 1a5b834096b4a4d5182f5dc7d3c1d163fdc18563..5d5d7b18b3aa30520d45b806aa3b03cb03665955 100644 (file)
@@ -499,7 +499,7 @@ static int read_speed(const char *devname)
        if (!f)
                err(EXIT_FAILURE, _("cannot open %s"), _PATH_PROC_CDROMINFO);
 
-       name = rindex(devname, '/') + 1;
+       name = strrchr(devname, '/') + 1;
 
        while (name && !feof(f)) {
                char line[512];