From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73802C11F64 for ; Thu, 1 Jul 2021 06:16:38 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7E7F61461 for ; Thu, 1 Jul 2021 06:16:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7E7F61461 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 52B578323D; Thu, 1 Jul 2021 08:16:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hYHRUEkb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F817831EA; Thu, 1 Jul 2021 08:16:24 +0200 (CEST) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 42026831EA for ; Thu, 1 Jul 2021 08:16:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x72b.google.com with SMTP id j184so5002575qkd.6 for ; Wed, 30 Jun 2021 23:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y69m50NIties87+pJv5ckXaLI1xTsNsDmfkBDE+KLww=; b=hYHRUEkb4ZVTf+paKLMApJy5Qu2iJpMoVOrgGseWfFYQHdBUcTKLX6HRiKYVPQNG+V MTI6PwqJemkrb5hQWtYGQ1ArEJ22b+IfniSHbsAnbktPZqpahV1tIDycvdKELEj8i5FA LWlhIITXv+xDeW0rvPRzi4nwWIXn55tSaJ5P1FGxwDFSs2nVIb4pSPhA2gpLJw9GFIY+ 1Rc6CfowqVHfPmLURSGuv0YI0nfh7xPbchL/8gfpbAAHXu+SF1PtCqU0GURQ5FEfYOw+ 92rcgMOEDIwZayllGxUB/ZlfpAt6Fj+xaUakl8U3CrOwAhKhZtjgtcl+ZVQigaqEV+p+ Ko5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y69m50NIties87+pJv5ckXaLI1xTsNsDmfkBDE+KLww=; b=ez5825IK7iD/ygejwGgzuIGKgTf/jiA0py6ZM/Fo+oFAxzvqLoHdAQ2T9O9cCVZkW4 /eRzLjDTUyrvQ3di4T+HGuzBrz3BG1gKisdF4W2LdLlJJ9UJoxvD4E+kS7dJZ2pgor0/ GDkS4OcnBn7Cfvl6dOEWxHI57KFBF2A0PA0OgOcwgbT+OGHk0/1YZw0OC6hNapBUM3kD F8I7b5Q+ZmTRylstLtf9sl+bf6tuRfZIkR2B5x4vYj5+vP70EJFTrUh8tsTOAMtjGZIB n4uHTMXral9JkhWxCI2VGrJWzhifpKp853Q3DYLwSpW0AMiRyJWZrUsXMF1UmV/06O0H EEew== X-Gm-Message-State: AOAM533oPYLJdLznlzxS/2AUypm53lFP89je7rIhc6VAhO4j7V0bLsNe vp4OOmVHDiu1AHOep2ZYSxMwWO06p2E= X-Google-Smtp-Source: ABdhPJyjitTtXr+Bi9uQEfYIoG3QDngPIkaceY1CdCrEq8d9dWcgnFuNCwN/31iLnTNypL0fTgBTig== X-Received: by 2002:a05:620a:12da:: with SMTP id e26mr7275825qkl.333.1625120176951; Wed, 30 Jun 2021 23:16:16 -0700 (PDT) Received: from godwin.fios-router.home (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.gmail.com with ESMTPSA id g21sm1684673qts.90.2021.06.30.23.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:16:16 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Tom Rini Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Wolfgang Denk , Simon Glass , Roland Gaudig , Heinrich Schuchardt , Kostas Michalopoulos , Sean Anderson Subject: [RFC PATCH 03/28] cli: lil: Replace strclone with strdup Date: Thu, 1 Jul 2021 02:15:46 -0400 Message-Id: <20210701061611.957918-4-seanga2@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210701061611.957918-1-seanga2@gmail.com> References: <20210701061611.957918-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Apparently strdup is not portable, so LIL used its own. Use strdup. Signed-off-by: Sean Anderson --- common/cli_lil.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/common/cli_lil.c b/common/cli_lil.c index c8c6986fe1..294d79e86e 100644 --- a/common/cli_lil.c +++ b/common/cli_lil.c @@ -123,17 +123,6 @@ static struct lil_env **envpool; static size_t envpoolsize, envpoolcap; #endif -static char *strclone(const char *s) -{ - size_t len = strlen(s) + 1; - char *ns = malloc(len); - - if (!ns) - return NULL; - memcpy(ns, s, len); - return ns; -} - static unsigned long hm_hash(const char *key) { unsigned long hash = 5381; @@ -173,7 +162,7 @@ static void hm_put(struct hashmap *hm, const char *key, void *value) } cell->e = realloc(cell->e, sizeof(struct hashentry) * (cell->c + 1)); - cell->e[cell->c].k = strclone(key); + cell->e[cell->c].k = strdup(key); cell->e[cell->c].v = value; cell->c++; } @@ -606,7 +595,7 @@ static struct lil_func *add_func(struct lil *lil, const char *name) } cmd = calloc(1, sizeof(struct lil_func)); - cmd->name = strclone(name); + cmd->name = strdup(name); ncmd = realloc(lil->cmd, sizeof(struct lil_func *) * (lil->cmds + 1)); if (!ncmd) { @@ -705,7 +694,7 @@ struct lil_var *lil_set_var(struct lil *lil, const char *name, env->var = nvar; nvar[env->vars] = calloc(1, sizeof(struct lil_var)); - nvar[env->vars]->n = strclone(name); + nvar[env->vars]->n = strdup(name); nvar[env->vars]->env = env; nvar[env->vars]->v = freeval ? val : lil_clone_value(val); hm_put(&env->varmap, name, nvar[env->vars]); @@ -1207,7 +1196,7 @@ void lil_set_error(struct lil *lil, const char *msg) free(lil->err_msg); lil->error = ERROR_FIXHEAD; lil->err_head = 0; - lil->err_msg = strclone(msg ? msg : ""); + lil->err_msg = strdup(msg ? msg : ""); } void lil_set_error_at(struct lil *lil, size_t pos, const char *msg) @@ -1218,7 +1207,7 @@ void lil_set_error_at(struct lil *lil, size_t pos, const char *msg) free(lil->err_msg); lil->error = ERROR_DEFAULT; lil->err_head = pos; - lil->err_msg = strclone(msg ? msg : ""); + lil->err_msg = strdup(msg ? msg : ""); } int lil_error(struct lil *lil, const char **msg, size_t *pos) @@ -2016,7 +2005,7 @@ static struct lil_value *fnc_rename(struct lil *lil, size_t argc, hm_put(&lil->cmdmap, oldname, 0); hm_put(&lil->cmdmap, newname, func); free(func->name); - func->name = strclone(newname); + func->name = strdup(newname); } else { del_func(lil, func); } @@ -2728,7 +2717,7 @@ static struct lil_value *real_trim(const char *str, const char *chars, int left, size_t len; char *s; - s = strclone(str + base); + s = strdup(str + base); len = strlen(s); while (len && strchr(chars, s[len - 1])) len--; @@ -2833,7 +2822,7 @@ static struct lil_value *fnc_repstr(struct lil *lil, size_t argc, if (!from[0]) return NULL; - src = strclone(lil_to_string(argv[0])); + src = strdup(lil_to_string(argv[0])); srclen = strlen(src); fromlen = strlen(from); tolen = strlen(to); -- 2.32.0