lkml.org 
[lkml]   [1996]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
From
Subjectname space analysis and patches, 2.1.17
Date

Analysing the kernel and modules name space to try to understand the
flow of control better. There are a few multiply defined non-static
symbols and over 1,500 non-static symbols which do not appear to be
referenced outside the source they are declared in, this seems to be a
bit of name space pollution.

The list below was generated by switching on every legal option on a
2.1.17 kernel, i386 architecture, using modules wherever possible.
Sources that would not compile were ignored except where the fix was
obvious (and thanks to Michael L. Galbraith for patches to get the ISDN
sources to compile). The load modules were then analysed for external
declarations and references.

The result is a 2,200+ line report of name space anomalies. If only
for the sake of cleanliness, these anomalies should be corrected. I
have included some patches to remove multiply defined non-static
symbols.

This mail only contains the multiply defined symbols and patches where
available. The full report, including all the non-static symbols which
are not used outside their own source (another 2,100 lines), can be
fetched by anonymous ftp from

ftp://ftp.ocs.com.au/pub/extra_externals-2.1.17.gz

Could the various maintainers look at that report and change the
symbols to static where possible.

NOTE: I have not tried to boot with the patches below, the patches
simply correct the multiple non-static definitions.


MULTIPLY DEFINED EXTERNALS AND OTHER ANOMALIES.

No nm data for drivers/char/ftape/fc-10.o

This module is in the ftape Makefile but there are no configuration
variables for it so it compiles to a null module. Bit of a waste
of space, is it still a viable source?

ax2asc is multiply defined in net/ax25/af_ax25.o and net/ipv4/arp.o

Two copies of the ax2asc routine, seemingly identical. The
af_ax25.c version is X()ported. Slight risk of code divergence.
Left to some networking guru to fix.

debug is multiply defined in drivers/net/tulip.o and
arch/i386/kernel/entry.o

tulip declares debug as integer if compiled as a module, entry
always declares debug as an entry. No need for externally visible
debug in tulip (?), possibly confusing, patch to make it static :-

diff -ur linux-2.1.17.orig/drivers/net/tulip.c linux/drivers/net/tulip.c
--- linux-2.1.17.orig/drivers/net/tulip.c Mon Dec 23 11:54:01 1996
+++ linux/drivers/net/tulip.c Mon Dec 23 14:06:12 1996
@@ -1415,7 +1415,7 @@
/* The parameters that may be passed in... */
/* This driver does nothing with options yet. It will later be used to
pass the full-duplex flag, etc. */
-int debug = -1;
+static int debug = -1;

int
init_module(void)
do_get_fast_time is multiply defined in 500 modules.

A side effect of declaring do_get_fast_time as a pointer in
<linux/time.h>. Every source that includes <linux/time.h> (over
500) declares a global pointer, adding at least 32 bytes to each
*.o file and (AFAIK) 4 bytes to each loaded module. Patch to
remove this waste of space :-

diff -ur linux-2.1.17.orig/include/linux/time.h linux/include/linux/time.h
--- linux-2.1.17.orig/include/linux/time.h Tue Nov 12 00:38:07 1996
+++ linux/include/linux/time.h Mon Dec 23 11:34:19 1996
@@ -25,7 +25,7 @@
void do_gettimeofday(struct timeval *tv);
void do_settimeofday(struct timeval *tv);
void get_fast_time(struct timeval *tv);
-void (*do_get_fast_time)(struct timeval *);
+extern void (*do_get_fast_time)(struct timeval *);
#endif

#define FD_SETSIZE __FD_SETSIZE
driver_template is multiply defined in drivers/scsi/... modules.

The driver_template's should probably be declared static in each
scsi host file. Left to the SCSI developers.

io is multiply defined in drivers/net/smc9194.o, drivers/net/3c523.o,
drivers/net/ni52.o, drivers/net/eth16i.o, drivers/char/wdt.o and
drivers/isdn/teles/mod.o

irq is multiply defined in drivers/net/smc9194.o, drivers/net/3c523.o,
drivers/net/ni52.o, drivers/net/eth16i.o, drivers/char/wdt.o and
drivers/isdn/pcbit/module.o

The io and irq parameters are normally used for insmod parameters, in
most modules they are defined as static, they probably should be static
in these modules as well. Patch for these variables and related insmod
variables follows :-

diff -ur linux-2.1.17.orig/drivers/char/wdt.c linux/drivers/char/wdt.c
--- linux-2.1.17.orig/drivers/char/wdt.c Fri Dec 13 01:51:09 1996
+++ linux/drivers/char/wdt.c Mon Dec 23 14:13:53 1996
@@ -48,8 +48,8 @@
* You must set these - there is no sane way to probe for this board.
*/

-int io=0x240;
-int irq=14;
+static int io=0x240;
+static int irq=14;

#define WD_TIMO (100*60) /* 1 minute */

diff -ur linux-2.1.17.orig/drivers/isdn/pcbit/module.c linux/drivers/isdn/pcbit/module.c
--- linux-2.1.17.orig/drivers/isdn/pcbit/module.c Wed May 15 16:09:00 1996
+++ linux/drivers/isdn/pcbit/module.c Mon Dec 23 14:15:19 1996
@@ -22,8 +22,8 @@
#include <linux/isdnif.h>
#include "pcbit.h"

-int mem[MAX_PCBIT_CARDS] = {0, };
-int irq[MAX_PCBIT_CARDS] = {0, };
+static int mem[MAX_PCBIT_CARDS] = {0, };
+static int irq[MAX_PCBIT_CARDS] = {0, };

int num_boards;
struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS] = {0, 0, 0, 0};
diff -ur linux-2.1.17.orig/drivers/isdn/teles/mod.c linux/drivers/isdn/teles/mod.c
--- linux-2.1.17.orig/drivers/isdn/teles/mod.c Tue Oct 29 06:44:46 1996
+++ linux/drivers/isdn/teles/mod.c Mon Dec 23 14:12:34 1996
@@ -20,7 +20,7 @@
unsigned int protocol;
} io_type;

-io_type io[] =
+static io_type io[] =
{
{0, 0, 0, 0},
{0, 0, 0, 0},
diff -ur linux-2.1.17.orig/drivers/net/3c523.c linux/drivers/net/3c523.c
--- linux-2.1.17.orig/drivers/net/3c523.c Fri Dec 13 01:51:09 1996
+++ linux/drivers/net/3c523.c Mon Dec 23 14:11:23 1996
@@ -1272,8 +1272,8 @@
" " /*"3c523"*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, elmc_probe };


-int irq=0;
-int io=0;
+static int irq=0;
+static int io=0;

int
init_module(void) {
diff -ur linux-2.1.17.orig/drivers/net/eth16i.c linux/drivers/net/eth16i.c
--- linux-2.1.17.orig/drivers/net/eth16i.c Mon Nov 18 20:31:31 1996
+++ linux/drivers/net/eth16i.c Mon Dec 23 14:12:17 1996
@@ -1183,8 +1183,8 @@
0, 0,
0, 0, 0, NULL, eth16i_probe };

-int io = 0x2a0;
-int irq = 0;
+static int io = 0x2a0;
+static int irq = 0;

int init_module(void)
{
diff -ur linux-2.1.17.orig/drivers/net/ni52.c linux/drivers/net/ni52.c
--- linux-2.1.17.orig/drivers/net/ni52.c Wed Oct 9 16:57:20 1996
+++ linux/drivers/net/ni52.c Mon Dec 23 14:12:04 1996
@@ -1316,10 +1316,10 @@
0, 0, 0, NULL, ni52_probe };

/* set: io,irq,memstart,memend or set it when calling insmod */
-int irq=9;
-int io=0x300;
-long memstart=0; /* e.g 0xd0000 */
-long memend=0; /* e.g 0xd4000 */
+static int irq=9;
+static int io=0x300;
+static long memstart=0; /* e.g 0xd0000 */
+static long memend=0; /* e.g 0xd4000 */

int init_module(void)
{
diff -ur linux-2.1.17.orig/drivers/net/smc9194.c linux/drivers/net/smc9194.c
--- linux-2.1.17.orig/drivers/net/smc9194.c Mon Oct 7 15:55:47 1996
+++ linux/drivers/net/smc9194.c Mon Dec 23 14:11:10 1996
@@ -1740,9 +1740,9 @@
0, 0, /* I/O address, IRQ */
0, 0, 0, NULL, smc_init };

-int io = 0;
-int irq = 0;
-int ifport = 0;
+static int io = 0;
+static int irq = 0;
+static int ifport = 0;

int init_module(void)
{
irq2host is multiply defined in drivers/scsi/qlogicisp.o and
drivers/scsi/wd7000.o

Should be static in both, patch follows :-

diff -ur linux-2.1.17.orig/drivers/scsi/qlogicisp.c linux/drivers/scsi/qlogicisp.c
--- linux-2.1.17.orig/drivers/scsi/qlogicisp.c Wed Jul 10 20:11:25 1996
+++ linux/drivers/scsi/qlogicisp.c Mon Dec 23 14:04:43 1996
@@ -534,7 +534,7 @@
QLOGICISP_REQ_QUEUE_LEN)
#define RES_QUEUE_DEPTH(in, out) QUEUE_DEPTH(in, out, RES_QUEUE_LEN)

-struct Scsi_Host *irq2host[NR_IRQS];
+static struct Scsi_Host *irq2host[NR_IRQS];

static void isp1020_enable_irqs(struct Scsi_Host *);
static void isp1020_disable_irqs(struct Scsi_Host *);
diff -ur linux-2.1.17.orig/drivers/scsi/wd7000.c linux/drivers/scsi/wd7000.c
--- linux-2.1.17.orig/drivers/scsi/wd7000.c Mon Sep 16 20:05:18 1996
+++ linux/drivers/scsi/wd7000.c Mon Dec 23 14:04:54 1996
@@ -215,7 +215,7 @@
* Note that if SA_INTERRUPT is not used, wd7000_intr_handle must be
* changed to pick up the IRQ level correctly.
*/
-Adapter *irq2host[16] = {NULL}; /* Possible IRQs are 0-15 */
+static Adapter *irq2host[16] = {NULL}; /* Possible IRQs are 0-15 */

/*
* (linear) base address for ROM BIOS

kd_mksound is multiply defined in drivers/char/tty_io.o,
drivers/char/console.o, drivers/char/vt.o, drivers/char/vc_screen.o,
drivers/char/selection.o, drivers/char/keyboard.o and
drivers/char/vga.o

A side effect of declaring kd_mksound as a pointer in
drivers/char/vt_kern.h. Patch :-

diff -ur linux-2.1.17.orig/drivers/char/vt_kern.h linux/drivers/char/vt_kern.h
--- linux-2.1.17.orig/drivers/char/vt_kern.h Sun Mar 24 22:35:08 1996
+++ linux/drivers/char/vt_kern.h Mon Dec 23 14:24:56 1996
@@ -30,7 +30,7 @@
struct wait_queue *paste_wait;
} *vt_cons[MAX_NR_CONSOLES];

-void (*kd_mksound)(unsigned int hz, unsigned int ticks);
+extern void (*kd_mksound)(unsigned int hz, unsigned int ticks);
int vc_allocate(unsigned int console);
int vc_cons_allocated(unsigned int console);
int vc_resize(unsigned long lines, unsigned long cols);
Cannot resolve reference to nr_proto_ops from net/netrom/nr_dev.o

Bit of a strange one. nr_proto_ops is defined as static in
net/netrom/af_netrom.c, it is not X()ported but it is referred to
by net/netrom/nr_dev.c. Cannot see how it is resolved, perhaps it
is not.

For the rest, see ftp://ftp.ocs.com.au/pub/extra_externals-2.1.17.gz


\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.066 / U:1.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site