All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mmc-utils: One further optimization of trimming routine
@ 2021-09-20 19:46 Michael Heimpold
  2021-09-24 19:23 ` Avri Altman
  2021-09-30  9:49 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Heimpold @ 2021-09-20 19:46 UTC (permalink / raw)
  To: linux-mmc; +Cc: 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.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

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(-)

diff --git a/lsmmc.c b/lsmmc.c
index 06cc0b8..05d59e8 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v3] mmc-utils: One further optimization of trimming routine
  2021-09-20 19:46 [PATCH v3] mmc-utils: One further optimization of trimming routine Michael Heimpold
@ 2021-09-24 19:23 ` Avri Altman
  2021-09-30  9:49 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Avri Altman @ 2021-09-24 19:23 UTC (permalink / raw)
  To: Michael Heimpold, linux-mmc

 
> 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>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Avri Altman <avri.altman@wdc.com>

> ---
> 
> 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(-)
> 
> diff --git a/lsmmc.c b/lsmmc.c
> index 06cc0b8..05d59e8 100644
> --- a/lsmmc.c
> +++ b/lsmmc.c
> @@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] mmc-utils: One further optimization of trimming routine
  2021-09-20 19:46 [PATCH v3] mmc-utils: One further optimization of trimming routine Michael Heimpold
  2021-09-24 19:23 ` Avri Altman
@ 2021-09-30  9:49 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2021-09-30  9:49 UTC (permalink / raw)
  To: Michael Heimpold; +Cc: linux-mmc

On Mon, 20 Sept 2021 at 22:01, Michael Heimpold <mhei@heimpold.de> 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>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

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

Kind regards
Uffe


> ---
>
> 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(-)
>
> diff --git a/lsmmc.c b/lsmmc.c
> index 06cc0b8..05d59e8 100644
> --- a/lsmmc.c
> +++ b/lsmmc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-30  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 19:46 [PATCH v3] mmc-utils: One further optimization of trimming routine Michael Heimpold
2021-09-24 19:23 ` Avri Altman
2021-09-30  9:49 ` Ulf Hansson

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.