[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJ6X/wrP/El8KLdh@hirez.programming.kicks-ass.net>
Date: Fri, 14 May 2021 17:32:15 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Liam Howlett <liam.howlett@...cle.com>
Cc: "maple-tree@...ts.infradead.org" <maple-tree@...ts.infradead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Song Liu <songliubraving@...com>,
Davidlohr Bueso <dave@...olabs.net>,
"Paul E . McKenney" <paulmck@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
David Rientjes <rientjes@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Rik van Riel <riel@...riel.com>,
Michel Lespinasse <walken.cr@...il.com>
Subject: Re: [PATCH 26/94] Maple Tree: Add new data structure
On Wed, Apr 28, 2021 at 03:36:02PM +0000, Liam Howlett wrote:
> +enum maple_type {
> + maple_dense,
> + maple_leaf_64,
> + maple_range_64,
> + maple_arange_64,
> +};
> +static inline unsigned long *ma_pivots(struct maple_node *node,
> + enum maple_type type)
> +{
> + switch (type) {
> + case maple_arange_64:
> + return node->ma64.pivot;
> + case maple_range_64:
> + case maple_leaf_64:
> + return node->mr64.pivot;
> + case maple_dense:
> + default:
> + return NULL;
> + }
> +}
> +static inline unsigned long *ma_gaps(struct maple_node *node,
> + enum maple_type type)
> +{
> + switch (type) {
> + case maple_arange_64:
> + return node->ma64.gap;
> + case maple_range_64:
> + case maple_leaf_64:
> + case maple_dense:
> + default:
> + return NULL;
> + }
> +}
> +static inline unsigned long mte_pivot(const struct maple_enode *mn,
> + unsigned char piv)
> +{
> + struct maple_node *node = mte_to_node(mn);
> +
> + switch (mte_node_type(mn)) {
> + case maple_arange_64:
> + return node->ma64.pivot[piv];
> + case maple_range_64:
> + case maple_leaf_64:
> + return node->mr64.pivot[piv];
> + case maple_dense:
> + default:
> + return 0;
> + }
> +}
I would suggest removing the default: case. Without it the cases are
complete and the compiler should not complain. Then if you extend the
enum and forget to add a case, the switch is no longer complete and will
trigger a warning, forcing you to update it (hopefully correct).
If you have the default, you'll not get a warning and it'll do whatever.
Powered by blists - more mailing lists