Deprecating __deprecated

Submitted by Jeremy
on October 26, 2007 - 6:03am

"The __deprecated marker is quite useful in highlighting the remnants of old APIs that want removing. However, it is quite normal for one or more years to pass, before the (usually ancient, bitrotten) code in question is either updated or deleted," explained Jeff Garzik, posting a small patch to make it possible to silence "warning: 'foo' is deprecated" type messages.

Andrew Morton wasn't impressed, suggesting, "Sigh. Can't we just fix the dud code? Or mark it BROKEN and see what happens?" Linus Torvalds added, "I think removing __deprecated is the better option. Quite frankly, some people add '__deprecated' *way* too eagerly." Jeff agreed that __deprecated is over used, "__deprecated has spread to just about every API that people don't consider fresh and up-to-date." He then added ,"like I noted in the patch description, rewriting grotty ISA/MCA/etc. probe code is a thankless, boring task that few are crazy enough to attempt :) As you can see from the patch flood recently I /have/ been working through the dud code, but it will still take years. The changes required for each are on average ~200 LOC changed, if not more."


From: Jeff Garzik
Subject: [PATCH] Permit silencing of __deprecated warnings.
Date: Oct 25, 1:06 am 2007

The __deprecated marker is quite useful in highlighting the remnants of
old APIs that want removing.

However, it is quite normal for one or more years to pass, before the
(usually ancient, bitrotten) code in question is either updated or
deleted.

Thus, like __must_check, add a Kconfig option that permits the silencing
of this compiler warning.

This change mimics the ifdef-ery and Kconfig defaults of MUST_CHECK as
closely as possible.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 include/linux/compiler.h |    6 ++++++
 lib/Kconfig.debug        |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c811c8b..c68b67b 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -101,6 +101,12 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 #undef __must_check
 #define __must_check
 #endif
+#ifndef CONFIG_ENABLE_WARN_DEPRECATED
+#undef __deprecated
+#undef __deprecated_for_modules
+#define __deprecated
+#define __deprecated_for_modules
+#endif
 
 /*
  * Allow us to avoid 'defined but not used' warnings on functions and data,
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 1faa508..1e5f207 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -9,6 +9,14 @@ config PRINTK_TIME
 	  operations.  This is useful for identifying long delays
 	  in kernel startup.
 
+config ENABLE_WARN_DEPRECATED
+	bool "Enable __deprecated logic"
+	default y
+	help
+	  Enable the __deprecated logic in the kernel build.
+	  Disable this to suppress the "warning: 'foo' is deprecated
+	  (declared at kernel/power/somefile.c:1234)" messages.
+
 config ENABLE_MUST_CHECK
 	bool "Enable __must_check logic"
 	default y
-- 
1.5.2.4

-

From: Andrew Morton Subject: Re: [PATCH] Permit silencing of __deprecated warnings. Date: Oct 25, 1:15 am 2007 On Thu, 25 Oct 2007 04:06:13 -0400 (EDT) Jeff Garzik <jeff@garzik.org> wrote: > The __deprecated marker is quite useful in highlighting the remnants of > old APIs that want removing. > > However, it is quite normal for one or more years to pass, before the > (usually ancient, bitrotten) code in question is either updated or > deleted. > > Thus, like __must_check, add a Kconfig option that permits the silencing > of this compiler warning. > > This change mimics the ifdef-ery and Kconfig defaults of MUST_CHECK as > closely as possible. Sigh. Can't we just fix the dud code? Or mark it BROKEN and see what happens? -
From: Linus Torvalds Subject: Re: [PATCH] Permit silencing of __deprecated warnings. Date: Oct 25, 8:34 am 2007 On Thu, 25 Oct 2007, Andrew Morton wrote: > > Sigh. Can't we just fix the dud code? Or mark it BROKEN and see what > happens? I think removing __deprecated is the better option. Quite frankly, some people add "__deprecated" *way* too eagerly. Linus -
From: Jeff Garzik Subject: Re: [PATCH] Permit silencing of __deprecated warnings. Date: Oct 25, 1:20 am 2007 Andrew Morton wrote: > On Thu, 25 Oct 2007 04:06:13 -0400 (EDT) Jeff Garzik <jeff@garzik.org> wrote: > >> The __deprecated marker is quite useful in highlighting the remnants of >> old APIs that want removing. >> >> However, it is quite normal for one or more years to pass, before the >> (usually ancient, bitrotten) code in question is either updated or >> deleted. >> >> Thus, like __must_check, add a Kconfig option that permits the silencing >> of this compiler warning. >> >> This change mimics the ifdef-ery and Kconfig defaults of MUST_CHECK as >> closely as possible. > > Sigh. Can't we just fix the dud code? Or mark it BROKEN and see what > happens? __deprecated has spread to just about every API that people don't consider fresh and up-to-date. Like I noted in the patch description, rewriting grotty ISA/MCA/etc. probe code is a thankless, boring task that few are crazy enough to attempt :) As you can see from the patch flood recently I /have/ been working through the dud code, but it will still take years. The changes required for each are on average ~200 LOC changed, if not more. But regardless... I don't see any reason to force every kernel build to remind us of grotty drivers. Where's the benefit? Everybody knows they are grotty. Like __must_check this option defaults to the current state of things -- warnings -- so you have to take an extra step to turn them off. Jeff -