public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Mark deprecated functions so they give a warning on use
@ 2002-12-28  0:57 Rusty Russell
  2002-12-28  5:54 ` Richard Henderson
  2002-12-28 15:30 ` Alexander Kellett
  0 siblings, 2 replies; 8+ messages in thread
From: Rusty Russell @ 2002-12-28  0:57 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, william stinson, trivial

If anyone can think of a better way, please share.  This should speed
up the removal of functions like check_region() (which, despite
William's janitorial efforts, is still not at the stage where it can
be removed).

Thanks,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: Mark deprecated functions so they give a warning on use
Author: Rusty Russell
Status: Trivial

D: Should speed elimination of deprecated functions (eg. check_region,
D: deprecated since 2.3, still used in about 120 files).
D:
D: This patch causes an "unused label" warning: hopefully unusual
D: enough to make people look twice. eg:
D:  drivers/net/depca.c: In function `isa_probe':
D:  drivers/net/depca.c:1413: warning: label `DEPRECATED_use_request_region_return_value' defined but not used

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.53/include/linux/compiler.h working-2.5.53-deprecated/include/linux/compiler.h
--- linux-2.5.53/include/linux/compiler.h	2002-12-28 11:12:34.000000000 +1100
+++ working-2.5.53-deprecated/include/linux/compiler.h	2002-12-28 11:51:08.000000000 +1100
@@ -19,4 +19,10 @@
   ({ unsigned long __ptr;					\
     __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
     (typeof(ptr)) (__ptr + (off)); })
+
+/* Used to give a warning on use of deprecated functions.  eg:
+   #define some_old_function(arg) \
+	__DEPRECATED(use_newfunction_instead), __some_old_function(arg)
+*/
+#define __DEPRECATED(msg) ({DEPRECATED_##msg: 1; })
 #endif /* __LINUX_COMPILER_H */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.53/include/linux/ioport.h working-2.5.53-deprecated/include/linux/ioport.h
--- linux-2.5.53/include/linux/ioport.h	2002-10-31 12:37:01.000000000 +1100
+++ working-2.5.53-deprecated/include/linux/ioport.h	2002-12-28 11:51:46.000000000 +1100
@@ -7,6 +7,7 @@
 
 #ifndef _LINUX_IOPORT_H
 #define _LINUX_IOPORT_H
+#include <linux/compiler.h>
 
 /*
  * Resources are tree-like, allowing
@@ -102,7 +103,7 @@ extern int allocate_resource(struct reso
 extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name);
 
 /* Compatibility cruft */
-#define check_region(start,n)	__check_region(&ioport_resource, (start), (n))
+#define check_region(start,n)	__DEPRECATED(use_request_region_return_value), __check_region(&ioport_resource, (start), (n))
 #define release_region(start,n)	__release_region(&ioport_resource, (start), (n))
 #define check_mem_region(start,n)	__check_region(&iomem_resource, (start), (n))
 #define release_mem_region(start,n)	__release_region(&iomem_resource, (start), (n))

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH] deprecated function attribute
@ 2002-12-28 23:32 william stinson
  0 siblings, 0 replies; 8+ messages in thread
From: william stinson @ 2002-12-28 23:32 UTC (permalink / raw)
  To: Robert Love
  Cc: Alexander Kellett, Rusty Russell, torvalds, linux-kernel, trivial

Hi Robert,

here's a patch to mark check_region "deprecated".

I have not done much testing with it yet (and maybe there is a more elegant implementation)

I do get nice warning messages for programs that still use check_region for example
	drivers/parport/parport_pc.c:2215: warning: `__check_region' is deprecated (declared at include/linux/ioport.h:111)

Best regards
William

--- linux-2.5.53/kernel/resource.c	2002-12-28 23:05:37.000000000 +0100
+++ linux-local/kernel/resource.c	2002-12-28 23:05:55.000000000 +0100
@@ -237,7 +237,7 @@
 	return res;
 }
 
-int __check_region(struct resource *parent, unsigned long start, unsigned long n)
+int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n)
 {
 	struct resource * res;
 
--- linux-2.5.53/include/linux/ioport.h	2002-12-28 23:02:52.000000000 +0100
+++ linux-local/include/linux/ioport.h	2002-12-28 23:14:46.000000000 +0100
@@ -8,6 +8,7 @@
 #ifndef _LINUX_IOPORT_H
 #define _LINUX_IOPORT_H
 
+#include <linux/compiler.h>
 /*
  * Resources are tree-like, allowing
  * nesting etc..
@@ -107,7 +108,7 @@
 #define check_mem_region(start,n)	__check_region(&iomem_resource, (start), (n))
 #define release_mem_region(start,n)	__release_region(&iomem_resource, (start), (n))
 
-extern int __check_region(struct resource *, unsigned long, unsigned long);
+extern int deprecated __check_region(struct resource *, unsigned long, unsigned long);
 extern void __release_region(struct resource *, unsigned long, unsigned long);
 
 #define get_ioport_list(buf)	get_resource_list(&ioport_resource, buf, PAGE_SIZE)





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-12-28 23:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-28  0:57 [PATCH] Mark deprecated functions so they give a warning on use Rusty Russell
2002-12-28  5:54 ` Richard Henderson
2002-12-28 15:30 ` Alexander Kellett
2002-12-28 17:51   ` [PATCH] deprecated function attribute Robert Love
2002-12-28 18:03     ` Robert Love
2002-12-28 18:53       ` Daniel Jacobowitz
2002-12-28 20:50         ` Robert Love
  -- strict thread matches above, loose matches on Subject: below --
2002-12-28 23:32 william stinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox