From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E853945AAF; Fri, 4 Oct 2024 18:25:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 62AED42EAF; Fri, 4 Oct 2024 18:24:44 +0200 (CEST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 5700342DE9 for ; Fri, 4 Oct 2024 18:24:35 +0200 (CEST) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2e0b0142bbfso2461067a91.1 for ; Fri, 04 Oct 2024 09:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728059074; x=1728663874; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Li7ShgBvH7vhbzugiCUod2gdTHB0nmqveHPeYDooxh8=; b=AA6BwGVnk3B4m43FEf88IiH/EU3Gmtj4jQCkeVpZBiP+rwtub52xlEnGqdvLGvCxKz ku0VLxNx5Rh2jG/GWC1yUFlhbOXbBPZvGxtOKu9E2oDnv6HLF7sBJVj0BmZYpqjUMIPD vSVzL9585DhnvpVoPCMNmWZSpHoNzSvAAsSf7regIEmRjYAtoSMMNknNh5iWY3zCRanY Uj0UN1HhRzVZQuSp+f1SagkIyHwp29zcatFDWS6qMGx+/Z7J1AlJfyd28rl8xrJLdyh1 NwlyIASm+udHDHWS3pt8Kr0Nc8ARx4GwnCTF2Wv/jYXWf2SFvvFSBHp5ni1LkDWQu4xl E5Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059074; x=1728663874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Li7ShgBvH7vhbzugiCUod2gdTHB0nmqveHPeYDooxh8=; b=NGS7BGC6+tt38SUHaLv0bHkLlJpL8oRmiO3x0dTrJy+XgrxWwZWz66Puj5mpft8WrS Ea6MkTgDboqcnlOI43z2LZsQxzhTqjiLQlB59Ro+El4dNMTUj7x0vettdGmZR+wT7i5t JwanOcjaklzimt24d5F265shPT3A7rZn+Z/LVV4zvxucc9UDLSKM8ujQv+bpONeYzumg beNyAfxo6YoTPCx1/Vi9AWjrO1ZMyVym8UQq4ZeC6S9PINEVpIJtvJmS9i3dQEY3i2vv t389xXktLOGtDLpw8ujsQgE2hpNkuJMm92+S1og0cAyYumfCx8XwM00ID2oDxZqdZ4tU 9lGQ== X-Gm-Message-State: AOJu0YyXv5yvFa7NhLgSwULgd7Mvb3JTXbQatW9QCTavzQOfHWtDxy1Z oDhvIhZxWTviLwZ2ZRBiaygybeDjur2zSmhHzvKMr7jFrfndXjR6gjQUI3timvxrR7U0p4RPSZn tznyV7w== X-Google-Smtp-Source: AGHT+IH3bizTMb2UCMmhFCNb+WP/ohkJ0bF3K2/4UsJeyIbIsjbwZ85a/4FvF4XgtkokoTvlm3vESQ== X-Received: by 2002:a17:90a:c70a:b0:2d8:a744:a81c with SMTP id 98e67ed59e1d1-2e1b3752147mr11225963a91.1.1728059074499; Fri, 04 Oct 2024 09:24:34 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e9f680d7a1sm139231a12.19.2024.10.04.09.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:24:34 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH 07/10] examples/pipeline: check return value of ethdev functions Date: Fri, 4 Oct 2024 09:21:54 -0700 Message-ID: <20241004162418.52940-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241004162418.52940-1-stephen@networkplumber.org> References: <20241004162418.52940-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The rte_eth_dev_info_get and rte_eth_link_get functions may return an error, and in that case the information structure is undefined. The port is valid check is not needed, that can be handled by rte_eth_dev_info_get checks. Signed-off-by: Stephen Hemminger --- examples/pipeline/cli.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 015717cb39..215b4061d5 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -390,14 +390,15 @@ ethdev_show(uint16_t port_id, char **out, size_t *out_size) uint32_t length; uint16_t mtu = 0; - if (!rte_eth_dev_is_valid_port(port_id)) + if (rte_eth_dev_info_get(port_id, &info) != 0) + return; + + if (rte_eth_link_get(port_id, &link) != 0) return; rte_eth_dev_get_name_by_port(port_id, name); - rte_eth_dev_info_get(port_id, &info); rte_eth_stats_get(port_id, &stats); rte_eth_macaddr_get(port_id, &addr); - rte_eth_link_get(port_id, &link); rte_eth_dev_get_mtu(port_id, &mtu); snprintf(*out, *out_size, -- 2.45.2