From patchwork Fri May 27 20:22:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102301 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp286413qge; Fri, 27 May 2016 13:22:44 -0700 (PDT) X-Received: by 10.98.90.130 with SMTP id o124mr24877075pfb.115.1464380564089; Fri, 27 May 2016 13:22:44 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk7si30501064pab.97.2016.05.27.13.22.43; Fri, 27 May 2016 13:22:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756614AbcE0UWk (ORCPT + 30 others); Fri, 27 May 2016 16:22:40 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:63116 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756572AbcE0UWj (ORCPT ); Fri, 27 May 2016 16:22:39 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0MFLD2-1bKfV842Dc-00EOB7; Fri, 27 May 2016 22:22:35 +0200 From: Arnd Bergmann Cc: Andrew Morton , Alexander Viro , Arnd Bergmann , reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] reiserfs: avoid uninitialized variable use Date: Fri, 27 May 2016 22:22:36 +0200 Message-Id: <1464380569-3493380-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:Yy8oqAgbdAf206Co9b6KN1ZixxRH815hJfQKtWbFgoDtL68dMzO G63zncNsv8yfTKk19E/vFM++pZLcQyxJVVAm1PXqOiEX1182nLcwkl2oTaZqKWaqLU/cKjA PY9NZKpZ47Gg6GzynwVXzY/0kaiOmbpQNx6EM6y2ow1c8FtLDaHejetGQNZb+WpvThxKJjW /Ya85XSTJwYVO39Mge4jw== X-UI-Out-Filterresults: notjunk:1; V01:K0:7c+Xueq9c1k=:tG3lVoaMLC2Y3iVOx3AGJz GCRVyLxuhzLsy0e0nEu/5F9dYzKRYBHrfeXTcnzd50kurkKgsvlOzTZ4WUBw+UhRwa1IOdWqR CBxk7CNbFgDli2zjK6c6ycHwSOts8ADI3Bb3ZOAX5vSns0b27UmsNZqNobaavYvcgokYbKCE3 sbHXT8/7OKsrzLcanECuouwjw2GR86peHam4jnQ5VxoHikYrfHhn4b9pGpKZdglQ3rIkuZec9 +GG0QljHEQRHy1OJfhXEi2/kwcdoNGy5tochqa/4xIkYfMJOow7lKXFwBNFWpUSy7j8NmgSMo gu8uEjYYma3cveoHLhkddmjF3mGccnjFP1EccTjbWHaWRhfWfFsFPqbHEI9nsl1cUShlM6rXF wNmQ+ArDZvVcazsWYNonZdlYOYwkdagLCKDPdlLGAuHIVlK2UHAiRSeOP6X1SiEFsHlvv3UUY 44Dv7UtHwavU87XOmIeS1NMCLDMe+v3auG0MJTjkHjzTT6a4syMVbJJBmB5sgvqOVYRk3kKi+ u5uRbxNO3cyMtayq/MjjIDNOIwB5FM3TR2sXM3Dlh91hFtcSqPEuyKUWyHqbLpxbMpPRCX76w 034izJU7nhvWuwqw9NbucjlRxhR1LIvDSGBTuVkiGhcQ1agiEwR7/F2Dp8L9EHs4rKFB6cHf1 NhqrnnKJng+CmMB7fBp7d+1XiVm6tUao2SWfCjcHIuzTFAqonTBdZh79Mi2kpNHU8JeY= To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I got this warning on an ARM64 allmodconfig build with gcc-5.3: fs/reiserfs/ibalance.c: In function 'balance_internal': fs/reiserfs/ibalance.c:1158:3: error: 'new_insert_key' may be used uninitialized in this function [-Werror=maybe-uninitialized] memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE); The warning is correct, in fact both new_insert_key and new_insert_ptr are only updated inside of an if() block, but used at the end of the function. Looking at how the balance_internal() function gets called, it is clear that this is harmless because the caller never uses the updated arrays, they are initialized from balance_leaf_new_nodes() and then passed into balance_internal(). This has not changed at all since the start of the git history, but apparently the warning has only recently appeared. This modifies the function to only update the two argument variables when the new_insert_key and new_insert_ptr have been updated, to get rid of the warning. Signed-off-by: Arnd Bergmann --- I thought I had send this on May 12 when I first became aware of the warning, but I can't find a reference to that now on any mailing list archives, and I'm not sure who is picking up reiserfs patches these days. The warning is now one of the few 'allmodconfig' warnings for arm64 and possibly some other architectures. fs/reiserfs/ibalance.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.0 diff --git a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c index b751eea32e20..6dcc38f132f5 100644 --- a/fs/reiserfs/ibalance.c +++ b/fs/reiserfs/ibalance.c @@ -1138,6 +1138,9 @@ int balance_internal(struct tree_balance *tb, S_new); /* S_new is released in unfix_nodes */ + + memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE); + insert_ptr[0] = new_insert_ptr; } n = B_NR_ITEMS(tbSh); /*number of items in S[h] */ @@ -1153,8 +1156,5 @@ int balance_internal(struct tree_balance *tb, insert_ptr); } - memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE); - insert_ptr[0] = new_insert_ptr; - return order; }