diff mbox series

[v2,1/6] uboot_env: switch to strchr/strrchr

Message ID 20220308085352.183941-2-gary.bisson@boundarydevices.com
State Accepted
Headers show
Series [v2,1/6] uboot_env: switch to strchr/strrchr | expand

Commit Message

Gary Bisson March 8, 2022, 8:53 a.m. UTC
First reason is because index/rindex aren't present in Bionic C library.

Also, per the man page [1]:
"marked as LEGACY in POSIX.1-2001.  POSIX.1-2008 removes the
specifications of index() and rindex(), recommending strchr(3) and
strrchr(3) instead."

[1] https://man7.org/linux/man-pages/man3/index.3.html

Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
---
Changelog v1->v2:
- None
---
 src/uboot_env.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/uboot_env.c b/src/uboot_env.c
index af415c1..a18c246 100644
--- a/src/uboot_env.c
+++ b/src/uboot_env.c
@@ -172,7 +172,7 @@  static int ubi_get_dev_id(char *device)
 	int dev_id = -1;
 	char *sep;
 
-	sep = rindex(device, 'i');
+	sep = strrchr(device, 'i');
 	if (sep)
 		sscanf(sep + 1, "%d", &dev_id);
 
@@ -273,7 +273,7 @@  static int ubi_update_name(struct uboot_flash_env *dev)
 	int dev_id, vol_id, ret = -EBADF;
 	char *sep;
 
-	sep = index(dev->devname, DEVNAME_SEPARATOR);
+	sep = strchr(dev->devname, DEVNAME_SEPARATOR);
 	if (sep)
 	{
 		memset(device, 0, DEVNAME_MAX_LENGTH);
@@ -308,7 +308,7 @@  static int normalize_device_path(char *path, struct uboot_flash_env *dev)
 	 * if volume name is present, split into device path and volume
 	 * since only the device path needs normalized
 	 */
-	sep = index(path, DEVNAME_SEPARATOR);
+	sep = strchr(path, DEVNAME_SEPARATOR);
 	if (sep)
 	{
 		volume_len = strlen(sep);