From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ejmAi-0002MP-7n for barebox@lists.infradead.org; Thu, 08 Feb 2018 13:23:31 +0000 Received: by mail-wm0-x243.google.com with SMTP id g1so9437411wmg.2 for ; Thu, 08 Feb 2018 05:23:17 -0800 (PST) From: Aleksander Morgado Date: Thu, 8 Feb 2018 14:22:59 +0100 Message-Id: <20180208132301.24921-7-aleksander@aleksander.es> In-Reply-To: <20180208132301.24921-1-aleksander@aleksander.es> References: <20180208132301.24921-1-aleksander@aleksander.es> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [RFC PATCH v2 6/8] ratp: use xstrndup() instead of a custom xmemdup_add_zero() To: barebox@lists.infradead.org Cc: Aleksander Morgado The console operations done via RATP expect strings, so just use xstrndup() instead of defining a custom method. Signed-off-by: Aleksander Morgado --- 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