diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-02-24 16:01:17 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-01 09:39:42 +0100 |
commit | 884eeea4082b36e8cca56f2886947d934bf40238 (patch) | |
tree | 88bce3b0d85bc907a8548f14a29693994587d971 /common/ratp/ratp.c | |
parent | ec42940ea194f3089c5b2d29a06d61d7d03e94d9 (diff) | |
download | barebox-884eeea4082b36e8cca56f2886947d934bf40238.tar.gz barebox-884eeea4082b36e8cca56f2886947d934bf40238.tar.xz |
ratp: implement getenv as a standard ratp command
Also, use xstrndup() instead of the custom xmemdup_add_zero() as we're
working with strings anyway.
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/ratp/ratp.c')
-rw-r--r-- | common/ratp/ratp.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c index 965c67a0a1..1e9c65179f 100644 --- a/common/ratp/ratp.c +++ b/common/ratp/ratp.c @@ -189,29 +189,6 @@ static int ratp_bb_send_command_return(struct ratp_ctx *ctx, uint32_t errno) return ret; } -static int ratp_bb_send_getenv_return(struct ratp_ctx *ctx, const char *val) -{ - void *buf; - struct ratp_bb *rbb; - int len, ret; - - if (!val) - val = ""; - - len = sizeof(*rbb) + strlen(val); - buf = xzalloc(len); - rbb = buf; - strcpy(rbb->data, val); - - rbb->type = cpu_to_be16(BB_RATP_TYPE_GETENV_RETURN); - - ret = ratp_send(&ctx->ratp, buf, len); - - free(buf); - - return ret; -} - static char *ratp_command; static struct ratp_ctx *ratp_ctx; @@ -220,7 +197,6 @@ static int ratp_bb_dispatch(struct ratp_ctx *ctx, const void *buf, int len) const struct ratp_bb *rbb = buf; struct ratp_bb_pkt *pkt; int dlen = len - sizeof(struct ratp_bb); - char *varname; int ret = 0; uint16_t type = be16_to_cpu(rbb->type); struct ratp_command *cmd; @@ -260,12 +236,6 @@ static int ratp_bb_dispatch(struct ratp_ctx *ctx, const void *buf, int len) kfifo_put(ctx->console_recv_fifo, rbb->data, dlen); break; - case BB_RATP_TYPE_GETENV: - varname = xmemdup_add_zero(&rbb->data, dlen); - - ret = ratp_bb_send_getenv_return(ctx, getenv(varname)); - break; - case BB_RATP_TYPE_FS_RETURN: pkt = xzalloc(sizeof(*pkt) + dlen); pkt->len = dlen; |