[PATCH] remove unused variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There were two kinds of unused but set variables:
 - the really pointless ones
 - the ones whose only purpose was to silence the warnings
    about ignoring the return values from functions declared with
    __attribute__((__warn_unused_result__))
Since gcc 4.5 the warnings can be disabled using -Wno-unused-result,
so the variables are no longer necessary.
Then -Wno-unused-but-set-variable is an overkill, so drop it.
---
 configure.ac                 |    2 +-
 gptsync/gptsync.c            |    5 ++---
 gptsync/os_unix.c            |    4 +---
 loader/driverdisk.c          |    4 ++--
 loader/driverselect.c        |    8 --------
 loader/fwloader.c            |   18 ++++++++----------
 loader/init.c                |   28 ++++++++++++----------------
 loader/loader.c              |   16 ++++++++--------
 loader/moduleinfo.c          |    2 --
 loader/undomounts.c          |    6 +-----
 pyanaconda/isys/auditd.c     |    7 +++----
 pyanaconda/isys/eddsupport.c |    7 +++----
 pyanaconda/xutils.c          |    4 +---
 utils/mapshdr.c              |    6 +++---
 14 files changed, 45 insertions(+), 72 deletions(-)

diff --git a/configure.ac b/configure.ac
index 50c4c21..2653fd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,7 +187,7 @@ fi
 
 # GCC likes to bomb out on some ridiculous warnings.  Add your favorites
 # here.
-SHUT_UP_GCC="-Wno-unused-but-set-variable"
+SHUT_UP_GCC="-Wno-unused-result"
 
 # Add remaining compiler flags we want to use
 CFLAGS="$CFLAGS -Wall -Werror $SHUT_UP_GCC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
diff --git a/gptsync/gptsync.c b/gptsync/gptsync.c
index 3ad26bf..94c37eb 100644
--- a/gptsync/gptsync.c
+++ b/gptsync/gptsync.c
@@ -222,7 +222,6 @@ static UINTN analyze(VOID)
     UINTN   i, k, iter, count_active, detected_parttype;
     CHARN   *fsname;
     UINT64  min_start_lba;
-    UINTN   status;
     BOOLEAN have_esp;
     
     new_mbr_part_count = 0;
@@ -237,7 +236,7 @@ static UINTN analyze(VOID)
         gpt_parts[i].mbr_type = gpt_parts[i].gpt_parttype->mbr_type;
         if (gpt_parts[i].gpt_parttype->kind == GPT_KIND_BASIC_DATA) {
             // Basic Data: need to look at data in the partition
-            status = detect_mbrtype_fs(gpt_parts[i].start_lba, &detected_parttype, &fsname);
+            detect_mbrtype_fs(gpt_parts[i].start_lba, &detected_parttype, &fsname);
             if (detected_parttype)
                 gpt_parts[i].mbr_type = detected_parttype;
             else
@@ -245,7 +244,7 @@ static UINTN analyze(VOID)
         } else if (gpt_parts[i].mbr_type == 0xef) {
             // EFI System Partition: GNU parted can put this on any partition,
             // need to detect file systems
-            status = detect_mbrtype_fs(gpt_parts[i].start_lba, &detected_parttype, &fsname);
+            detect_mbrtype_fs(gpt_parts[i].start_lba, &detected_parttype, &fsname);
             if (!have_esp && (detected_parttype == 0x01 || detected_parttype == 0x0e || detected_parttype == 0x0c))
                 ;  // seems to be a legitimate ESP, don't change
             else if (detected_parttype)
diff --git a/gptsync/os_unix.c b/gptsync/os_unix.c
index b43685b..c034031 100644
--- a/gptsync/os_unix.c
+++ b/gptsync/os_unix.c
@@ -185,7 +185,6 @@ int main(int argc, char *argv[])
     char        *filename;
     struct stat sb;
     int         filekind;
-    UINT64      filesize;
     char        *reason;
     int         status;
     
@@ -207,10 +206,9 @@ int main(int argc, char *argv[])
     }
     
     filekind = 0;
