Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp586134rwe; Fri, 26 Aug 2022 10:16:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR50azrMBJKqcrrAmlM17kYzmG71Ap4GJ1WhtV2gQlO2SS7hikN2jk78Hu8kB/YkJ3Y80Wv2 X-Received: by 2002:a17:907:3f85:b0:733:3f0e:2f28 with SMTP id hr5-20020a1709073f8500b007333f0e2f28mr5878713ejc.376.1661534190565; Fri, 26 Aug 2022 10:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661534190; cv=none; d=google.com; s=arc-20160816; b=g88ywCkFAPrXFt24uoq7Zl4f8v/P4Zi8kNNJJEbFOHHGfMeFOgMkK7AiiYoysTxzOe oem0XejDCWvgVF77kptmc+Wd3Lrk9rOcHWN171R5ndmb8r50IO9sYfENoeo0q7lPzI7Y rX28qjyyVswJWlHXKkNrroFR0ivds4Y+rwrFeoD6Q2TfyK5QSRMArQVX2q0j1F1Ca6az b/N4/kpIqDPtGH19dQT5leaAjKTZmzwlxrd7rKi8miLa6IWqqw5fllvCdIKUwskhUtRP oD9/qrBviEWa0m5Ujz9cdgwIDkKUqTUyrHJHlukfd2dz2IE/zN2RTzFAQhhYfeikRO/J x55w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UHxQNac7+y6T8HuGfiFe8GQdrtI4xLbtO21BSRiD3iY=; b=c6uU88HiNj+y1snu83lv3214FtUZkQdHsS385G8q8Yos/1xStuaIn694YpzW9p+a1L O6QlKLSx1i2+7nvBe1UjhuNidyFRk11n3H1vP9DzWXraNW4rL2psyl+KcNt4KlwuBvsi Yg1NWz/mi35sUFNYMOqwH+ZT6+fXA9C7CsbeimHY7nMKgGrzLb86DEBwkTSs8bufJ5Zl Z4WbGwRXzLlg4F2a1gm5yKFW2jEOBC7wrNBv4XugEZfGs4zsO9B6wjlb1N5ltgCV7E0I 9binPybAA4MCGfc8MyF2XODBqMVmoTdOtlxKgmqcI3W1wYJ304vDsGC+rjscgT+4hg6a TlpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acm.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y25-20020a50e619000000b004472a202580si1562365edm.220.2022.08.26.10.16.04; Fri, 26 Aug 2022 10:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acm.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344546AbiHZQVg (ORCPT + 99 others); Fri, 26 Aug 2022 12:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344578AbiHZQVb (ORCPT ); Fri, 26 Aug 2022 12:21:31 -0400 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 689F8DD77E for ; Fri, 26 Aug 2022 09:21:30 -0700 (PDT) Received: by mail-pj1-f42.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso8564497pjk.0 for ; Fri, 26 Aug 2022 09:21:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=UHxQNac7+y6T8HuGfiFe8GQdrtI4xLbtO21BSRiD3iY=; b=OLvxdcq+e9sygai/ODa7nXQFO3vWSFjSqk2uC515dUhqK80k6gD2Rcokg1T0cNSqI0 XQOHpxv8sLh1+11gYa6bnIw07Cm3+rYAN20O/cCVRxSmBiXUqn4F7dMg1zb577yNHJWR ALCk3TuHjRbcjcl0XQpHCa6KmxoFIFZJtqW82+F1y3X12YvwlP7FRo0iXBFuBJZNS5IW pmlYH9b9HJXOx3rKcWXPQkTcuHEdT27v9oh1ZFMcqIAl5Bdaagm3NVaHKW6T5OgCJoLC IirtG1jP2wt9dyKfEzuPK6JjiAZlvVpieWeR6ph/4hrL4soFNz7ub5CgwxGyd+VOgjLY FECg== X-Gm-Message-State: ACgBeo1a+X8YB8JOWfr99OdnGOfHFVJA14by/HbHsHA/SRix5cKbHy3R wEWV9XQxeE8KlFmAEETS95o= X-Received: by 2002:a17:903:134d:b0:172:e199:bb39 with SMTP id jl13-20020a170903134d00b00172e199bb39mr4301800plb.154.1661530889774; Fri, 26 Aug 2022 09:21:29 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:a12:b4b9:f1b3:ec63]) by smtp.gmail.com with ESMTPSA id cp7-20020a170902e78700b0016ee328fd61sm1790077plb.198.2022.08.26.09.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 09:21:29 -0700 (PDT) From: Bart Van Assche To: Kees Cook Cc: linux-kernel@vger.kernel.org, Bart Van Assche , Andrew Morton , Arnd Bergmann , Dan Williams , Eric Dumazet , Ingo Molnar , Isabella Basso , "Jason A. Donenfeld" , Josh Poimboeuf , Luc Van Oostenryck , Masami Hiramatsu , Nathan Chancellor , Peter Zijlstra , Rasmus Villemoes , Sander Vanheule , Steven Rostedt , Vlastimil Babka , Yury Norov Subject: [PATCH 2/2] overflow, tracing: Define the is_signed_type() macro once Date: Fri, 26 Aug 2022 09:21:16 -0700 Message-Id: <20220826162116.1050972-3-bvanassche@acm.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220826162116.1050972-1-bvanassche@acm.org> References: <20220826162116.1050972-1-bvanassche@acm.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two definitions of the is_signed_type() macro: one in and a second definition in . As suggested by Linus Torvalds, move the definition of the is_signed_type() macro into the header file. Change the definition of the is_signed_type() macro to make sure that it does not trigger any sparse warnings with future versions of sparse for bitwise types. See also: https://lore.kernel.org/all/CAHk-=whjH6p+qzwUdx5SOVVHjS3WvzJQr6mDUwhEyTf6pJWzaQ@mail.gmail.com/ https://lore.kernel.org/all/CAHk-=wjQGnVfb4jehFR0XyZikdQvCZouE96xR_nnf5kqaM5qqQ@mail.gmail.com/ Cc: Andrew Morton Cc: Arnd Bergmann Cc: Dan Williams Cc: Eric Dumazet Cc: Ingo Molnar Cc: Isabella Basso Cc: "Jason A. Donenfeld" Cc: Josh Poimboeuf Cc: Luc Van Oostenryck Cc: Masami Hiramatsu Cc: Nathan Chancellor Cc: Peter Zijlstra Cc: Rasmus Villemoes Cc: Sander Vanheule Cc: Steven Rostedt Cc: Vlastimil Babka Cc: Yury Norov Signed-off-by: Bart Van Assche --- include/linux/compiler.h | 6 ++++++ include/linux/overflow.h | 1 - include/linux/trace_events.h | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 01ce94b58b42..7713d7bcdaea 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -239,6 +239,12 @@ static inline void *offset_to_ptr(const int *off) /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) +/* + * Whether 'type' is a signed type or an unsigned type. Supports scalar types, + * bool and also pointer types. + */ +#define is_signed_type(type) (((type)(-1)) < (__force type)1) + /* * This is needed in functions which generate the stack canary, see * arch/x86/kernel/smpboot.c::start_secondary() for an example. diff --git a/include/linux/overflow.h b/include/linux/overflow.h index f1221d11f8e5..0eb3b192f07a 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h @@ -30,7 +30,6 @@ * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html - * credit to Christian Biere. */ -#define is_signed_type(type) (((type)(-1)) < (type)1) #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) #define type_min(T) ((T)((T)-type_max(T)-(T)1)) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index b18759a673c6..8401dec93c15 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -814,8 +814,6 @@ extern int trace_add_event_call(struct trace_event_call *call); extern int trace_remove_event_call(struct trace_event_call *call); extern int trace_event_get_offsets(struct trace_event_call *call); -#define is_signed_type(type) (((type)(-1)) < (type)1) - int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set); int trace_set_clr_event(const char *system, const char *event, int set); int trace_array_set_clr_event(struct trace_array *tr, const char *system,