Hello.

I went over powertop trying to reduce the number of compilation warnings
it produced and found a few things I think are worthwile to add, I list
them according to how important I percieve each one to be.

readlink.diff:
        First, the size limit is set to sizeof(link), in this context
        link refers to link(2) so this looks plain wrong.
        Secondly len is unused so let's just remove it. Use (void)fun()
        to silence lint if necessary.
 
remove-unused-ifaceup.diff:
        In find_wireless_nic(void) there is some work done to set the
        variable ifaceup but then it is never used. The patch removes
        the setting of the variable but if the intention was to use it
        then an alternative patch is needed.

kill-spurious-semicolon.diff:
        powertop.c starts with a semicolon. Make it stop doing that.

lower-declaration.diff:
        Reduce the scope of a variable to the smallest possible one.
diff --git a/urbnum.c b/urbnum.c
index 5f0f6e1..5bc55dc 100644
--- a/urbnum.c
+++ b/urbnum.c
@@ -136,7 +136,6 @@ void count_usb_urbs(void)
 	char pathname[PATH_MAX];
 	char buffer[4096];
 	struct device_data *dev;
-	int len;
 	char linkto[PATH_MAX];
 
 	memset(linkto, 0, sizeof(linkto));
@@ -152,7 +151,7 @@ void count_usb_urbs(void)
 
 		/* skip usb input devices */
 		sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
-		len = readlink(filename, linkto, sizeof(link) - 1);
+		readlink(filename, linkto, sizeof(linkto) - 1);
 		if (strstr(linkto, "usbhid"))
 			continue;
 
diff --git a/usb.c b/usb.c
index ceaf851..24738d4 100644
--- a/usb.c
+++ b/usb.c
@@ -38,7 +38,6 @@ void activate_usb_autosuspend(void)
 	struct dirent *dirent;
 	FILE *file;
 	char filename[PATH_MAX];
-	int len;
 	char linkto[PATH_MAX];
 
 	dir = opendir("/sys/bus/usb/devices");
@@ -51,7 +50,7 @@ void activate_usb_autosuspend(void)
 
 		/* skip usb input devices */
 		sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
-		len = readlink(filename, linkto, sizeof(link) - 1);
+		readlink(filename, linkto, sizeof(linkto) - 1);
 		if (strstr(linkto, "usbhid"))
 			continue;
 
@@ -73,7 +72,6 @@ void suggest_usb_autosuspend(void)
 	FILE *file;
 	char filename[PATH_MAX];
 	char line[1024];
-	int len;
 	char linkto[PATH_MAX];
 	int need_hint = 0;
 
@@ -89,7 +87,7 @@ void suggest_usb_autosuspend(void)
 
 		/* skip usb input devices */
 		sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
-		len = readlink(filename, linkto, sizeof(link) - 1);
+		readlink(filename, linkto, sizeof(linkto) - 1);
 		if (strstr(linkto, "usbhid"))
 			continue;
 
diff --git a/wireless.c b/wireless.c
index 3a40a35..52481ee 100644
--- a/wireless.c
+++ b/wireless.c
@@ -203,7 +203,6 @@ void find_wireless_nic(void)
 	struct ifreq ifr;
 	struct ethtool_value ethtool;
 	struct ethtool_drvinfo driver;
-	int ifaceup = 0;
 	int ret;
 
 	if (found++)
@@ -255,10 +254,6 @@ void find_wireless_nic(void)
 		return;
 	}
 
-	ifaceup = 0;
-	if (ifr.ifr_flags & (IFF_UP | IFF_RUNNING))
-		ifaceup = 1;
-
 	memset(&driver, 0, sizeof(driver));
 	driver.cmd = ETHTOOL_GDRVINFO;
         ifr.ifr_data = (void*) &driver;
diff --git a/powertop.c b/powertop.c
index 30d3b0e..dcfb9eb 100644
--- a/powertop.c
+++ b/powertop.c
@@ -1,4 +1,4 @@
-;/*
+/*
  * Copyright 2007, Intel Corporation
  *
  * This file is part of PowerTOP
diff --git a/misctips.c b/misctips.c
index eaa5288..052ffef 100644
--- a/misctips.c
+++ b/misctips.c
@@ -236,12 +236,11 @@ void suggest_powersched(void)
 		return;
 	while (!feof(file)) {
 		memset(buffer, 0, 1024);
-		char *c;
 		if (!fgets(buffer, 1023, file))
 			break;
 		if (strstr(buffer, "cpu cores")) {
-			c = strchr(buffer, ':');
-			if (!c) 
+			char *c = strchr(buffer, ':');
+			if (!c)
 				continue;
 			c++;
 			if (strtoll(c, NULL, 10) >= cpu)
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power

Reply via email to