From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935288AbdCWPGv (ORCPT ); Thu, 23 Mar 2017 11:06:51 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:60397 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934302AbdCWPGs (ORCPT ); Thu, 23 Mar 2017 11:06:48 -0400 From: Arnd Bergmann Cc: Andrew Morton , Jan Kara , Arnd Bergmann , reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] reiserfs: avoid a -Wmaybe-uninitialized warning Date: Thu, 23 Mar 2017 16:06:13 +0100 Message-Id: <20170323150627.347589-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:7o8RLYd1NHdaclvP5pk3uMX+VTDmjOJlyehw1n/I4d0PwVREmBC CtJ92prwytpGzbdw8+cZTUib7JZvEXEoA4aI6swbyJAycw9iZnDXERomTksCPx8kku0V0fe Lh+1y5Zpgz+B1WbwcrhnjJ8OkYGS5n6wsASwj8tOSykakSi4U+lHyqDPpkqhwA54A5y69zm xFronhUpgxtxgulZXCD6A== X-UI-Out-Filterresults: notjunk:1;V01:K0:ty2FioLlYNQ=:yYdMuElBWZ277KfIQ9uFVs xCk1eVvs9PHU1bHdHmjtJFjzQQNft6kp+EbC02Oh8pXCKb9qdNsKeC1JfWesvZdzFAmXIH3hI ssy6+dP1bfZAXCjhsP56++upwWt6y0PCCIJjLzNHjhGjd9MrJoVIJcf8PHYNljaIKOeKTiM+U qLuC3ntBuw6JQnSb7L42EcFDlaRilk6tAjhy4IGMUpdpBtgLf/IwPi457dIx5XmIPbcjPrVZi TqYEdg/U0Cr707xBx0xGdsB3QgxMaOM92WH3uCAm7GhtE/2JKGhOlOYn6Zvo5P/+xjMwUG6zu uDaLi/k1JXhDM4u8yZxDmUefJ97v0q2PBkaA7m0gJaBur2fo3FIzn8pLFhrPgLUsiU8nvzHAM LY64JLrNRuaechQ5ihJrmpeen1gdIYKuLKyKj3AbImR1YpWXOunnco8WjDILK78ZIDuriOx0O i3JZZprg/XQhkZV+maPqzJgUYmHnAT0DP+oLUqJbOwb2J+59isaCv8dfiWLmaev4lG3Vp4Jxy eNPhuiS3YIuFTudxPiNKwQtlJE0lDB1oyYivkFhnkibAEKSojG7rSLTcSb0iD196cGnVhwj58 7wzUhWmZgdOgwDBH11a5drfUutBcvV9P0uiWkuwYw7XCM7ACofb4S2nYkayzrtSR/u3vx1+Jj JzcMmKPhlFzRWXWluIqwhqJsOVW7EHPQTAk7KtUoYVdYlWHykme2nQ5vnchonHqPW/1E= To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The latest gcc-7.0.1 snapshot warns about an unintialized variable use: In file included from fs/reiserfs/lbalance.c:8:0: fs/reiserfs/lbalance.c: In function 'leaf_item_bottle.isra.3': fs/reiserfs/reiserfs.h:1279:13: error: '*((void *)&n_ih+8).v' may be used uninitialized in this function [-Werror=maybe-uninitialized] v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset); ~~^~~ fs/reiserfs/reiserfs.h:1279:13: error: '*((void *)&n_ih+8).v' may be used uninitialized in this function [-Werror=maybe-uninitialized] v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset); This happens because the offset/type pair that is stored in ih.key.u.k_offset_v2 is actually uninitialized when we call set_le_ih_k_offset() and set_le_ih_k_type(). After we have called both, all data is correct, but the first of the two reads uninitialized data for the type field and writes it back before it gets overwritten. This works around the warning by initializing the k_offset_v2 through the slightly larger memcpy(). Signed-off-by: Arnd Bergmann --- fs/reiserfs/lbalance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c index 249594a821e0..8eed8f5f6881 100644 --- a/fs/reiserfs/lbalance.c +++ b/fs/reiserfs/lbalance.c @@ -475,7 +475,7 @@ static void leaf_item_bottle(struct buffer_info *dest_bi, * 'cpy_bytes'; create new item header; * n_ih = new item_header; */ - memcpy(&n_ih, ih, SHORT_KEY_SIZE); + memcpy(&n_ih, ih, KEY_SIZE); /* Endian safe, both le */ n_ih.ih_version = ih->ih_version; -- 2.9.0