All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 14/14] main: Avoid unncessary strdup()/free()
Date: Thu, 10 Apr 2014 20:01:36 -0600	[thread overview]
Message-ID: <1397181696-7271-15-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1397181696-7271-1-git-send-email-sjg@chromium.org>

It doesn't seem necessary to use memory allocation in this code. The setenv()
will make a copy anyway.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/common/main.c b/common/main.c
index b0d3ea4..ab1f708 100644
--- a/common/main.c
+++ b/common/main.c
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <autoboot.h>
 #include <cli.h>
-#include <malloc.h>
 #include <version.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -26,10 +25,9 @@ static void modem_init(void)
 #ifdef CONFIG_MODEM_SUPPORT
 	debug("DEBUG: main_loop:   gd->do_mdm_init=%lu\n", gd->do_mdm_init);
 	if (gd->do_mdm_init) {
-		char *str = strdup(getenv("mdm_cmd"));
+		char *str = getenv("mdm_cmd");
+
 		setenv("preboot", str);  /* set or delete definition */
-		if (str != NULL)
-			free(str);
 		mdm_init(); /* wait for modem connection */
 	}
 #endif  /* CONFIG_MODEM_SUPPORT */
-- 
1.9.1.423.g4596e3a

  parent reply	other threads:[~2014-04-11  2:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11  2:01 [U-Boot] [PATCH 0/14] Split out code from the enormous main.c Simon Glass
2014-04-11  2:01 ` [U-Boot] [PATCH 01/14] Remove unnecessary use of hush header file Simon Glass
2014-05-30 15:27   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 02/14] Rename hush to cli_hush Simon Glass
2014-05-30 15:27   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 03/14] move CLI prototypes to cli.h and add comments Simon Glass
2014-05-30 15:27   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 04/14] Split out simple parser and readline into separate files Simon Glass
2014-05-30 15:27   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 05/14] Add cli_ prefix to readline functions Simon Glass
2014-05-30 15:27   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 06/14] Move autoboot code to autoboot.c Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 07/14] Move command line API into cli.c Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 08/14] Move bootretry code into bootretry.c and clean up Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 09/14] Rename bootretry functions and remove #ifdefs Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 10/14] m68k: powerpc: Clean up do_mdm_init Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 11/14] Simplify the main loop Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 12/14] main: Hide the hush/simple details inside cli.c Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` [U-Boot] [PATCH 13/14] main: Make the execution path a little clearer in main.c Simon Glass
2014-05-30 15:28   ` Tom Rini
2014-04-11  2:01 ` Simon Glass [this message]
2014-05-30 15:29   ` [U-Boot] [PATCH 14/14] main: Avoid unncessary strdup()/free() Tom Rini
2014-04-21 17:26 ` [U-Boot] [PATCH 0/14] Split out code from the enormous main.c Simon Glass

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=1397181696-7271-15-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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.