Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
* [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr()
@ 2019-11-22 16:31 Petr Vorel
  2019-11-22 16:54 ` Petr Vorel
  2019-11-22 18:27 ` Steve Dickson
  0 siblings, 2 replies; 3+ messages in thread
From: Petr Vorel @ 2019-11-22 16:31 UTC (permalink / raw)
  To: linux-nfs; +Cc: Frederik Pasch, Steve Dickson, Gustavo Zacarias, Petr Vorel

From: Frederik Pasch <fpasch@googlemail.com>

[ gustavo: rebased to 1.2.6 ]
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
[ pvorel: taken from Buildroot distribution, rebased ]
Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Frederik Pasch <fpasch@googlemail.com>
---
 support/nfs/nfs_mntent.c | 6 +++---
 utils/mount/error.c      | 2 +-
 utils/mountd/fsloc.c     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/support/nfs/nfs_mntent.c b/support/nfs/nfs_mntent.c
index 05a4c687..25e5944a 100644
--- a/support/nfs/nfs_mntent.c
+++ b/support/nfs/nfs_mntent.c
@@ -9,7 +9,7 @@
  */
 
 #include <stdio.h>
-#include <string.h>		/* for index */
+#include <string.h>		/* for strchr */
 #include <ctype.h>		/* for isdigit */
 #include <sys/stat.h>		/* for umask */
 #include <unistd.h>		/* for ftruncate */
@@ -176,7 +176,7 @@ nfs_getmntent (mntFILE *mfp) {
 			return NULL;
 
 		mfp->mntent_lineno++;
-		s = index (buf, '\n');
+		s = strchr (buf, '\n');
 		if (s == NULL) {
 			/* Missing final newline?  Otherwise extremely */
 			/* long line - assume file was corrupted */
@@ -184,7 +184,7 @@ nfs_getmntent (mntFILE *mfp) {
 				fprintf(stderr, _("[mntent]: warning: no final "
 					"newline at the end of %s\n"),
 					mfp->mntent_file);
-				s = index (buf, 0);
+				s = strchr (buf, 0);
 			} else {
 				mfp->mntent_errs = 1;
 				goto err;
diff --git a/utils/mount/error.c b/utils/mount/error.c
index 562f312e..986f0660 100644
--- a/utils/mount/error.c
+++ b/utils/mount/error.c
@@ -62,7 +62,7 @@ static int rpc_strerror(int spos)
 	char *tmp;
 
 	if (estr) {
-		if ((ptr = index(estr, ':')))
+		if ((ptr = strchr(estr, ':')))
 			estr = ++ptr;
 
 		tmp = &errbuf[spos];
diff --git a/utils/mountd/fsloc.c b/utils/mountd/fsloc.c
index cf42944f..1b869b60 100644
--- a/utils/mountd/fsloc.c
+++ b/utils/mountd/fsloc.c
@@ -128,7 +128,7 @@ static struct servers *method_list(char *data)
 	bool v6esc = false;
 
 	xlog(L_NOTICE, "method_list(%s)", data);
-	for (ptr--, listsize=1; ptr; ptr=index(ptr, ':'), listsize++)
+	for (ptr--, listsize=1; ptr; ptr=strchr(ptr, ':'), listsize++)
 		ptr++;
 	list = malloc(listsize * sizeof(char *));
 	copy = strdup(data);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr()
  2019-11-22 16:31 [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr() Petr Vorel
@ 2019-11-22 16:54 ` Petr Vorel
  2019-11-22 18:27 ` Steve Dickson
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2019-11-22 16:54 UTC (permalink / raw)
  To: linux-nfs, Steve Dickson; +Cc: Frederik Pasch, Gustavo Zacarias

Hi Steve,

> From: Frederik Pasch <fpasch@googlemail.com>

NOTE: this fixes build on musl, which has index() only in legacy <strings.h>
(not in <string.h> unlike glibc/uclibc).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr()
  2019-11-22 16:31 [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr() Petr Vorel
  2019-11-22 16:54 ` Petr Vorel
@ 2019-11-22 18:27 ` Steve Dickson
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Dickson @ 2019-11-22 18:27 UTC (permalink / raw)
  To: Petr Vorel, linux-nfs; +Cc: Frederik Pasch, Gustavo Zacarias



On 11/22/19 11:31 AM, Petr Vorel wrote:
> From: Frederik Pasch <fpasch@googlemail.com>
> 
> [ gustavo: rebased to 1.2.6 ]
> Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
> [ pvorel: taken from Buildroot distribution, rebased ]
> Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> Signed-off-by: Frederik Pasch <fpasch@googlemail.com>
> ---
>  support/nfs/nfs_mntent.c | 6 +++---
>  utils/mount/error.c      | 2 +-
>  utils/mountd/fsloc.c     | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
Committed... (tag: nfs-utils-2-4-3-rc2)

steved.
> 
> diff --git a/support/nfs/nfs_mntent.c b/support/nfs/nfs_mntent.c
> index 05a4c687..25e5944a 100644
> --- a/support/nfs/nfs_mntent.c
> +++ b/support/nfs/nfs_mntent.c
> @@ -9,7 +9,7 @@
>   */
>  
>  #include <stdio.h>
> -#include <string.h>		/* for index */
> +#include <string.h>		/* for strchr */
>  #include <ctype.h>		/* for isdigit */
>  #include <sys/stat.h>		/* for umask */
>  #include <unistd.h>		/* for ftruncate */
> @@ -176,7 +176,7 @@ nfs_getmntent (mntFILE *mfp) {
>  			return NULL;
>  
>  		mfp->mntent_lineno++;
> -		s = index (buf, '\n');
> +		s = strchr (buf, '\n');
>  		if (s == NULL) {
>  			/* Missing final newline?  Otherwise extremely */
>  			/* long line - assume file was corrupted */
> @@ -184,7 +184,7 @@ nfs_getmntent (mntFILE *mfp) {
>  				fprintf(stderr, _("[mntent]: warning: no final "
>  					"newline at the end of %s\n"),
>  					mfp->mntent_file);
> -				s = index (buf, 0);
> +				s = strchr (buf, 0);
>  			} else {
>  				mfp->mntent_errs = 1;
>  				goto err;
> diff --git a/utils/mount/error.c b/utils/mount/error.c
> index 562f312e..986f0660 100644
> --- a/utils/mount/error.c
> +++ b/utils/mount/error.c
> @@ -62,7 +62,7 @@ static int rpc_strerror(int spos)
>  	char *tmp;
>  
>  	if (estr) {
> -		if ((ptr = index(estr, ':')))
> +		if ((ptr = strchr(estr, ':')))
>  			estr = ++ptr;
>  
>  		tmp = &errbuf[spos];
> diff --git a/utils/mountd/fsloc.c b/utils/mountd/fsloc.c
> index cf42944f..1b869b60 100644
> --- a/utils/mountd/fsloc.c
> +++ b/utils/mountd/fsloc.c
> @@ -128,7 +128,7 @@ static struct servers *method_list(char *data)
>  	bool v6esc = false;
>  
>  	xlog(L_NOTICE, "method_list(%s)", data);
> -	for (ptr--, listsize=1; ptr; ptr=index(ptr, ':'), listsize++)
> +	for (ptr--, listsize=1; ptr; ptr=strchr(ptr, ':'), listsize++)
>  		ptr++;
>  	list = malloc(listsize * sizeof(char *));
>  	copy = strdup(data);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 16:31 [nfs-utils PATCH 1/1] Switch legacy index() in favour of strchr() Petr Vorel
2019-11-22 16:54 ` Petr Vorel
2019-11-22 18:27 ` Steve Dickson

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git