diff mbox series

[V2,mmc-utils] One further optimization of trimming routine

Message ID 20181208094301.11199-1-mhei@heimpold.de (mailing list archive)
State New, archived
Headers show
Series [V2,mmc-utils] One further optimization of trimming routine | expand

Commit Message

Michael Heimpold Dec. 8, 2018, 9:43 a.m. UTC
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.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>

---
V2: remove copy&paste left-over from commit message

 lsmmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Wolfram Sang Dec. 9, 2018, 4:35 p.m. UTC | #1
On Sat, Dec 08, 2018 at 10:43:01AM +0100, Michael Heimpold wrote:
> 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.
> 
> Signed-off-by: Michael Heimpold <mhei@heimpold.de>

Yes, sure, thanks!

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Minor nit, concerning newlines, this seems to me a tad more readable:

	...
		start++;
		len--;
	}

	start[len] = '\0';
	return strdup(start);
diff mbox series

Patch

diff --git a/lsmmc.c b/lsmmc.c
index 9737b37..86be802 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -358,10 +358,9 @@  char *read_file(char *name)
 		start++;
 		len--;
 	}
-	memmove(line, start, len);
-	line[len] = '\0';
+	start[len] = '\0';
 
-	return strdup(line);
+	return strdup(start);
 }
 
 /* Hexadecimal string parsing functions */