From patchwork Tue Nov 15 01:00:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9428713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 44D9660484 for ; Tue, 15 Nov 2016 01:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3861C28B32 for ; Tue, 15 Nov 2016 01:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 295AB28B34; Tue, 15 Nov 2016 01:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 411CE28B32 for ; Tue, 15 Nov 2016 01:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755161AbcKOBAc (ORCPT ); Mon, 14 Nov 2016 20:00:32 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:35778 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755153AbcKOBAc (ORCPT ); Mon, 14 Nov 2016 20:00:32 -0500 Received: by mail-it0-f67.google.com with SMTP id b123so18297590itb.2 for ; Mon, 14 Nov 2016 17:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=W9kMOmejJJWJ1iYl9Yucnca3LHnSGbRwXAwYj0gQXT0=; b=dwMSH0VZqacWp9A1NG//E6Ng3oQkKEemelqVZurcAdolFZ9GInWvYimOUJvPfETayD bHEJAJf0/1IvgVmAmb9ryqsaAwdzXBIq3oN9V1jCAqazriLSYIAFJxMQ0qgQe/QVPiVv S06uINOcoe/se7zloCkezp2x2sPmkbyoiB2b8hHwM7yU6iFR3Wtx2P799iCPisKCXlv4 Y47rgoaLBQDeDgtE+7X5wFwvMVJCm4hM6C7ocCO6D5XOLX5PSE+VpBwy2/3XJB6YsqhW TOtl4poXC0uxw2uL3uZ80Al+bkifv2Vu4t5XGoNPVKnlt/SVvu4gKBc9PUQ6CH9z145g nq+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=W9kMOmejJJWJ1iYl9Yucnca3LHnSGbRwXAwYj0gQXT0=; b=mXgk9TSQoGdnkdof5KpJN8QClkfQpBJc0wywM7vZRFSFDFtxp+bAGzC2Vn57OQLok1 e5E0fp7pZu2TQ/CVPcdyuHqpiiWjUlGmjht8TFq5xFmqkK9kjGUgXD6dzzBtkG299efL +wlLXh53HFfwSeu9WpKXghjp/UREHhvm7rX7y6PRGZePt0QelrVBdKpzJpvGHkUTTIeR 3HlMxlAsH4Y2HJJfxFBBcjygf1UdXZ7NG8RELRWj1JNzBld2iGt0V4jct0JpVVdMHvpB RBwb0XyR1fz7NRv8ze/vxC+6HfN84gBlzFVgyJ0ZyG0KZLm04wk3BrywQy95+ugPSYFy HUCQ== X-Gm-Message-State: ABUngveNa+Mb/DuvLmhwT3SZyVH5WqAtncAF6Rxr2So4nbgRTWIP9/B9Sbw7cWjCTSgBj+z+BDfyCM3gxLGBdA== X-Received: by 10.36.22.197 with SMTP id a188mr811898ita.1.1479171630745; Mon, 14 Nov 2016 17:00:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.209.68 with HTTP; Mon, 14 Nov 2016 17:00:30 -0800 (PST) In-Reply-To: References: <1479150736-28392-1-git-send-email-jlayton@redhat.com> <20161114200447.GA15866@macbook.local> From: Christopher Li Date: Tue, 15 Nov 2016 09:00:30 +0800 X-Google-Sender-Auth: hDhs8qRGVvRkkqs9EtG-KzJmc9s Message-ID: Subject: Re: [PATCH] Handle SForced in storage_modifiers To: Linus Torvalds Cc: Luc Van Oostenryck , Jeff Layton , Sparse Mailing-list , Al Viro Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Nov 15, 2016 at 4:17 AM, Linus Torvalds wrote: > The problem is the _size_ of the array. Without that initializer for > SForced case, it is one entry too small, and you get a random access > past the end of the array. > > The patch is definitely correct. > Yes, the patch is definitely correct. It is a good catch. I purpose a slightly different way to fix it. I think it is better just give the array of a size instead of using the designated initializer to determine the array size. Sequential initializer to determine the array size is fine. Jeff, how about some thing like this: Chris Reviewed-by: Jeff Layton --- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/parse.c b/parse.c index 66f9353..a01ba00 100644 --- a/parse.c +++ b/parse.c @@ -109,7 +109,7 @@ enum { }; enum { - SNone = 0, STypedef, SAuto, SRegister, SExtern, SStatic, SForced + SNone = 0, STypedef, SAuto, SRegister, SExtern, SStatic, SForced, SMax }; static struct symbol_op typedef_op = { @@ -1279,7 +1279,7 @@ static const char *storage_class[] = static unsigned long storage_modifiers(struct decl_state *ctx) { - static unsigned long mod[] = + static unsigned long mod[SMax] = { [SAuto] = MOD_AUTO, [SExtern] = MOD_EXTERN,