These fail cppcheck on ppc64 anyway. --- pyanaconda/isys/Makefile.am | 2 +- pyanaconda/isys/devices.c | 240 -------------------------------------------- pyanaconda/isys/devices.h | 42 -------- 3 files changed, 1 insertion(+), 283 deletions(-) delete mode 100644 pyanaconda/isys/devices.c delete mode 100644 pyanaconda/isys/devices.h
diff --git a/pyanaconda/isys/Makefile.am b/pyanaconda/isys/Makefile.am index f04429d..8a26aa7 100644 --- a/pyanaconda/isys/Makefile.am +++ b/pyanaconda/isys/Makefile.am @@ -19,7 +19,7 @@
pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
-ISYS_SRCS = devices.c isofs.c +ISYS_SRCS = isofs.c
dist_noinst_HEADERS = $(srcdir)/*.h
diff --git a/pyanaconda/isys/devices.c b/pyanaconda/isys/devices.c deleted file mode 100644 index 1f7a6c1..0000000 --- a/pyanaconda/isys/devices.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * devices.c - various hardware probing functionality - * - * Copyright (C) 2007 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - * Author(s): Bill Nottingham notting@redhat.com - */ - -#include "config.h" - -#include <ctype.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <limits.h> -#include <net/if_arp.h> - -#include "devices.h" - -/* for 'disks', to filter out weird stuff */ -#define MINIMUM_INTERESTING_SIZE 32*1024 /* 32MB */ - -/* from genhd.h, kernel side */ -#define GENHD_FL_REMOVABLE 1 -#define GENHD_FL_DRIVERFS 2 -#define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 -#define GENHD_FL_CD 8 -#define GENHD_FL_UP 16 -#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 -#define GENHD_FL_FAIL 64 - - -struct device **getDevices(enum deviceType type) { - struct device **ret = NULL; - struct device **tmpret; - struct device *new; - int numdevices = 0; - - if (type & (DEVICE_DISK | DEVICE_CDROM)) { - DIR *dir; - struct dirent *ent; - - dir = opendir("/sys/block"); - - if (!dir) goto storagedone; - - while ((ent = readdir(dir))) { - char path[64]; - char buf[64]; - int fd, caps, devtype; - - snprintf(path, 64, "/sys/block/%s/capability", ent->d_name); - fd = open(path, O_RDONLY); - if (fd == -1) - continue; - if (read(fd, buf, 63) <= 0) { - close(fd); - continue; - } - - close(fd); - errno = 0; - caps = strtol(buf, NULL, 16); - - if ((errno == ERANGE && (caps == LONG_MIN || caps == LONG_MAX)) || - (errno != 0 && caps == 0)) { - return NULL; - } - - if (caps & GENHD_FL_CD) - devtype = DEVICE_CDROM; - else - devtype = DEVICE_DISK; - if (!(devtype & type)) - continue; - - if (devtype == DEVICE_DISK && !(caps & GENHD_FL_REMOVABLE)) { - long long int size; - - snprintf(path, 64, "/sys/block/%s/size", ent->d_name); - fd = open(path, O_RDONLY); - - if (fd == -1) - continue; - if (read(fd, buf, 63) <= 0) { - close(fd); - continue; - } - - close(fd); - errno = 0; - size = strtoll(buf, NULL, 10); - - if ((errno == ERANGE && (size == LLONG_MIN || - size == LLONG_MAX)) || - (errno != 0 && size == 0)) { - return NULL; - } - - if (size < MINIMUM_INTERESTING_SIZE) - continue; - } - - new = calloc(1, sizeof(struct device)); - new->device = strdup(ent->d_name); - /* FIXME */ - if (asprintf(&new->description, "Storage device %s", - new->device) == -1) { - fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__, - strerror(errno)); - fflush(stderr); - abort(); - } - new->type = devtype; - if (caps & GENHD_FL_REMOVABLE) { - new->priv.removable = 1; - } - tmpret = realloc(ret, (numdevices+2) * sizeof(struct device)); - if (NULL == tmpret) - { - free(ret); - return NULL; - } - ret = tmpret; - ret[numdevices] = new; - ret[numdevices+1] = NULL; - numdevices++; - } - - closedir(dir); - } -storagedone: - - if (type & DEVICE_NETWORK) { - DIR *dir; - struct dirent *ent; - - dir = opendir("/sys/class/net"); - - if (!dir) goto netdone; - - while ((ent = readdir(dir))) { - char path[64]; - int fd, type; - char buf[64]; - - snprintf(path, 64, "/sys/class/net/%s/type", ent->d_name); - fd = open(path, O_RDONLY); - if (fd == -1) - continue; - if (read(fd, buf, 63) <= 0) { - close(fd); - continue; - } - - close(fd); - errno = 0; - type = strtol(buf, NULL, 10); - - if ((errno == ERANGE && (type == LONG_MIN || type == LONG_MAX)) || - (errno != 0 && type == 0)) { - return NULL; - } - - /* S390 channel-to-channnel devices have type 256 */ - if ((type != ARPHRD_ETHER) && - !((type == ARPHRD_SLIP) && !strncmp(ent->d_name, "ctc", 3))) - continue; - - new = calloc(1, sizeof(struct device)); - new->device = strdup(ent->d_name); - /* FIXME */ - snprintf(path, 64, "/sys/class/net/%s/address", ent->d_name); - fd = open(path, O_RDONLY); - if (fd != -1) { - memset(buf, '\0', 64); - if (read(fd, buf, 63) > 0) { - int i; - for (i = (strlen(buf)-1); isspace(buf[i]); i--) - buf[i] = '\0'; - new->priv.hwaddr = strdup(buf); - } - close(fd); - } - - if (new->priv.hwaddr) { - if (asprintf(&new->description, "Ethernet device %s - %s", - new->device, new->priv.hwaddr) == -1) { - fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__, - strerror(errno)); - fflush(stderr); - abort(); - } - } else { - if (asprintf(&new->description, "Ethernet device %s", - new->device) == -1) { - fprintf(stderr, "%s: %d: %s\n", __func__, __LINE__, - strerror(errno)); - fflush(stderr); - abort(); - } - } - - tmpret = realloc(ret, (numdevices+2) * sizeof(struct device)); - if (NULL == tmpret) - { - free(ret); - return NULL; - } - ret = tmpret; - ret[numdevices] = new; - ret[numdevices+1] = NULL; - numdevices++; - } - - closedir(dir); - } -netdone: - return ret; -} - diff --git a/pyanaconda/isys/devices.h b/pyanaconda/isys/devices.h deleted file mode 100644 index 9428a77..0000000 --- a/pyanaconda/isys/devices.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * devices.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef DEVICES_H -#define DEVICES_H - -enum deviceType { - DEVICE_ANY = ~0, - DEVICE_NETWORK = (1 << 0), - DEVICE_DISK = (1 << 1), - DEVICE_CDROM = (1 << 2) -}; - -struct device { - char *device; - char *description; - enum deviceType type; - union { - char *hwaddr; - int removable; - } priv; -}; - -struct device **getDevices(enum deviceType type); - -#endif
On 02/06/2014 04:34 PM, Chris Lumens wrote:
These fail cppcheck on ppc64 anyway.
pyanaconda/isys/Makefile.am | 2 +- pyanaconda/isys/devices.c | 240 -------------------------------------------- pyanaconda/isys/devices.h | 42 -------- 3 files changed, 1 insertion(+), 283 deletions(-) delete mode 100644 pyanaconda/isys/devices.c delete mode 100644 pyanaconda/isys/devices.h
Ack.
anaconda-patches@lists.fedorahosted.org