mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org, s.hauer@pengutronix.de
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH v3 6/9] ratp: use xstrndup() instead of a custom xmemdup_add_zero()
Date: Sat, 24 Feb 2018 16:01:18 +0100	[thread overview]
Message-ID: <20180224150121.28309-7-aleksander@aleksander.es> (raw)
In-Reply-To: <20180224150121.28309-1-aleksander@aleksander.es>

The console operations done via RATP expect strings, so just use
xstrndup() instead of defining a custom method.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
 common/ratp/ratp.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index 1e9c65179..fae9cec5b 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -132,17 +132,6 @@ static int console_send(struct ratp *r, void *pkt, int len)
 	return 0;
 }
 
-static void *xmemdup_add_zero(const void *buf, int len)
-{
-	void *ret;
-
-	ret = xzalloc(len + 1);
-	*(uint8_t *)(ret + len) = 0;
-	memcpy(ret, buf, len);
-
-	return ret;
-}
-
 static void ratp_queue_console_tx(struct ratp_ctx *ctx)
 {
 	u8 buf[255];
@@ -220,7 +209,7 @@ static int ratp_bb_dispatch(struct ratp_ctx *ctx, const void *buf, int len)
 		if (!IS_ENABLED(CONFIG_CONSOLE_RATP) || ratp_command)
 			return 0;
 
-		ratp_command = xmemdup_add_zero(&rbb->data, dlen);
+		ratp_command = xstrndup((const char *)rbb->data, dlen);
 		ratp_ctx = ctx;
 		pr_debug("got command: %s\n", ratp_command);
 
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-02-24 15:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 15:01 [PATCH v3 0/9] ratp: new generic RATP command support Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 1/9] ratp: implement generic " Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 2/9] ratp: moved logic to its own subdirectory Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 3/9] ratp: allow building without full console support Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 4/9] ratp: implement ping as a standard ratp command Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 5/9] ratp: implement getenv " Aleksander Morgado
2018-02-24 15:01 ` Aleksander Morgado [this message]
2018-02-24 15:01 ` [PATCH v3 7/9] ratp: new md and mw commands Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 8/9] ratp: new reset command Aleksander Morgado
2018-02-24 15:01 ` [PATCH v3 9/9] docs: add reference to libratp-barebox in the remote-control docs Aleksander Morgado
2018-03-01  8:48 ` [PATCH v3 0/9] ratp: new generic RATP command support Sascha Hauer

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=20180224150121.28309-7-aleksander@aleksander.es \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox