Skip to contentSkip to conversation

Cleanup event.c and warn about bug

PATCH Pavel Machek 1 participant 1 message Oct 4, 2004 ACPI

lore
Share & tools
lore
#0 lore raw

Hi!

event.c contains some completely unneccessary gotos, and is not reentrant as it needs to be. Fix gotos, warn about reentrancy. Please apply,
Pavel

drivers/acpi/event.c +7 -12
Index: linux/drivers/acpi/event.c
===================================================================
@@ -24,19 +24,14 @@
 static int
 acpi_system_open_event(struct inode *inode, struct file *file)
 {
+	int retval = 0;
 	spin_lock_irq (&acpi_system_event_lock);
-
-	if(event_is_open)
-		goto out_busy;
-
-	event_is_open = 1;
-
-	spin_unlock_irq (&acpi_system_event_lock);
-	return 0;
-
-out_busy:
+	if (event_is_open)
+		retval = -EBUSY;
+	else
+		event_is_open = 1;
 	spin_unlock_irq (&acpi_system_event_lock);
-	return -EBUSY;
+	return retval;
 }
 
 static ssize_t
@@ -48,7 +43,7 @@
 {
 	int			result = 0;
 	struct acpi_bus_event	event;
-	static char		str[ACPI_MAX_STRING];
+	static char		str[ACPI_MAX_STRING];		/* That's joke, right?! What if two threads read from it at the same time? */
 	static int		chars_remaining = 0;
 	static char		*ptr;
 
Signature · 9 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl