From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jTkQH-0003Lt-Gc for barebox@lists.infradead.org; Wed, 29 Apr 2020 10:58:44 +0000 Received: from geraet.fritz.box (i5387567C.versanet.de [83.135.86.124]) (Authenticated sender: ahmad@a3f.at) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 02DF31BF205 for ; Wed, 29 Apr 2020 10:58:33 +0000 (UTC) From: Ahmad Fatoum Date: Wed, 29 Apr 2020 12:58:04 +0200 Message-Id: <20200429105803.57863-1-ahmad@a3f.at> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v3] of: refactor of_read_number for clarity To: barebox@lists.infradead.org While the code is correct, less sophisticated static analyzers (and users operating them..) trip over it, because they don't see that the be32_to_cpu argument is evaluated multiple times only if it's constant. Moving the side effect out: - Lets us avoid the false positive - Aligns us with what Linux does - Makes the code IMO a bit clearer Do so. Signed-off-by: Ahmad Fatoum --- v2 -> v3: fix full stop at end of commit subject (Roland) v1 -> v2: fix inaccurate commit message (Sascha) --- include/of.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/of.h b/include/of.h index 85d55f9b57dc..08bbeaf4d21b 100644 --- a/include/of.h +++ b/include/of.h @@ -79,8 +79,8 @@ struct fdt_header *of_get_fixed_tree(struct device_node *node); static inline u64 of_read_number(const __be32 *cell, int size) { u64 r = 0; - while (size--) - r = (r << 32) | be32_to_cpu(*(cell++)); + for (; size--; cell++) + r = (r << 32) | be32_to_cpu(*cell); return r; } -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox