Skip to contentSkip to conversation

gcc4 fix for sn_serial.c

PATCH In review Jesse Barnes 3 participants 5 messages Mar 14, 2005 – Apr 26, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc4 fix for sn_serial.c

The sal_console and sal_console_uart structures have a circular relationship since they both initialize member fields to pointers of one another. The current code forward declares sal_console_uart as extern so that sal_console can take its address, but gcc4 complains about this since the real definition of sal_console_uart is marked 'static'. This patch just removes the static qualifier from sal_console_uart to avoid the inconsistency. Does it look ok to you, Pat?

Thanks,
Jesse

===== drivers/serial/sn_console.c 1.12 vs edited =====

drivers/serial/sn_console.c +1 -1
@@ -801,7 +801,7 @@
 
 #define SAL_CONSOLE	&sal_console
 
-static struct uart_driver sal_console_uart = {
+struct uart_driver sal_console_uart = {
 	.owner = THIS_MODULE,
 	.driver_name = "sn_console",
 	.dev_name = DEVICE_NAME,
#1 lore raw
Quoted 12 lines · Jesse Barnes

The sal_console and sal_console_uart structures have a circular relationship since they both initialize member fields to pointers of one another. The current code forward declares sal_console_uart as extern so that sal_console can take its address, but gcc4 complains about this since the real definition of sal_console_uart is marked 'static'. This patch just removes the static qualifier from sal_console_uart to avoid the inconsistency. Does it look ok to you, Pat?
...
===== drivers/serial/sn_console.c 1.12 vs edited =====

drivers/serial/sn_console.c line 807

Quoted 8 lines
drivers/serial/sn_console.c +1 -1
@@ -801,7 +801,7 @@
 
 #define SAL_CONSOLE	&sal_console
 
-static struct uart_driver sal_console_uart = {
+struct uart_driver sal_console_uart = {
 	.owner = THIS_MODULE,
 	.driver_name = "sn_console",
 	.dev_name = DEVICE_NAME,

Why can't you solve this without making sal_console_uart global?

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#2 lore raw
Quoted 7 lines · Adrian Bunk

drivers/serial/sn_console.c line 807

Quoted 5 lines
drivers/serial/sn_console.c +1 -1
-static struct uart_driver sal_console_uart = {
+struct uart_driver sal_console_uart = {
  .owner = THIS_MODULE,
  .driver_name = "sn_console",
  .dev_name = DEVICE_NAME,

Why can't you solve this without making sal_console_uart global?

I think that would mean moving some of the structure initializaiton into an init function somewhere. But the compiler knows the addrs of these structures, so there must be a better way to do it, I just don't know it. Any suggestions?

Jesse

#3 lore raw
Quoted 11 lines · Jesse Barnes
Quoted 7 lines · Adrian Bunk

Review

Quoted 5 lines
(quoted diff) +1 -1
-static struct uart_driver sal_console_uart = {
+struct uart_driver sal_console_uart = {
  .owner = THIS_MODULE,
  .driver_name = "sn_console",
  .dev_name = DEVICE_NAME,

Why can't you solve this without making sal_console_uart global?

I think that would mean moving some of the structure initializaiton into an init function somewhere.

Just make the tentative definition static.

drivers/serial/sn_console.c renamed from drivers/serial/sn_console.c.~1~ +1 -1
@@ -821,7 +821,7 @@ static void __init sn_sal_switch_to_inte
 
 static void sn_sal_console_write(struct console *, const char *, unsigned);
 static int __init sn_sal_console_setup(struct console *, char *);
-extern struct uart_driver sal_console_uart;
+static struct uart_driver sal_console_uart;
 extern struct tty_driver *uart_console_device(struct console *, int *);
 
 static struct console sal_console = {

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#4 lore raw
Quoted 11 lines · Andreas Schwab
Quoted 9 lines · Jesse Barnes
Quoted 7 lines · Adrian Bunk

Review

Quoted 5 lines
(quoted diff) +1 -1
-static struct uart_driver sal_console_uart = {
+struct uart_driver sal_console_uart = {
  .owner = THIS_MODULE,
  .driver_name = "sn_console",
  .dev_name = DEVICE_NAME,

Why can't you solve this without making sal_console_uart global?

Quoted 4 lines
Quoted 2 lines

I think that would mean moving some of the structure initializaiton into an init function somewhere.

Just make the tentative definition static.

And this is the complete patch:

Make sal_console_uart static again.

drivers/serial/sn_console.c renamed from drivers/serial/sn_console.c.~1~ +2 -2
@@ -787,7 +787,7 @@ static void __init sn_sal_switch_to_inte
 
 static void sn_sal_console_write(struct console *, const char *, unsigned);
 static int __init sn_sal_console_setup(struct console *, char *);
-extern struct uart_driver sal_console_uart;
+static struct uart_driver sal_console_uart;
 extern struct tty_driver *uart_console_device(struct console *, int *);
 
 static struct console sal_console = {
@@ -801,7 +801,7 @@ static struct console sal_console = {
 
 #define SAL_CONSOLE	&sal_console
 
-struct uart_driver sal_console_uart = {
+static struct uart_driver sal_console_uart = {
 	.owner = THIS_MODULE,
 	.driver_name = "sn_console",
 	.dev_name = DEVICE_NAME,

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."