mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Frediano Ziglio <fziglio@redhat.com>
To: musl@lists.openwall.com
Cc: Frediano Ziglio <fziglio@redhat.com>
Subject: [PATCH 2/2] avoid passing a parameter
Date: Tue, 26 Mar 2019 09:36:48 +0000	[thread overview]
Message-ID: <20190326093648.5669-2-fziglio@redhat.com> (raw)
In-Reply-To: <20190326093648.5669-1-fziglio@redhat.com>

Make code slightly smaller.
"file" should not be long and it should fit in NAME_MAX so
this code would be faster only rarely.
---
 src/process/execvp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/process/execvp.c b/src/process/execvp.c
index ef3b9dd5..a2726af9 100644
--- a/src/process/execvp.c
+++ b/src/process/execvp.c
@@ -19,7 +19,7 @@ int __execvpe(const char *file, char *const argv[], char *const envp[])
 		return execve(file, argv, envp);
 
 	if (!path) path = "/usr/local/bin:/bin:/usr/bin";
-	k = strnlen(file, NAME_MAX+1);
+	k = strlen(file);
 	if (k > NAME_MAX) {
 		errno = ENAMETOOLONG;
 		return -1;
-- 
2.20.1



  reply	other threads:[~2019-03-26  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26  9:36 [PATCH 1/2] use __strchrnul instead of strchr and strlen Frediano Ziglio
2019-03-26  9:36 ` Frediano Ziglio [this message]
2019-03-26 15:07   ` [PATCH 2/2] avoid passing a parameter Rich Felker
2019-03-26 15:22     ` Frediano Ziglio
2019-04-02  9:57 ` [PATCH 1/2] use __strchrnul instead of strchr and strlen Frediano Ziglio
2019-04-02 14:40   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326093648.5669-2-fziglio@redhat.com \
    --to=fziglio@redhat.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).