Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750851AbdGYHRf (ORCPT ); Tue, 25 Jul 2017 03:17:35 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33190 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750746AbdGYHRd (ORCPT ); Tue, 25 Jul 2017 03:17:33 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170721210251.3378996-1-arnd@arndb.de> From: Arnd Bergmann Date: Tue, 25 Jul 2017 09:17:32 +0200 X-Google-Sender-Auth: e6nm4jgKOs4q10th26RaxWgGgwc Message-ID: Subject: Re: [PATCH] [v2] kasan: avoid -Wmaybe-uninitialized warning To: Alexander Potapenko Cc: Andrey Ryabinin , Dmitry Vyukov , Andrew Morton , Andrey Konovalov , kasan-dev , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1032 Lines: 25 On Mon, Jul 24, 2017 at 1:35 PM, Alexander Potapenko wrote: > On Fri, Jul 21, 2017 at 11:02 PM, Arnd Bergmann wrote: >> diff --git a/mm/kasan/report.c b/mm/kasan/report.c >> index 04bb1d3eb9ec..28fb222ab149 100644 >> --- a/mm/kasan/report.c >> +++ b/mm/kasan/report.c >> @@ -111,6 +111,9 @@ static const char *get_wild_bug_type(struct kasan_access_info *info) >> { >> const char *bug_type = "unknown-crash"; >> >> + /* shut up spurious -Wmaybe-uninitialized warning */ >> + info->first_bad_addr = (void *)(-1ul); >> + > Why don't we initialize info.first_bad_addr in kasan_report(), where > info is allocated? I'm just trying to shut up a particular warning here where gcc can't figure out by itself that it is initialized. Setting an invalid address at allocation time would prevent gcc from warning even for any trivial bug where we use the incorrect value in the normal code path, in case someone later wants to modify the code further and makes a mistake. Arnd