Skip to contentSkip to conversation

struct should not be named same way as function in sony-laptop

PATCH Pavel Machek 2 participants 3 messages Jan 3, 2008 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Naming struct and function by same name is evil. Rename the struct.

drivers/misc/sony-laptop.c +6 -6
index b0f6803..31ce39d 100644
@@ -1180,7 +1180,7 @@ struct sony_pic_ioport {
 	struct list_head	list;
 };
 
-struct sony_pic_irq {
+struct sony_pic_irqdesc {
 	struct acpi_resource_irq	irq;
 	struct list_head		list;
 };
@@ -1192,7 +1192,7 @@ struct sony_pic_dev {
 	u8			bluetooth_power;
 	u8			wwan_power;
 	struct acpi_device	*acpi_dev;
-	struct sony_pic_irq	*cur_irq;
+	struct sony_pic_irqdesc	*cur_irq;
 	struct sony_pic_ioport	*cur_ioport;
 	struct list_head	interrupts;
 	struct list_head	ioports;
@@ -2094,7 +2094,7 @@ sony_pic_read_possible_resource(struct a
 	case ACPI_RESOURCE_TYPE_IRQ:
 		{
 			struct acpi_resource_irq *p = &resource->data.irq;
-			struct sony_pic_irq *interrupt = NULL;
+			struct sony_pic_irqdesc *interrupt = NULL;
 			if (!p || !p->interrupt_count) {
 				/*
 				 * IRQ descriptors may have no IRQ# bits set,
@@ -2218,7 +2218,7 @@ static int sony_pic_disable(struct acpi_
  *  Call _SRS to set current resources
  */
 static int sony_pic_enable(struct acpi_device *device,
-		struct sony_pic_ioport *ioport, struct sony_pic_irq *irq)
+		struct sony_pic_ioport *ioport, struct sony_pic_irqdesc *irq)
 {
 	acpi_status status;
 	int result = 0;
@@ -2381,7 +2381,7 @@ found:
 static int sony_pic_remove(struct acpi_device *device, int type)
 {
 	struct sony_pic_ioport *io, *tmp_io;
-	struct sony_pic_irq *irq, *tmp_irq;
+	struct sony_pic_irqdesc *irq, *tmp_irq;
 
 	if (sony_pic_disable(device)) {
 		printk(KERN_ERR DRV_PFX "Couldn't disable device.\n");
@@ -2422,7 +2422,7 @@ static int sony_pic_add(struct acpi_devi
 {
 	int result;
 	struct sony_pic_ioport *io, *tmp_io;
-	struct sony_pic_irq *irq, *tmp_irq;
+	struct sony_pic_irqdesc *irq, *tmp_irq;
 
 	printk(KERN_INFO DRV_PFX "%s v%s.\n",
 		SONY_PIC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw
Quoted 1 line · Pavel Machek

Naming struct and function by same name is evil. Rename the struct.

Um... why? It's not even particulary bad style per se... Occurs less frequently than things like

	struct foo *foo;

but nothing inherently terrible and not likely to cause any kind of confusion.

#2 lore raw
Quoted 8 lines · Al Viro
Quoted 1 line · Pavel Machek

Naming struct and function by same name is evil. Rename the struct.

Um... why? It's not even particulary bad style per se... Occurs less frequently than things like

	struct foo *foo;

but nothing inherently terrible and not likely to cause any kind of confusion.

Well, it confused me a lot in this particular case...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html