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 64F58A0542; Thu, 13 Feb 2020 00:08:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 69C951BEE5; Thu, 13 Feb 2020 00:08:26 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by dpdk.org (Postfix) with ESMTP id 7E4B2DE3 for ; Thu, 13 Feb 2020 00:08:22 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id 2so1967167pfg.12 for ; Wed, 12 Feb 2020 15:08:22 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=TQ1foTVxg+p0Z34hPpUt3AbAs5O+/GOEYxwluwUJ5WI=; b=m7ApAhTdNMkC5iXzXs0BrexJbKE12mmUY7KpZMg3MW5W+wrMvDM82i/QvZxzcXpjBW ZZyxK47O+O731HrHcwDXrL1JVXN7zyJIeTOjYyeOlwH1/KV12/ByODwYhC1AAK6zk4d9 pB5JN/0ioAchBCFSYc0YZWB0NYmiZbFJ0Awum0NLqt7ycb90XwgFAsvD0LjNJXcq8ISP 5ONQOLsiQ0XMHJqwYYTmo0HlU/Q1Jx1Ospz/BLjIlV7Uw3YZOFoB/ChDML/URomwNpKi 1NuEclvoUscpTxuYtAqNEdeEhibgDGEjpb16yfIgt/KOxBh8K1ZgEvgH+v2qBknjYl58 8xqA== 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:mime-version:content-transfer-encoding; bh=TQ1foTVxg+p0Z34hPpUt3AbAs5O+/GOEYxwluwUJ5WI=; b=NF1L4Q7EXlksMc8ci7piSCCP67i9ukwEeZUYFDxBsXdw7R8QfrwBfpT1kDSeX64lrl GnGtuyJdeKbVyavvBSK3oW4wDTmNPJOYJOukYS/7kPjQr3btn4n8gymrm2+yLWZAsWaP euDyYvyv8ARhZefRPLRgXxnM1QCgWwh+Ep4fmjDiDs0Dl+szd4zOLgF5DYpp4oKM430e CyPvhDQyCbl/Nxt1ucEcVcivrL3em4qP4MMYmQbDo7l/cneRMfuQ6JDZLFrS1rbNffKy R47vcUgV5vCcqXiB5xJYKqErk+R+DuDbaVzUAtaIASUUCFbZgsr5QXoPiwzTXPwfATor MzOA== X-Gm-Message-State: APjAAAWe2dTL+U0b54pu6A3ok44UJRnV7FMJR3vHv9TGOt1zBJW/9fm2 GlUcsMAvWSDF9N+6pyr5dF/uWfRu7T4= X-Google-Smtp-Source: APXvYqxaD/TdUM4RZtI9Q0hlLDT+BLOYl7RIgebHP3PMnNqxBWSIytqbTYgFGsY6GLLzy3Tq/GMp7A== X-Received: by 2002:a63:4385:: with SMTP id q127mr13973929pga.404.1581548901028; Wed, 12 Feb 2020 15:08:21 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f18sm198301pgn.2.2020.02.12.15.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 15:08:20 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 12 Feb 2020 15:08:07 -0800 Message-Id: <20200212230810.2837-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212230810.2837-1-stephen@networkplumber.org> References: <20200212230810.2837-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC 1/4] ring: future proof flag settings 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" All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI. Signed-off-by: Stephen Hemminger --- lib/librte_ring/rte_ring.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index 77e5de099b81..6cd8831649ea 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -100,6 +100,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count, RTE_BUILD_BUG_ON((offsetof(struct rte_ring, prod) & RTE_CACHE_LINE_MASK) != 0); + /* future proof flags, only allow supported values */ + if (flags & ~(RING_F_SP_ENQ | RING_F_SC_DEQ)) { + RTE_LOG(ERR, RING, + "Unsupported flags requested %d\n", flags); + return -EINVAL; + } + /* init the ring structure */ memset(r, 0, sizeof(*r)); ret = strlcpy(r->name, name, sizeof(r->name)); -- 2.20.1