From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5775AA0527; Mon, 9 Nov 2020 12:58:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 243A25B30; Mon, 9 Nov 2020 12:58:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id 82E265AA6 for ; Mon, 9 Nov 2020 12:58:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604923107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PQgzp4Fwy31hcqort0JHqFqYZWfUlQAEyPDC+jDC2WU=; b=VRbU+z2O78s4iVQ1tNihX6k3E0pOnfZEgI4MolAPBF18JXG4yf4NCD50IeAMiAOnxK9xHJ hSvuGFXs00iT+vxG097NOFVrg2PjjT8s40tCYslbbrI6lEYDF5Db18TjV+TO489znM7LJh ziKT3Uf8em5VkOf6+U3Z/iF38FLtXCA= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-H7ogQZdWNbWz_4smAELTeA-1; Mon, 09 Nov 2020 06:58:25 -0500 X-MC-Unique: H7ogQZdWNbWz_4smAELTeA-1 Received: by mail-vk1-f198.google.com with SMTP id x23so1124971vkx.1 for ; Mon, 09 Nov 2020 03:58:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PQgzp4Fwy31hcqort0JHqFqYZWfUlQAEyPDC+jDC2WU=; b=IBTshIQrThXJinc4yHKGOpLv1BP2Xkl6lD2WAjx4qUZxrdcoLviLbqNhvDQnqXmZQe iek3al847vuoCigziI3bG23vRbfJPVwkZsuflceIskK4u4MjSJom4PVJX9vc6pTAnFNA /g3+dHBWVJu6Fa1YxrTcFb/Tqo/tsi5laYbZVo2Ic+s6J0oOw+aOOZEZV+ASi6KLv3qj UfgDUrPSOq2VXIs9sEEc70hChKXPOGJPSVlSdi8pNU+VquFs3/yBv6YC0AbXksePM7H0 em+Ggg/BAreEqoR61Vmap7tJzXqcdsl89dTW5kK/Xd2caGHZji5FYSQ4SP+3dahqW4Yn GUpg== X-Gm-Message-State: AOAM532Vtks3Kj5IBl5VW3qRP9tOSn3DZpBW3zISfJ4i+8NEofNHDDmG GcEmgZaqvZOrjmLtflMcDJ4biBuY8TxzNI8M1CA1F2DOFQ6kAo0G+KB8f+AN9q/sLVfLgVXFnbl YGPEz3VGL6G7CCr4eQNk= X-Received: by 2002:a05:6102:2362:: with SMTP id o2mr2062722vsa.5.1604923104580; Mon, 09 Nov 2020 03:58:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkOsdI+bCP300T2RJlpr5pu17cjxOJKaYpLmegivEtfFS6gq8oNnAn0gtlVVg1xekGzrB3urs4DqopjFBx/pU= X-Received: by 2002:a05:6102:2362:: with SMTP id o2mr2062709vsa.5.1604923104392; Mon, 09 Nov 2020 03:58:24 -0800 (PST) MIME-Version: 1.0 References: <20201109113147.962882-1-grive@u256.net> In-Reply-To: <20201109113147.962882-1-grive@u256.net> From: David Marchand Date: Mon, 9 Nov 2020 12:58:13 +0100 Message-ID: To: Gaetan Rivet Cc: dev , Hemant Agrawal , Sachin Saxena Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] bus/dpaa: optimize device name parsing 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Nov 9, 2020 at 12:32 PM Gaetan Rivet wrote: > + delta = 0; > + if (strncmp(name, "dpaa_bus:", 9) == 0) { > + delta = 9; > + } else if (strncmp(name, "name=", 5) == 0) { > + delta = 5; > + } > + > + if (sscanf(&name[delta], "fm%u-mac%u", &i, &j) == 2) { > + if (i >= 2 || j >= 16) > + return -EINVAL; > + if (out != NULL) { > + char *out_name = out; > + > + if (rte_strscpy(out_name, &name[delta], 10) < 0) > + return -ENAMETOOLONG; > + /* Because 'i' can only be 0 or 1, fm%u is fixed size ; > + * mac%u needs to be checked for optional end ','. > + */ > + if (out_name[9] == ',') > + out_name[9] = '\0'; > } > + return 0; > + } else { > + return -EINVAL; > } Mmm, we always return from each of the previous branches? Then the ENODEV return after is dead code. Reading again the diff, you could probably return at the sscanf step. if (sscanf(&name[delta], "fm%u-mac%u", &i, &j) != 2 || i >= 2 || j >= 16) return -EINVAL; > > - free(dup_name); > - return -EINVAL; > + return -ENODEV; > } > > #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa" -- David Marchand