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 C455445CD8; Mon, 18 Nov 2024 19:24:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C07C2432E2; Mon, 18 Nov 2024 19:22:29 +0100 (CET) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id B518A42DDC for ; Mon, 18 Nov 2024 19:22:19 +0100 (CET) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso3004792a12.1 for ; Mon, 18 Nov 2024 10:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731954139; x=1732558939; 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=REPLojYG24mGrz9ru9fESpsphl8S8r6uIwwr2ioreVI=; b=B4lxt64xdleWderb8G5wByQhGiODAbLS/THvRkXG9PJ34evdl02/fhNbcoAaxJTQOn p5FKttrgrCvUvubavLsIvcYxmnNi1ndEzPBJ3EhM3gOOI+bzJtnzzyMeff+diBfVMVwq 736/7WfRdVADoQGYvj/0KDz9CVI7biVUAl03f1zXLWfHtVK6vsTdfHDeOuEm2Ge2RVSL kc/yhEQjgJ9h8VKgqVtkqYZVyKu7RyvdeKpGr9KEanF8l58WKO8RI3Rh2QKh3D8hcD6z yWOG8TyniqEe98Jn9XOnknx5Qw2IR92g12qzfJHOp6lYHl7hUvtugy413H2Dyz8g3Coz pdmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731954139; x=1732558939; 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=REPLojYG24mGrz9ru9fESpsphl8S8r6uIwwr2ioreVI=; b=H5dj/1x/jYtNNXNXzcDmJc3kgVBXerA/jxKaAiq/X6SY780Pi/nJmXe95+0l3+GL/0 rkQbn2X9k4vS7e5jk1TC5m15KlofBUaH21HXQLtL7xwBFe5EG/wnuA+QULdecIhLwiFW wG7xcCPxC0+YQQ+T9kXp6cSbemCL/UQ0yURYRqOLDGWA0LonW+QuvE+77FvACHhkKQR2 euDiBx9DSKW2+OO1TU8aKuWTt1pZpFy48bsAKCx9JzTPtecUNQ7SxK+UDtdpCsqDAB+U HvOfcH0KIKWZRpFKO2/Wm85K2FFNZl9w+dMfTwjl9HPXmgl0oxNoRNLVjNa1V3shnSD3 OaxQ== X-Gm-Message-State: AOJu0YwyfVSwZNKN+MMf4LnJ75V/07YzuKU6pNX5aQ2WJYBUYthCjL6Z TCtLv9sNNXNM2HnHRYiao8h56cfPwhAt/mQ1Rk8L++4Lay0UolpWSVyNeuFqbrO4+lwqLPXAawA X X-Google-Smtp-Source: AGHT+IFWx+MVhRO256Kp7jDqk5nELsKfWoCEyOJAg0t5R7BjPPXW99Lmjpd1Vs5q5H1YSfuEEKryhQ== X-Received: by 2002:a17:90b:4f41:b0:2ea:9e36:980e with SMTP id 98e67ed59e1d1-2eaaa7e793emr467473a91.13.1731954137395; Mon, 18 Nov 2024 10:22:17 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea61869bb2sm2916724a91.12.2024.11.18.10.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 10:22:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org Subject: [PATCH v2 18/19] examples/l3fwd: fix operator precedence bugs Date: Mon, 18 Nov 2024 10:20:59 -0800 Message-ID: <20241118182153.87042-19-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182153.87042-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> <20241118182153.87042-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 expression: if ((socketid = rte_lcore_to_socket_id(lcore) != 0) && gets evaluated as sockeid = (rte_lcore_to_socket_id(lcore) != 0) which is not what was intended. This is goes all the way back to first release. Link: https://pvs-studio.com/en/blog/posts/cpp/1183/ Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/l3fwd-power/main.c | 4 ++-- examples/l3fwd/main.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index ae8b55924e..7957ea6c95 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1412,8 +1412,8 @@ check_lcore_params(void) "mask\n", lcore); return -1; } - if ((socketid = rte_lcore_to_socket_id(lcore) != 0) && - (numa_on == 0)) { + socketid = rte_lcore_to_socket_id(lcore); + if (socketid != 0 && numa_on == 0) { printf("warning: lcore %u is on socket %d with numa " "off\n", lcore, socketid); } diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 6e2155e005..14076e07cc 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -307,8 +307,9 @@ check_lcore_params(void) printf("error: lcore %u is not enabled in lcore mask\n", lcore); return -1; } - if ((socketid = rte_lcore_to_socket_id(lcore) != 0) && - (numa_on == 0)) { + + socketid = rte_lcore_to_socket_id(lcore); + if (socketid != 0 && numa_on == 0) { printf("warning: lcore %u is on socket %d with numa off\n", lcore, socketid); } -- 2.45.2