From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id CB5FD1B450 for ; Wed, 6 Feb 2019 23:10:24 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id g189so3548267pgc.5 for ; Wed, 06 Feb 2019 14:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sdYjYddmLrJQjqE6Xr/qMTu4XKmN9zNltihbvbMPtsg=; b=vyEFMjySNKS48Kw8bKCyu9Cxq+RpScoCEfx4bl2w63o0HOe1wN8BtdM/Q/G0FIKu0O p5apHNhlK9wGD9J2rhoK7s3jVMYlG6ycV2Uhhr51kH3d6SFpG09X6xZNK80Z0IEMP9vn 8D4rYmbD9pj1EoHg++NiKIjbw2QGYDOqmVjkq26cowlm++vjxVdVB7rySjU9smcx4/A8 y7Jcn0CcHxxwQ//zELo30q6Ng11ZJJgSz7Q0cBzkp1WrrjUX9xIsk0+ZBRkTQa4VFBaz 2fVJzZ4PBhZAZ6H4x0eEsRdAYTMQ6FnaRWnCUJ1wVjqnCKuCGewRb9qAOqnnSJHXyD8X 4hgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sdYjYddmLrJQjqE6Xr/qMTu4XKmN9zNltihbvbMPtsg=; b=hBFgdHUvQWoyhBCYm5AOZLAlQw9r+ZuonOdsqd6Um2N4gGbmx2chaKJA2oQcs5GKWW IvAud3YJuMzZatAAttu/dBE9YIbCpwxDfxpV8K0Z5XYMHpOHb+y1FIpfbmBT+GsyQ4td FAjhFcr3eM+WU2MmP1Dlbim6bdM9g4yK6oXo/ROcyTfzI/SQWGYAxL4Ckh5z6Wgs++x8 WW4uG7aM4J6d4coaCN6kfdheHzbAJReJOfUXRYpVAD09SBG8GbGj2bG45smewzMuSf8A XvZm/ZwUeD0t58JXf2aijyTg5FOzlg8yQs8XHSaR8RCUPs2QejcrxkiuSdrZhHIt8u9D sNZw== X-Gm-Message-State: AHQUAubw4CTLa2AhuJZ2JBP2FI7j1MOUd7rYV6e6jbJ3g9k4d0dQb5sc PwqsXj0jyhAHb+q3Y1Nv7FmZL3RkgzY= X-Google-Smtp-Source: AHgI3IZ2L39UIhDvoN4+ZO+bU/q/GQ5cc0uqjAggaqrQXXOtl8HyJEGzQw6Ym2Ih1y9HztISZwpEgw== X-Received: by 2002:a62:2fc3:: with SMTP id v186mr12844958pfv.82.1549491023762; Wed, 06 Feb 2019 14:10:23 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a90sm10975959pfj.109.2019.02.06.14.10.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 14:10:23 -0800 (PST) Date: Wed, 6 Feb 2019 14:10:15 -0800 From: Stephen Hemminger To: dev@dpdk.org Message-ID: <20190206141015.4adedb33@hermes.lan> In-Reply-To: <20190206220414.9450-1-stephen@networkplumber.org> References: <20190206220414.9450-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH] fslmc: remove unneeded strdup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2019 22:10:25 -0000 The fslmc bus code was duplicating the device name and doing extra initialization. The code can be simplified to just use the device name directly. Compile tested only; do not have this hardware. Signed-off-by: Stephen Hemminger --- This patch assumes the previous log fix. Since it is only a cleanup does not need to go to stable. drivers/bus/fslmc/fslmc_bus.c | 38 +++++++++++------------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index a2525780cd08..eaa39a2093e0 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -229,49 +229,35 @@ static int rte_fslmc_parse(const char *name, void *addr) { uint16_t dev_id; - char *t_ptr = NULL, *dname = NULL; + char *t_ptr; /* 'name' is expected to contain name of device, for example, dpio.1, * dpni.2, etc. */ - - dname = strdup(name); - if (!dname) - return -EINVAL; - t_ptr = dname; - - if (strncmp("dpni", t_ptr, 4) && - strncmp("dpseci", t_ptr, 6) && - strncmp("dpcon", t_ptr, 5) && - strncmp("dpbp", t_ptr, 4) && - strncmp("dpio", t_ptr, 4) && - strncmp("dpci", t_ptr, 4) && - strncmp("dpmcp", t_ptr, 5) && - strncmp("dpdmai", t_ptr, 6) && - strncmp("dpdmux", t_ptr, 6)) { + if (strncmp("dpni", name, 4) && + strncmp("dpseci", name, 6) && + strncmp("dpcon", name, 5) && + strncmp("dpbp", name, 4) && + strncmp("dpio", name, 4) && + strncmp("dpci", name, 4) && + strncmp("dpmcp", name, 5) && + strncmp("dpdmai", name, 6) && + strncmp("dpdmux", name, 6)) { DPAA2_BUS_DEBUG("Unknown or unsupported device (%s)", name); goto err_out; } t_ptr = strchr(name, '.'); - if (!t_ptr) { - DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr); - goto err_out; - } - - t_ptr = (char *)(t_ptr + 1); - if (sscanf(t_ptr, "%hu", &dev_id) <= 0) { - DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr); + if (!t_ptr || sscanf(t_ptr + 1, "%hu", &dev_id) != 1) { + DPAA2_BUS_ERR("Missing device id in device name (%s)", name); goto err_out; } - free(dname); if (addr) strcpy(addr, name); return 0; err_out: - free(dname); return -EINVAL; } -- 2.20.1