-    filesize = 0;
     reason = NULL;
     if (S_ISREG(sb.st_mode))
-        filesize = sb.st_size;
+        ;
     else if (S_ISBLK(sb.st_mode))
         filekind = 1;
     else if (S_ISCHR(sb.st_mode))
diff --git a/loader/driverdisk.c b/loader/driverdisk.c
index f78b565..506ac32 100644
--- a/loader/driverdisk.c
+++ b/loader/driverdisk.c
@@ -218,7 +218,7 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
     struct moduleBallLocation * location;
     struct stat sb;
     static int disknum = 0;
-    int rc, fd, ret;
+    int rc, fd;
     char *kernelver;
     struct utsname unamedata;
 
@@ -232,7 +232,7 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
     title = malloc(sb.st_size + 1);
 
     fd = open(file, O_RDONLY);
-    ret = read(fd, title, sb.st_size);
+    read(fd, title, sb.st_size);
     if (title[sb.st_size - 1] == '\n')
         sb.st_size--;
     title[sb.st_size] = '\0';
diff --git a/loader/driverselect.c b/loader/driverselect.c
index a2332d7..a563bad 100644
--- a/loader/driverselect.c
+++ b/loader/driverselect.c
@@ -122,7 +122,6 @@ static int getManualModuleArgs(struct moduleInfo * mod, gchar *** moduleArgs) {
 
 int chooseManualDriver(int class, struct loaderData_s *loaderData) {
     int i, numSorted, num = 0, done = 0;
-    enum driverMajor type;
     struct sortModuleList * sortedOrder;
     char giveArgs = ' ';
     gchar **moduleArgs = NULL;
@@ -132,13 +131,6 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
     newtGrid grid, buttons;
     struct newtExitStruct es;
 
-    if (class == DEVICE_NETWORK)
-        type = DRIVER_NET;
-    else if (class == DEVICE_DISK || class == DEVICE_CDROM)
-        type = DRIVER_SCSI;
-    else
-        type = DRIVER_ANY;
-
     do {
         sortedOrder = malloc(sizeof(*sortedOrder) * modInfo->numModules);
         numSorted = 0;
diff --git a/loader/fwloader.c b/loader/fwloader.c
index e6ed4c7..77b4aa3 100644
--- a/loader/fwloader.c
+++ b/loader/fwloader.c
@@ -81,7 +81,7 @@ static inline int set_fd_coe(int fd, int enable)
 
 static int open_uevent_socket(struct fw_loader *fwl)
 {
-    int fd, rc;
+    int fd;
     struct sockaddr_nl sa;
 
     fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
@@ -103,14 +103,14 @@ static int open_uevent_socket(struct fw_loader *fwl)
 
     fd = open("/proc/sys/kernel/hotplug", O_RDWR);
     if (fd >= 0) {
-        rc = ftruncate(fd, 0);
-        rc = write(fd, "\n", 1);
+        ftruncate(fd, 0);
+        write(fd, "\n", 1);
         close(fd);
     }
 
     fd = open("/sys/class/firmware/timeout", O_RDWR);
     if (fd >= 0) {
-        rc = write(fd, "10", 2);
+        write(fd, "10", 2);
         close(fd);
     }
 
@@ -129,7 +129,6 @@ static void kill_hotplug_signal(int signum)
 static int daemonize(struct fw_loader *fwl)
 {
     int fd;
-    int rc;
 
     signal(SIGTERM, kill_hotplug_signal);
     signal(SIGSEGV, loaderSegvHandler);
@@ -143,11 +142,11 @@ static int daemonize(struct fw_loader *fwl)
     sigemptyset(&fwl->sigmask);
 
     prctl(PR_SET_NAME, "hotplug", 0, 0, 0);
-    rc = chdir("/");
+    chdir("/");
 
     fd = open("/proc/self/oom_adj", O_RDWR);
     if (fd >= 0) {
-        rc = write(fd, "-17", 3);
+        write(fd, "-17", 3);
         close(fd);
     }
 
@@ -343,7 +342,6 @@ fetcher(char *inpath, int outfd)
     size_t inlen;
     int count;
     int en = 0;
-    int rc;
 
     errno = 0;
     if (access(inpath, F_OK))
@@ -353,8 +351,8 @@ fetcher(char *inpath, int outfd)
         goto out;
 
     lseek(outfd, 0, SEEK_SET);
-    rc = ftruncate(outfd, 0);
-    rc = ftruncate(outfd, inlen);
+    ftruncate(outfd, 0);
+    ftruncate(outfd, inlen);
 
     count = 0;
     while (count < inlen) {
diff --git a/loader/init.c b/loader/init.c
index fb18113..51ab2a2 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -125,8 +125,7 @@ static void doExit(int result)
 }
 
 static void printstr(char * string) {
-    int ret;
-    ret = write(1, string, strlen(string));
+    write(1, string, strlen(string));
 }
 
 static void fatal_error(int usePerror) {
@@ -141,7 +140,6 @@ static void fatal_error(int usePerror) {
 /* sets up and launches syslog */
 static void startSyslog(void) {
     int conf_fd;
-    int ret;
     gchar *addr = NULL, *virtiolog = NULL;
     const char *forward_tcp = "*.* @@";
     const char *forward_format_tcp = "\n";
@@ -158,14 +156,14 @@ static void startSyslog(void) {
             sleep(5);
         } else {
             if (addr != NULL) {
-                ret = write(conf_fd, forward_tcp, strlen(forward_tcp));
-                ret = write(conf_fd, addr, strlen(addr));
-                ret = write(conf_fd, forward_format_tcp, strlen(forward_format_tcp));
+                write(conf_fd, forward_tcp, strlen(forward_tcp));
+                write(conf_fd, addr, strlen(addr));
+                write(conf_fd, forward_format_tcp, strlen(forward_format_tcp));
             }
             if (virtiolog != NULL) {
-                ret = write(conf_fd, forward_virtio, strlen(forward_virtio));
-                ret = write(conf_fd, virtiolog, strlen(virtiolog));
-                ret = write(conf_fd, forward_format_virtio, strlen(forward_format_virtio));
+                write(conf_fd, forward_virtio, strlen(forward_virtio));
+                write(conf_fd, virtiolog, strlen(virtiolog));
+                write(conf_fd, forward_format_virtio, strlen(forward_format_virtio));
             }
             close(conf_fd);
         }
@@ -386,7 +384,7 @@ static int onQEMU(void)
 }
 
 static int getInitPid(void) {
-    int fd = 0, pid = -1, ret;
+    int fd = 0, pid = -1;
     char * buf = calloc(1, 10);
 
     fd = open("/var/run/init.pid", O_RDONLY);
@@ -394,9 +392,9 @@ static int getInitPid(void) {
         fprintf(stderr, "Unable to find pid of init!!!\n");
         return -1;
     }
-    ret = read(fd, buf, 9);
+    read(fd, buf, 9);
     close(fd);
-    ret = sscanf(buf, "%d", &pid);
+    sscanf(buf, "%d", &pid);
     return pid;
 }
 
@@ -794,10 +792,9 @@ int main(int argc, char **argv) {
     /* write out a pid file */
     if ((fd = open("/var/run/init.pid", O_WRONLY|O_CREAT, 0644)) > 0) {
         char * buf = malloc(10);
-        int ret;
 
         snprintf(buf, 9, "%d", getpid());
-        ret = write(fd, buf, strlen(buf));
+        write(fd, buf, strlen(buf));
         close(fd);
         free(buf);
     } else {
@@ -866,9 +863,8 @@ int main(int argc, char **argv) {
            ctrl-alt-del handler */
         if (count == strlen(buf) &&
             (fd = open("/proc/sys/kernel/ctrl-alt-del", O_WRONLY)) != -1) {
-            int ret;
 
-            ret = write(fd, "0", 1);
+            write(fd, "0", 1);
             close(fd);
         }
     }
diff --git a/loader/loader.c b/loader/loader.c
index 08b8c3c..37b7c78 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2319,11 +2319,11 @@ int main(int argc, char ** argv) {
             if (strncmp(loaderData.instRepo, "ftp:", 4)) {
                 *argptr++ = loaderData.instRepo;
             } else {
-                int fd, ret;
+                int fd;
 
                 fd = open("/tmp/ftp-repo", O_CREAT | O_TRUNC | O_RDWR, 0600);
-                ret = write(fd, loaderData.instRepo, strlen(loaderData.instRepo));
-                ret = write(fd, "\r", 1);
+                write(fd, loaderData.instRepo, strlen(loaderData.instRepo));
+                write(fd, "\r", 1);
                 close(fd);
                 *argptr++ = "@/tmp/ftp-repo";
             }
@@ -2339,15 +2339,15 @@ int main(int argc, char ** argv) {
             *argptr++ = strdup(loaderData.proxy);
 
             if (loaderData.proxyUser && strcmp(loaderData.proxyUser, "")) {
-                int fd, ret;
+                int fd;
 
                 fd = open("/tmp/proxy", O_CREAT|O_TRUNC|O_RDWR, 0600);
-                ret = write(fd, loaderData.proxyUser, strlen(loaderData.proxyUser));
-                ret = write(fd, "\r\n", 2);
+                write(fd, loaderData.proxyUser, strlen(loaderData.proxyUser));
+                write(fd, "\r\n", 2);
 
                 if (loaderData.proxyPassword && strcmp(loaderData.proxyPassword, "")) {
-                    ret = write(fd, loaderData.proxyPassword, strlen(loaderData.proxyPassword));
-                    ret = write(fd, "\r\n", 2);
+                    write(fd, loaderData.proxyPassword, strlen(loaderData.proxyPassword));
+                    write(fd, "\r\n", 2);
                 }
 
                 close(fd);
diff --git a/loader/moduleinfo.c b/loader/moduleinfo.c
index 2e0ab77..61d1681 100644
--- a/loader/moduleinfo.c
+++ b/loader/moduleinfo.c
@@ -93,7 +93,6 @@ int readModuleInfo(const char * filename, moduleInfoSet mis,
     int fd, isIndented;
     char * buf, * start, * next = NULL, * chptr;
     struct stat sb;
-    char oldch;
     struct moduleInfo * nextModule;
     int modulesAlloced;
     int i;
@@ -223,7 +222,6 @@ int readModuleInfo(const char * filename, moduleInfoSet mis,
                 chptr = start;
                 while (!isspace(*chptr) && *chptr) chptr++;
                 if (*chptr) {
-                    oldch = *chptr;
                     *chptr = '\0';
                     nextModule->args[nextModule->numArgs].arg = strdup(start);
 
diff --git a/loader/undomounts.c b/loader/undomounts.c
index 1ed5beb..5445a18 100644
--- a/loader/undomounts.c
+++ b/loader/undomounts.c
@@ -52,9 +52,7 @@ struct unmountInfo {
 void undoLoop(struct unmountInfo * fs, int numFs, int this);
 
 static void printstr(char * string) {
-    int ret;
-    
-    ret = write(1, string, strlen(string));
+    write(1, string, strlen(string));
 }
 
 void undoMount(struct unmountInfo * fs, int numFs, int this) {
@@ -126,7 +124,6 @@ void unmountFilesystems(void) {
     int numFilesystems = 0;
     int i;
     struct loop_info li;
-    char * device;
     struct stat sb;
 
     fd = open("/proc/mounts", O_RDONLY, 0);
@@ -144,7 +141,6 @@ void unmountFilesystems(void) {
 
     chptr = buf;
     while (*chptr) {
-	device = chptr;
 	while (*chptr != ' ') chptr++;
 	*chptr++ = '\0';
 	start = chptr;
diff --git a/pyanaconda/isys/auditd.c b/pyanaconda/isys/auditd.c
index 2ca6d04..0d72dd9 100644
--- a/pyanaconda/isys/auditd.c
+++ b/pyanaconda/isys/auditd.c
@@ -95,20 +95,19 @@ int audit_daemonize(void) {
 #ifdef USESELINUX
     int fd;
     pid_t child;
-    int i;
     if ((child = fork()) > 0)
         return 0;
 
 #ifndef STANDALONE 
-    for (i = 0; i < getdtablesize(); i++)
-        close(i);
+    for (fd = 0; fd < getdtablesize(); fd++)
+        close(fd);
     signal(SIGTTOU, SIG_IGN);
     signal(SIGTTIN, SIG_IGN);
     signal(SIGTSTP, SIG_IGN);
 #endif /* !defined(STANDALONE) */
 
     if ((fd = open("/proc/self/oom_adj", O_RDWR)) >= 0) {
-        i = write(fd, "-17", 3);
+        write(fd, "-17", 3);
         close(fd);
     }
     fd = audit_open();
diff --git a/pyanaconda/isys/eddsupport.c b/pyanaconda/isys/eddsupport.c
index c50278e..1585c84 100644
--- a/pyanaconda/isys/eddsupport.c
+++ b/pyanaconda/isys/eddsupport.c
@@ -149,7 +149,7 @@ static int mapBiosDisks(struct device** devices,const char *path) {
     char * sigFileName;
     uint32_t mbrSig, biosNum, currentSig;
     struct device **currentDev, **foundDisk;
-    int i, rc, ret, dm_nr, highest_dm;
+    int i, rc, dm_nr, highest_dm;
 
     dirHandle = opendir(path);
     if(!dirHandle){
@@ -173,7 +173,7 @@ static int mapBiosDisks(struct device** devices,const char *path) {
         if(!strncmp(entry->d_name,".",1) || !strncmp(entry->d_name,"..",2)) {
             continue;
         }
-        ret = sscanf((entry->d_name+9), "%x", &biosNum);
+        sscanf((entry->d_name+9), "%x", &biosNum);
         
         sigFileName = malloc(strlen(path) + strlen(entry->d_name) + 20);
         sprintf(sigFileName, "%s/%s/%s", path, entry->d_name, SIG_FILE);
@@ -321,7 +321,6 @@ static int addToHashTable(struct diskMapTable *hashTable,
 char * getBiosDisk(char *biosStr) {
     uint32_t biosNum;
     struct diskMapEntry * disk;
-    int ret;
 
     if (diskHashInit == 0) {
         probeBiosDisks();
@@ -331,7 +330,7 @@ char * getBiosDisk(char *biosStr) {
     if (mbrSigToName == NULL)
         return NULL;
 
-    ret = sscanf(biosStr,"%x",&biosNum);
+    sscanf(biosStr,"%x",&biosNum);
     disk = lookupHashItem(mbrSigToName, biosNum);
     if (disk) return disk->diskname;
 
diff --git a/pyanaconda/xutils.c b/pyanaconda/xutils.c
index 372ffca..6e49798 100644
--- a/pyanaconda/xutils.c
+++ b/pyanaconda/xutils.c
@@ -262,7 +262,5 @@ getXatom(PyObject *s, PyObject *args)
 void 
 initxutils ()
 {
-    PyObject * d;
-
-    d = Py_InitModule ("xutils", xutilsMethods);
+    Py_InitModule ("xutils", xutilsMethods);
 }
diff --git a/utils/mapshdr.c b/utils/mapshdr.c
index 2792ee7..ffba6b2 100644
--- a/utils/mapshdr.c
+++ b/utils/mapshdr.c
@@ -29,13 +29,13 @@
 int main(int argc, char ** argv) {
     struct kmapHeader h;
     struct kmapInfo info;
-    int i, x;
+    int i;
     struct stat sb;
     char * chptr;
 
     h.magic = KMAP_MAGIC;
     h.numEntries = argc - 1;
-    x = write(1, &h, sizeof(h));
+    write(1, &h, sizeof(h));
 
     for (i = 1; i < argc; i++) {
 	if (stat(argv[i], &sb)) {
@@ -52,7 +52,7 @@ int main(int argc, char ** argv) {
 	*chptr = '\0';
 
 	info.size = sb.st_size;
-	x = write(1, &info, sizeof(info));
+	write(1, &info, sizeof(info));
     }
 
     return 0;
-- 
1.7.3.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux