[PATCH] um: Remove unnecessary snprintf in umid.c
anton.ivanov at cambridgegreys.com
anton.ivanov at cambridgegreys.com
Wed Oct 21 05:18:53 EDT 2020
From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
1. We already perform the sprintf inside asprintf when allocating the
name for the pid file. There is no need to snprintf it again -
this is surplus code which was a leftover from the pre-asprintf
version.
2. The new code introduced in 0d4e5ac7e78035950d564e65c38ce148cb9af681
was not returning the same error as the old code upon failure.
This makes its behaviour identical with the old code.
Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
arch/um/os-Linux/umid.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index 1d7558dac75f..c2d7a755521c 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -141,16 +141,7 @@ static inline int is_umdir_used(char *dir)
err = asprintf(&file, "%s/pid", dir);
if (err < 0)
- return 0;
-
- filelen = strlen(file);
-
- n = snprintf(file, filelen, "%s/pid", dir);
- if (n >= filelen) {
- printk(UM_KERN_ERR "is_umdir_used - pid filename too long\n");
- err = -E2BIG;
- goto out;
- }
+ return -E2BIG;
dead = 0;
fd = open(file, O_RDONLY);
--
2.20.1
More information about the linux-um
mailing list