Skip to content

Commit dcf8e56

Browse files
bvanasschetorvalds
authored andcommitted
tracing: Define the is_signed_type() macro once
There are two definitions of the is_signed_type() macro: one in <linux/overflow.h> and a second definition in <linux/trace_events.h>. As suggested by Linus, move the definition of the is_signed_type() macro into the <linux/compiler.h> 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. Link: https://lore.kernel.org/all/CAHk-=whjH6p+qzwUdx5SOVVHjS3WvzJQr6mDUwhEyTf6pJWzaQ@mail.gmail.com/ Link: https://lore.kernel.org/all/CAHk-=wjQGnVfb4jehFR0XyZikdQvCZouE96xR_nnf5kqaM5qqQ@mail.gmail.com/ Cc: Rasmus Villemoes <[email protected]> Cc: Steven Rostedt <[email protected]> Acked-by: Kees Cook <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d68d289 commit dcf8e56

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

include/linux/compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ static inline void *offset_to_ptr(const int *off)
239239
/* &a[0] degrades to a pointer: a different type from an array */
240240
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
241241

242+
/*
243+
* Whether 'type' is a signed type or an unsigned type. Supports scalar types,
244+
* bool and also pointer types.
245+
*/
246+
#define is_signed_type(type) (((type)(-1)) < (__force type)1)
247+
242248
/*
243249
* This is needed in functions which generate the stack canary, see
244250
* arch/x86/kernel/smpboot.c::start_secondary() for an example.

include/linux/overflow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
* https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
3131
* credit to Christian Biere.
3232
*/
33-
#define is_signed_type(type) (((type)(-1)) < (type)1)
3433
#define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
3534
#define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
3635
#define type_min(T) ((T)((T)-type_max(T)-(T)1))

include/linux/trace_events.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,6 @@ extern int trace_add_event_call(struct trace_event_call *call);
814814
extern int trace_remove_event_call(struct trace_event_call *call);
815815
extern int trace_event_get_offsets(struct trace_event_call *call);
816816

817-
#define is_signed_type(type) (((type)(-1)) < (type)1)
818-
819817
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
820818
int trace_set_clr_event(const char *system, const char *event, int set);
821819
int trace_array_set_clr_event(struct trace_array *tr, const char *system,

0 commit comments

Comments
 (0)