From patchwork Mon Nov 3 14:34:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirsher, Jeffrey T" X-Patchwork-Id: 5216961 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1503B9F380 for ; Mon, 3 Nov 2014 14:34:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AFE12012E for ; Mon, 3 Nov 2014 14:34:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7081B20125 for ; Mon, 3 Nov 2014 14:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752348AbaKCOeR (ORCPT ); Mon, 3 Nov 2014 09:34:17 -0500 Received: from mga03.intel.com ([134.134.136.65]:25688 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbaKCOeR (ORCPT ); Mon, 3 Nov 2014 09:34:17 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 03 Nov 2014 06:32:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,308,1413270000"; d="scan'208";a="630338762" Received: from tpandit-mobl2.amr.corp.intel.com (HELO jtkirshe-mobl.amr.corp.intel.com) ([10.254.81.222]) by orsmga002.jf.intel.com with ESMTP; 03 Nov 2014 06:34:16 -0800 From: Jeff Kirsher To: sparse@chrisli.org Cc: Mark Rustad , linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org, Jeff Kirsher Subject: [PATCH] compiler: Correct macro parameter expansion problem Date: Mon, 3 Nov 2014 06:34:13 -0800 Message-Id: <1415025253-15976-1-git-send-email-jeffrey.t.kirsher@intel.com> X-Mailer: git-send-email 1.9.3 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mark Rustad The macro __compiletime_error_fallback has an error in that it lacks parens around the expansion of an expression. It also lacks a conversion to a boolean value. The first problem can result in a mis-evaluation. The second problem can also result in an error if the value comes out negative. That would thwart the intended error generation. That is, the error being asserted would not in fact generate an error. Fix both problems by adding !!() to the expansion. Signed-off-by: Mark Rustad Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher Reviewed-by: Josh Triplett --- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index d5ad7b1..59dc611 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -331,7 +331,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); */ # ifndef __CHECKER__ # define __compiletime_error_fallback(condition) \ - do { ((void)sizeof(char[1 - 2 * condition])); } while (0) + do { ((void)sizeof(char[1 - 2 * !!(condition)])); } while (0) # endif #endif #ifndef __compiletime_error_fallback