Skip to contentSkip to conversation

mmc-utils: One further optimization of trimming routine

PATCH Applied Michael Heimpold 3 participants 3 messages Sep 20, 2021 – Sep 30, 2021 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mmc-utils: One further optimization of trimming routine

The last change to the trimming routine made it more efficient, however, we can even get rid of the memmove() as we leave the function with strdup() anyway.

---

While doing some house-keeping, I found this somewhat older patch still hanging around (v2 was sent on 2018-12-08). I'm just resending to check what's the current opinion about it :-)

 lsmmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lsmmc.c +2 -3
index 06cc0b8..05d59e8 100644
@@ -393,10 +393,9 @@ char *read_file(char *name)
 		start++;
 		len--;
 	}
-	memmove(line, start, len);
-	line[len] = '\0';
 
-	return strdup(line);
+	start[len] = '\0';
+	return strdup(start);
 }
 
 /* Hexadecimal string parsing functions */
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#1 lore raw
Quoted 7 lines

The last change to the trimming routine made it more efficient, however, we can even get rid of the memmove() as we leave the function with strdup() anyway.

Quoted 29 lines

---

While doing some house-keeping, I found this somewhat older patch still hanging around (v2 was sent on 2018-12-08). I'm just resending to check what's the current opinion about it :-)

 lsmmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lsmmc.c +2 -4
index 06cc0b8..05d59e8 100644
@@ -393,10 +393,9 @@ char *read_file(char *name)
                start++;
                len--;
        }
-       memmove(line, start, len);
-       line[len] = '\0';
 
-       return strdup(line);
+       start[len] = '\0';
+       return strdup(start);
 }
 
 /* Hexadecimal string parsing functions */
--

2.17.1

Applied
#2 lore raw
In reply to Michael Heimpold
Quoted 7 lines · Michael Heimpold

The last change to the trimming routine made it more efficient, however, we can even get rid of the memmove() as we leave the function with strdup() anyway.

Applied to the master branch at
https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git, thanks!

Kind regards
Uffe

Quoted 30 lines

---

While doing some house-keeping, I found this somewhat older patch still hanging around (v2 was sent on 2018-12-08). I'm just resending to check what's the current opinion about it :-)

 lsmmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lsmmc.c +2 -4
index 06cc0b8..05d59e8 100644
@@ -393,10 +393,9 @@ char *read_file(char *name)
                start++;
                len--;
        }
-       memmove(line, start, len);
-       line[len] = '\0';
 
-       return strdup(line);
+       start[len] = '\0';
+       return strdup(start);
 }
 
 /* Hexadecimal string parsing functions */
--

2.17.1