From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 302A14C99 for ; Tue, 12 Mar 2019 18:12:01 +0100 (CET) Received: by mail-pf1-f194.google.com with SMTP id a3so2265688pff.11 for ; Tue, 12 Mar 2019 10:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4WbF4IlsAiN2XTrgtStKuRV3mtpQWNnd0gVRKkatbYM=; b=RlffI/H06/6NpIOa6LiT478PTwLSqURQIwl8JyPKYCjTK28G3O/1NQRMjRg7WdJAOc fcKIlihQFI8ju2A9z6c7jAAbn6T0Ukz8r7YTUq4MhLkZio8kzW48KMmzngLzC1tkpkxL qp11GYmEuKm4jotrZbIFmMXOkPex0usL0/XawcDYZAHTWOSA4eTFyACldaRA0XdTgb96 ohoAveJN4dCNirS8oYOT/MLLH1777855IRy/Zr3miz4wphsO2Loz/vYHtMXW0Ap+cD5D E221DFSyXVhIiihZW5Df8GBwuzsN/1JV2BzYEaz0AhBNIH6fRWt+pu6M2EmQUPUJrkxe IzhQ== 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; bh=4WbF4IlsAiN2XTrgtStKuRV3mtpQWNnd0gVRKkatbYM=; b=reYw7+fW96uiETYB4rZnDL5pP3ryNVSOgzZh62DxX9XEAS1yTTE2AqQLBdNeScO8xk vv8grI65aQMkqYH4OM6eKVvKwoKTEXLwLDClrs9J9AENMzcfoVHpaPsJ9pLJecq9d48b u9wyC3F6LO7o7Ofppf9AOJjfouKB4W6FzpnXNJsYPb5J3tBWMJVsNyFiL2JQ4Ki7iRRQ cucv534/Xs0bDbhczo6NTQMLSK4O/RDVEesZmmXGCggIAXF8mTg1ryTxDlTnP9Jrpj11 JOaZtVVq45BmRPt135shZZwKMaub8y7qeEs0Ife/6qGa2gae7HvfkmVVazmn7+y3AWmT sWxg== X-Gm-Message-State: APjAAAWiWFUQf8C3ooPbfnr5ga6NKrgAxBDDf1GTBUH38iNruQ3PIfbA wbsF4APS07MU++FV1iSWyhq+BuAk4H0iXA== X-Google-Smtp-Source: APXvYqxuIWvofjImwJJ2S3szuPpzHg/BJiPXuFykwrLz0th6kwABjYWa2f0w9zNOABVLhktghwUFCg== X-Received: by 2002:a17:902:9f94:: with SMTP id g20mr41456187plq.0.1552410720339; Tue, 12 Mar 2019 10:12:00 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a66sm25246593pfj.153.2019.03.12.10.11.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 10:11:58 -0700 (PDT) From: Stephen Hemminger To: hemant.agrawal@nxp.com, shreyansh.jain@nxp.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 12 Mar 2019 10:11:52 -0700 Message-Id: <20190312171152.28637-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190312171152.28637-1-stephen@networkplumber.org> References: <20190312171152.28637-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 2/2] bus/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: Tue, 12 Mar 2019 17:12:01 -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 --- 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.17.1