From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
To: richard@nod.at, anton.ivanov@cambridgegreys.com,
johannes@sipsolutions.net, kees@kernel.org,
tiwei.btw@antgroup.com, linux-um@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: paulo.miguel.almeida.rodenas@gmail.com
Subject: [PATCH][next] um: Malloc just enough space for fitting pid file
Date: Sat, 26 Oct 2024 16:46:54 +1300 [thread overview]
Message-ID: <ZxxmLngMg3iNjOfK@mail.google.com> (raw)
umid is already generated during make_umid_init __initcall so there is
no need to allocate UMID_LEN bytes to accommodate the max possible name
for the umid segment of the filepath
This patch replaces UMID_LEN occurences in which it's redundant
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
arch/um/os-Linux/umid.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index eb523ab1e218..513a2cce38db 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -212,7 +212,7 @@ static void __init create_pid_file(void)
char pid[sizeof("nnnnnnnnn")], *file;
int fd, n;
- n = strlen(uml_dir) + UMID_LEN + sizeof("/pid");
+ n = strlen(uml_dir) + strlen(umid) + sizeof("/pid");
file = malloc(n);
if (!file)
return;
@@ -394,7 +394,7 @@ static void remove_umid_dir(void)
{
char *dir, err;
- dir = malloc(strlen(uml_dir) + UMID_LEN + 1);
+ dir = malloc(strlen(uml_dir) + strlen(umid) + 1);
if (!dir)
return;
--
2.47.0
next reply other threads:[~2024-10-26 3:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-26 3:46 Paulo Miguel Almeida [this message]
2024-10-26 7:44 ` [PATCH][next] um: Malloc just enough space for fitting pid file Johannes Berg
2024-10-26 7:59 ` Paulo Miguel Almeida
2024-10-26 8:03 ` Johannes Berg
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=ZxxmLngMg3iNjOfK@mail.google.com \
--to=paulo.miguel.almeida.rodenas@gmail.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=richard@nod.at \
--cc=tiwei.btw@antgroup.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.