FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Kernel Team

 
 
LinkBack Thread Tools
 
Old 12-17-2009, 01:01 PM
Ales Kozumplik
 
Default Run everything through Lindent.

On 12/16/2009 10:16 PM, Peter Jones wrote:

If we're saying to use a particular coding style, we should at least
try to do something close to it everywhere.


Hi Peter.

I am against this change --- one thing is I don't like the tabs, but
mainly it will make git blame pointless.


If in the end you are allowed to go ahead with this anyway, you might
also run all our Python code through a similar program to give it
four-spaces indentation everywhere.


Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-17-2009, 01:04 PM
Martin Sivak
 
Default Run everything through Lindent.

No way. As I said before, this breaks git blame history. We decided not to do this before and the arguments against it are still valid.

----- "Peter Jones" <pjones@redhat.com> wrote:

> If we're saying to use a particular coding style, we should at least
> try to do something close to it everywhere.
> ---
> isys/auditd.c | 142 +-
> isys/cpio.c | 39 +-
> isys/cpio.h | 37 +-
> isys/dasd.c | 245 ++--
> isys/devices.c | 352 +++--
> isys/devices.h | 22 +-
> isys/eddsupport.c | 451 +++---
> isys/eddsupport.h | 4 +-
> isys/ethtool.c | 151 +-
> isys/ethtool.h | 18 +-
> isys/iface.c | 744 +++++-----
> isys/iface.h | 113 +-
> isys/imount.c | 475 +++---
> isys/imount.h | 2 +-
> isys/isofs.c | 55 +-
> isys/isys.c | 1055 +++++++------
> isys/isys.h | 8 +-
> isys/lang.c | 270 ++--
> isys/lang.h | 14 +-
> isys/linkdetect.c | 203 ++--
> isys/minifind.c | 73 +-
> isys/minifind.h | 14 +-
> isys/str.c | 91 +-
> isys/uncpio.c | 1282 ++++++++-------
> isys/vio.c | 127 +-
> loader/cdinstall.c | 851 ++++++-----
> loader/cdinstall.h | 9 +-
> loader/copy.c | 228 ++--
> loader/copy.h | 4 +-
> loader/devices.h | 120 +-
> loader/dirbrowser.c | 271 ++--
> loader/dirbrowser.h | 4 +-
> loader/driverdisk.c | 1112 +++++++-------
> loader/driverdisk.h | 9 +-
> loader/driverselect.c | 419 +++---
> loader/fwloader.c | 1013 ++++++------
> loader/getparts.c | 265 ++--
> loader/getparts.h | 2 +-
> loader/hardware.c | 273 ++--
> loader/hdinstall.c | 819 +++++-----
> loader/hdinstall.h | 12 +-
> loader/ibft.c | 45 +-
> loader/ibft.h | 17 +-
> loader/init.c | 1423 +++++++++--------
> loader/kbd.c | 207 ++--
> loader/kbd.h | 6 +-
> loader/kickstart.c | 868 ++++++-----
> loader/kickstart.h | 8 +-
> loader/lang.c | 631 ++++----
> loader/lang.h | 15 +-
> loader/loader.c | 4072
> +++++++++++++++++++++++++-----------------------
> loader/loader.h | 84 +-
> loader/loadermisc.c | 201 ++--
> loader/loadermisc.h | 8 +-
> loader/log.c | 177 ++-
> loader/log.h | 8 +-
> loader/mediacheck.c | 148 +-
> loader/method.c | 813 +++++-----
> loader/method.h | 37 +-
> loader/mkctype.c | 71 +-
> loader/moduleinfo.c | 469 +++---
> loader/moduleinfo.h | 52 +-
> loader/modules.c | 677 ++++----
> loader/modules.h | 4 +-
> loader/net.c | 3861
> ++++++++++++++++++++++++----------------------
> loader/net.h | 43 +-
> loader/nfsinstall.c | 1043 +++++++------
> loader/nfsinstall.h | 20 +-
> loader/selinux.c | 29 +-
> loader/shutdown.c | 98 +-
> loader/telnet.c | 344 +++--
> loader/telnet.h | 10 +-
> loader/telnetd.c | 333 ++--
> loader/telnetd.h | 2 +-
> loader/udelay.h | 203 ++--
> loader/undomounts.c | 368 +++--
> loader/urlinstall.c | 700 +++++----
> loader/urlinstall.h | 12 +-
> loader/urls.c | 626 ++++----
> loader/urls.h | 8 +-
> loader/windows.c | 134 +-
> loader/windows.h | 11 +-
> mini-wm.c | 135 +-
> utils/geninitrdsz.c | 46 +-
> utils/mapshdr.c | 58 +-
> utils/mk-s390-cdboot.c | 546 ++++---
> utils/modlist.c | 232 ++--
> utils/readmap.c | 152 +-
> utils/snarffont.c | 113 +-
> xutils.c | 393 +++---
> 90 files changed, 16064 insertions(+), 14895 deletions(-)
>
> diff --git a/isys/auditd.c b/isys/auditd.c
> index f050550..ee90122 100644
> --- a/isys/auditd.c
> +++ b/isys/auditd.c
> @@ -40,93 +40,95 @@ static int done;
>
> static void sig_done(int sig)
> {
> - done = 1;
> + done = 1;
> }
>
> -static void do_auditd(int fd) {
> - struct audit_reply rep;
> - sigset_t sigs;
> - struct sigaction sa;
> - struct pollfd pds = {
> - .events = POLLIN,
> - .revents = 0,
> - .fd = fd,
> - };
> -
> - if (audit_set_pid(fd, getpid(), WAIT_YES) < 0)
> - return;
> -
> - if (audit_set_enabled(fd, 1) < 0)
> - return;
> -
> - memset(&sa, '', sizeof (sa));
> - sa.sa_handler = sig_done;
> - sigaction(SIGTERM, &sa, NULL);
> - sigaction(SIGINT, &sa, NULL);
> - sigaction(SIGHUP, &sa, NULL);
> -
> - sigfillset(&sigs);
> - sigdelset(&sigs, SIGTERM);
> - sigdelset(&sigs, SIGINT);
> - sigdelset(&sigs, SIGHUP);
> -
> - while (1) {
> - int retval;
> -
> - memset(&rep, 0, sizeof(rep));
> -
> - do {
> - retval = ppoll(&pds, 1, NULL, &sigs);
> - } while (retval == -1 && errno == EINTR && !done);
> -
> - if (done)
> - break;
> -
> - if (audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0) > 0)
> {
> - /* we don't actually want to do anything here. */
> - ;
> - }
> - }
> - return;
> +static void do_auditd(int fd)
> +{
> + struct audit_reply rep;
> + sigset_t sigs;
> + struct sigaction sa;
> + struct pollfd pds = {
> + .events = POLLIN,
> + .revents = 0,
> + .fd = fd,
> + };
> +
> + if (audit_set_pid(fd, getpid(), WAIT_YES) < 0)
> + return;
> +
> + if (audit_set_enabled(fd, 1) < 0)
> + return;
> +
> + memset(&sa, '', sizeof(sa));
> + sa.sa_handler = sig_done;
> + sigaction(SIGTERM, &sa, NULL);
> + sigaction(SIGINT, &sa, NULL);
> + sigaction(SIGHUP, &sa, NULL);
> +
> + sigfillset(&sigs);
> + sigdelset(&sigs, SIGTERM);
> + sigdelset(&sigs, SIGINT);
> + sigdelset(&sigs, SIGHUP);
> +
> + while (1) {
> + int retval;
> +
> + memset(&rep, 0, sizeof(rep));
> +
> + do {
> + retval = ppoll(&pds, 1, NULL, &sigs);
> + } while (retval == -1 && errno == EINTR && !done);
> +
> + if (done)
> + break;
> +
> + if (audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0) > 0) {
> + /* we don't actually want to do anything here. */
> + ;
> + }
> + }
> + return;
> }
> #endif /* USESELINUX */
>
> -int audit_daemonize(void) {
> +int audit_daemonize(void)
> +{
> #ifdef USESELINUX
> - int fd;
> -#ifndef STANDALONE
> - int i;
> - pid_t child;
> -
> - if ((child = fork()) > 0)
> - return 0;
> + int fd;
> +#ifndef STANDALONE
> + int i;
> + pid_t child;
>
> - for (i = 0; i < getdtablesize(); i++)
> - close(i);
> + if ((child = fork()) > 0)
> + return 0;
>
> - signal(SIGTTOU, SIG_IGN);
> - signal(SIGTTIN, SIG_IGN);
> - signal(SIGTSTP, SIG_IGN);
> + for (i = 0; i < getdtablesize(); i++)
> + close(i);
>
> - if ((fd = open("/proc/self/oom_adj", O_RDWR)) >= 0) {
> - i = write(fd, "-17", 3);
> - close(fd);
> - }
> + signal(SIGTTOU, SIG_IGN);
> + signal(SIGTTIN, SIG_IGN);
> + signal(SIGTSTP, SIG_IGN);
>
> + if ((fd = open("/proc/self/oom_adj", O_RDWR)) >= 0) {
> + i = write(fd, "-17", 3);
> + close(fd);
> + }
> #endif /* !defined(STANDALONE) */
> - fd = audit_open();
> - do_auditd(fd);
> - audit_close(fd);
> + fd = audit_open();
> + do_auditd(fd);
> + audit_close(fd);
> #ifndef STANDALONE
> - exit(0);
> + exit(0);
> #endif /* !defined(STANDALONE) */
> #endif /* USESELINUX */
> - return 0;
> + return 0;
> }
>
> #ifdef STANDALONE
> -int main(void) {
> - return audit_daemonize();
> +int main(void)
> +{
> + return audit_daemonize();
> }
> #endif /* STANDALONE */
>
> diff --git a/isys/cpio.c b/isys/cpio.c
> index bebc795..acb613f 100644
> --- a/isys/cpio.c
> +++ b/isys/cpio.c
> @@ -24,25 +24,26 @@
>
> #include "cpio.h"
>
> -int installCpioFile(gzFile fd, char * cpioName, char * outName, int
> inWin) {
> - struct cpioFileMapping map;
> - int rc;
> - const char * failedFile;
> -
> - if (outName) {
> - map.archivePath = cpioName;
> - map.fsPath = outName;
> - map.mapFlags = CPIO_MAP_PATH;
> - }
> -
> - rc = myCpioInstallArchive(fd, outName ? &map : NULL, 1, NULL,
> NULL,
> - &failedFile);
> -
> - if (rc || access(outName, R_OK)) {
> - return -1;
> - }
> -
> - return 0;
> +int installCpioFile(gzFile fd, char *cpioName, char *outName, int
> inWin)
> +{
> + struct cpioFileMapping map;
> + int rc;
> + const char *failedFile;
> +
> + if (outName) {
> + map.archivePath = cpioName;
> + map.fsPath = outName;
> + map.mapFlags = CPIO_MAP_PATH;
> + }
> +
> + rc = myCpioInstallArchive(fd, outName ? &map : NULL, 1, NULL, NULL,
> + &failedFile);
> +
> + if (rc || access(outName, R_OK)) {
> + return -1;
> + }
> +
> + return 0;
> }
>
> /* vim:set sw=8 noet */
> diff --git a/isys/cpio.h b/isys/cpio.h
> index 6f76a6d..573f65b 100644
> --- a/isys/cpio.h
> +++ b/isys/cpio.h
> @@ -50,7 +50,6 @@
> #define CPIOERR_HDR_SIZE (21 )
> #define CPIOERR_UNKNOWN_FILETYPE (22 )
>
> -
> /* Don't think this behaves just like standard cpio. It's pretty
> close, but
> it has some behaviors which are more to RPM's liking. I tried to
> document
> them inline in cpio.c, but I may have missed some. */
> @@ -59,26 +58,26 @@
> #define CPIO_MAP_MODE (1 << 1)
> #define CPIO_MAP_UID (1 << 2)
> #define CPIO_MAP_GID (1 << 3)
> -#define CPIO_FOLLOW_SYMLINKS (1 << 4) /* only for building */
> +#define CPIO_FOLLOW_SYMLINKS (1 << 4) /* only for building */
>
> struct cpioFileMapping {
> - char * archivePath;
> - char * fsPath;
> - mode_t finalMode;
> - uid_t finalUid;
> - gid_t finalGid;
> - int mapFlags;
> + char *archivePath;
> + char *fsPath;
> + mode_t finalMode;
> + uid_t finalUid;
> + gid_t finalGid;
> + int mapFlags;
> };
>
> /* on cpio building, only "file" is filled in */
> struct cpioCallbackInfo {
> - char * file;
> - long fileSize; /* total file size */
> - long fileComplete; /* amount of file unpacked */
> - long bytesProcessed; /* bytes in archive read */
> + char *file;
> + long fileSize; /* total file size */
> + long fileComplete; /* amount of file unpacked */
> + long bytesProcessed; /* bytes in archive read */
> };
>
> -typedef void (*cpioCallback)(struct cpioCallbackInfo * filespec, void
> * data);
> +typedef void (*cpioCallback) (struct cpioCallbackInfo * filespec,
> void *data);
>
> /* If no mappings are passed, this installs everything! If one is
> passed
> it should be sorted according to cpioFileMapCmp() and only files
> included
> @@ -87,17 +86,17 @@ typedef void (*cpioCallback)(struct
> cpioCallbackInfo * filespec, void * data);
> directory. The mode mapping is only used for the permission bits,
> not
> for the file type. The owner/group mappings are ignored for the
> nonroot
> user. If *failedFile is non-NULL on return, it should be free()d.
> */
> -int myCpioInstallArchive(gzFile stream, struct cpioFileMapping *
> mappings,
> - int numMappings, cpioCallback cb, void * cbData,
> - const char ** failedFile);
> -int myCpioFilterArchive(gzFile inStream, gzFile outStream, char **
> pattern);
> +int myCpioInstallArchive(gzFile stream, struct cpioFileMapping
> *mappings,
> + int numMappings, cpioCallback cb, void *cbData,
> + const char **failedFile);
> +int myCpioFilterArchive(gzFile inStream, gzFile outStream, char
> **pattern);
>
> /* This is designed to be qsort/bsearch compatible */
> -int myCpioFileMapCmp(const void * a, const void * b);
> +int myCpioFileMapCmp(const void *a, const void *b);
>
> const char *myCpioStrerror(int rc);
>
> -int installCpioFile(gzFile fd, char * cpioName, char * outName, int
> inWin);
> +int installCpioFile(gzFile fd, char *cpioName, char *outName, int
> inWin);
>
> #endif
>
> diff --git a/isys/dasd.c b/isys/dasd.c
> index 3b07f25..17f4783 100644
> --- a/isys/dasd.c
> +++ b/isys/dasd.c
> @@ -41,139 +41,150 @@
>
> #if defined(__s390__) || defined(__s390x__)
> /* s390 stuff to detect DASDs */
> -static int read_vlabel(dasd_information_t *dasd_info, int fd, int
> blksize,
> - volume_label_t *vlabel) {
> - int rc;
> - unsigned long vlabel_start = dasd_info->label_block * blksize;
> +static int read_vlabel(dasd_information_t * dasd_info, int fd, int
> blksize,
> + volume_label_t * vlabel)
> +{
> + int rc;
> + unsigned long vlabel_start = dasd_info->label_block * blksize;
>
> - memset(vlabel, 0, sizeof(volume_label_t));
> + memset(vlabel, 0, sizeof(volume_label_t));
>
> - if (lseek(fd, vlabel_start, SEEK_SET) < 0) {
> - return 2;
> - }
> + if (lseek(fd, vlabel_start, SEEK_SET) < 0) {
> + return 2;
> + }
>
> - rc = read(fd, vlabel, sizeof(volume_label_t));
> - if (rc != sizeof(volume_label_t)) {
> - return 1;
> - }
> + rc = read(fd, vlabel, sizeof(volume_label_t));
> + if (rc != sizeof(volume_label_t)) {
> + return 1;
> + }
>
> - return 0;
> + return 0;
> }
> #endif
>
> -int isUsableDasd(char *device) {
> +int isUsableDasd(char *device)
> +{
> #if !defined(__s390__) && !defined(__s390x__)
> - return 0;
> + return 0;
> #else
> - char devname[16];
> - char label[5], v4_hex[9];
> - char l4ebcdic_hex[] = "d3d5e7f1"; /* LNX1 */
> - char cms1_hex[] = "c3d4e2f1"; /* CMS1 */
> - int f, ret, blksize;
> - dasd_information_t dasd_info;
> - volume_label_t vlabel;
> -
> - memset(&dasd_info, 0, sizeof(dasd_info));
> - strcpy(devname, "/dev/");
> - strcat(devname, device);
> -
> - if ((f = open(devname, O_RDONLY)) == -1)
> - return 0;
> -
> - if (ioctl(f, BLKSSZGET, &blksize) != 0) {
> - close(f);
> - return 0;
> - }
> -
> - if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
> - close(f);
> - return 0;
> - }
> -
> - ret = read_vlabel(&dasd_info, f, blksize, &vlabel);
> - close(f);
> -
> - if (ret == 2)
> - return 0;
> - else if (ret == 1) /* probably unformatted DASD */
> - return 1;
> -
> - memset(label, 0, 5);
> - memset(v4_hex, 0, 9);
> - strncpy(label, vlabel.volkey, 4);
> -
> - ret = sprintf(v4_hex, "%02x%02x%02x%02x", label[0], label[1],
> - label[2], label[3]);
> - if (ret < 0 || ret < strlen(cms1_hex))
> - return 3;
> -
> - if (!strncmp(v4_hex, cms1_hex, 9))
> - return 0;
> -
> - if (!strncmp(v4_hex, l4ebcdic_hex, 9))
> - return 2;
> -
> - return 1;
> + char devname[16];
> + char label[5], v4_hex[9];
> + char l4ebcdic_hex[] = "d3d5e7f1"; /* LNX1 */
> + char cms1_hex[] = "c3d4e2f1"; /* CMS1 */
> + int f, ret, blksize;
> + dasd_information_t dasd_info;
> + volume_label_t vlabel;
> +
> + memset(&dasd_info, 0, sizeof(dasd_info));
> + strcpy(devname, "/dev/");
> + strcat(devname, device);
> +
> + if ((f = open(devname, O_RDONLY)) == -1)
> + return 0;
> +
> + if (ioctl(f, BLKSSZGET, &blksize) != 0) {
> + close(f);
> + return 0;
> + }
> +
> + if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
> + close(f);
> + return 0;
> + }
> +
> + ret = read_vlabel(&dasd_info, f, blksize, &vlabel);
> + close(f);
> +
> + if (ret == 2)
> + return 0;
> + else if (ret == 1) /* probably unformatted DASD */
> + return 1;
> +
> + memset(label, 0, 5);
> + memset(v4_hex, 0, 9);
> + strncpy(label, vlabel.volkey, 4);
> +
> + ret = sprintf(v4_hex, "%02x%02x%02x%02x", label[0], label[1],
> + label[2], label[3]);
> + if (ret < 0 || ret < strlen(cms1_hex))
> + return 3;
> +
> + if (!strncmp(v4_hex, cms1_hex, 9))
> + return 0;
> +
> + if (!strncmp(v4_hex, l4ebcdic_hex, 9))
> + return 2;
> +
> + return 1;
> #endif
> }
>
> -int isLdlDasd(char * device) {
> - return (isUsableDasd(device) == 2);
> +int isLdlDasd(char *device)
> +{
> + return (isUsableDasd(device) == 2);
> }
>
> -char *getDasdPorts() {
> +char *getDasdPorts()
> +{
> #if !defined(__s390__) && !defined(__s390x__)
> - return 0;
> + return 0;
> #else
> - char * line, *ports = NULL;
> - char devname[7];
> - char port[10];
> - FILE *fd;
> - int ret, sz;
> -
> - fd = fopen("/proc/dasd/devices", "r");
> - if (!fd)
> - return NULL;
> -
> - if ((line = (char *)malloc(100 * sizeof(char))) == NULL) {
> - fclose(fd);
> - return NULL;
> - }
> -
> - while (fgets(line, 100, fd) != NULL) {
> - if ((strstr(line, "unknown") != NULL))
> - continue;
> -
> - if (strstr(line, "(FBA )") != NULL)
> - ret = sscanf(line, "%[A-Za-z.0-9](FBA ) at ( %*d: %*d) is
> %s : %*s", port, devname);
> - else
> - ret = sscanf(line, "%[A-Za-z.0-9](ECKD) at ( %*d: %*d) is
> %s : %*s", port, devname);
> -
> - if (ret == 2) {
> - if (!ports) {
> - sz = strlen(port) + 1;
> - if ((ports = (char *) malloc(sz)) == NULL) {
> - fclose(fd);
> - return NULL;
> - }
> -
> - ports = strcpy(ports, port);
> - } else {
> - sz = strlen(ports) + strlen(port) + 2;
> - if ((ports = (char *) realloc(ports, sz)) == NULL) {
> - fclose(fd);
> - return NULL;
> - }
> -
> - ports = strcat(ports, ",");
> - ports = strcat(ports, port);
> - }
> - }
> - }
> -
> - fclose(fd);
> -
> - return ports;
> + char *line, *ports = NULL;
> + char devname[7];
> + char port[10];
> + FILE *fd;
> + int ret, sz;
> +
> + fd = fopen("/proc/dasd/devices", "r");
> + if (!fd)
> + return NULL;
> +
> + if ((line = (char *)malloc(100 * sizeof(char))) == NULL) {
> + fclose(fd);
> + return NULL;
> + }
> +
> + while (fgets(line, 100, fd) != NULL) {
> + if ((strstr(line, "unknown") != NULL))
> + continue;
> +
> + if (strstr(line, "(FBA )") != NULL)
> + ret =
> + sscanf(line,
> + "%[A-Za-z.0-9](FBA ) at ( %*d: %*d) is %s : %*s",
> + port, devname);
> + else
> + ret =
> + sscanf(line,
> + "%[A-Za-z.0-9](ECKD) at ( %*d: %*d) is %s : %*s",
> + port, devname);
> +
> + if (ret == 2) {
> + if (!ports) {
> + sz = strlen(port) + 1;
> + if ((ports = (char *)malloc(sz)) == NULL) {
> + fclose(fd);
> + return NULL;
> + }
> +
> + ports = strcpy(ports, port);
> + } else {
> + sz = strlen(ports) + strlen(port) + 2;
> + if ((ports =
> + (char *)realloc(ports, sz)) == NULL) {
> + fclose(fd);
> + return NULL;
> + }
> +
> + ports = strcat(ports, ",");
> + ports = strcat(ports, port);
> + }
> + }
> + }
> +
> + fclose(fd);
> +
> + return ports;
> #endif
> }
>
> diff --git a/isys/devices.c b/isys/devices.c
> index ef4384d..56f562b 100644
> --- a/isys/devices.c
> +++ b/isys/devices.c
> @@ -34,7 +34,7 @@
> #include "devices.h"
>
> /* for 'disks', to filter out weird stuff */
> -#define MINIMUM_INTERESTING_SIZE 32*1024 /* 32MB */
> +#define MINIMUM_INTERESTING_SIZE 32*1024 /* 32MB */
>
> /* from genhd.h, kernel side */
> #define GENHD_FL_REMOVABLE 1
> @@ -45,175 +45,193 @@
> #define GENHD_FL_SUPPRESS_PARTITION_INFO 32
> #define GENHD_FL_FAIL 64
>
> -
> -struct device **getDevices(enum deviceType type) {
> - struct device **ret = NULL;
> - 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)) {
> - 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 = strtol(buf, NULL, 10);
> -
> - if ((errno == ERANGE && (size == LONG_MIN ||
> - size == LONG_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
", __func__, __LINE__,
> - strerror(errno));
> - fflush(stderr);
> - abort();
> - }
> - new->type = devtype;
> - if (caps & GENHD_FL_REMOVABLE) {
> - new->priv.removable = 1;
> - }
> - ret = realloc(ret, (numdevices+2) * sizeof(struct
> device));
> - ret[numdevices] = new;
> - ret[numdevices+1] = NULL;
> - numdevices++;
> - }
> - }
> +struct device **getDevices(enum deviceType type)
> +{
> + struct device **ret = NULL;
> + 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)) {
> + 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 = strtol(buf, NULL, 10);
> +
> + if ((errno == ERANGE && (size == LONG_MIN ||
> + size == LONG_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
", __func__,
> + __LINE__, strerror(errno));
> + fflush(stderr);
> + abort();
> + }
> + new->type = devtype;
> + if (caps & GENHD_FL_REMOVABLE) {
> + new->priv.removable = 1;
> + }
> + ret =
> + realloc(ret,
> + (numdevices + 2) * sizeof(struct device));
> + ret[numdevices] = new;
> + ret[numdevices + 1] = NULL;
> + numdevices++;
> + }
> + }
> 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;
> - }
> -
> - if (type != 1)
> - 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, '', 64);
> - if (read(fd, buf, 63) > 0) {
> - int i;
> - for (i = (strlen(buf)-1); isspace(buf[i]); i--)
> - buf[i] = '';
> - new->priv.hwaddr = strdup(buf);
> - }
> - }
> -
> - if (new->priv.hwaddr) {
> - if (asprintf(&new->description, "Ethernet device %s -
> %s",
> - new->device, new->priv.hwaddr) == -1) {
> - fprintf(stderr, "%s: %d: %s
", __func__,
> __LINE__,
> - strerror(errno));
> - fflush(stderr);
> - abort();
> - }
> - } else {
> - if (asprintf(&new->description, "Ethernet device
> %s",
> - new->device) == -1) {
> - fprintf(stderr, "%s: %d: %s
", __func__,
> __LINE__,
> - strerror(errno));
> - fflush(stderr);
> - abort();
> - }
> - }
> -
> - ret = realloc(ret, (numdevices+2) * sizeof(struct
> device));
> - ret[numdevices] = new;
> - ret[numdevices+1] = NULL;
> - numdevices++;
> - }
> - }
> + 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;
> + }
> +
> + if (type != 1)
> + 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, '', 64);
> + if (read(fd, buf, 63) > 0) {
> + int i;
> + for (i = (strlen(buf) - 1);
> + isspace(buf[i]); i--)
> + buf[i] = '';
> + new->priv.hwaddr = strdup(buf);
> + }
> + }
> +
> + if (new->priv.hwaddr) {
> + if (asprintf
> + (&new->description,
> + "Ethernet device %s - %s", new->device,
> + new->priv.hwaddr) == -1) {
> + fprintf(stderr, "%s: %d: %s
",
> + __func__, __LINE__,
> + strerror(errno));
> + fflush(stderr);
> + abort();
> + }
> + } else {
> + if (asprintf
> + (&new->description, "Ethernet device %s",
> + new->device) == -1) {
> + fprintf(stderr, "%s: %d: %s
",
> + __func__, __LINE__,
> + strerror(errno));
> + fflush(stderr);
> + abort();
> + }
> + }
> +
> + ret =
> + realloc(ret,
> + (numdevices + 2) * sizeof(struct device));
> + ret[numdevices] = new;
> + ret[numdevices + 1] = NULL;
> + numdevices++;
> + }
> + }
> netdone:
> - return ret;
> + return ret;
> }
>
> -
> /* vim:set sw=8 noet */
> diff --git a/isys/devices.h b/isys/devices.h
> index 9f636ad..7262ce1 100644
> --- a/isys/devices.h
> +++ b/isys/devices.h
> @@ -21,20 +21,20 @@
> #define DEVICES_H
>
> enum deviceType {
> - DEVICE_ANY = ~0,
> - DEVICE_NETWORK = (1 << 0),
> - DEVICE_DISK = (1 << 1),
> - DEVICE_CDROM = (1 << 2)
> + 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;
> + char *device;
> + char *description;
> + enum deviceType type;
> + union {
> + char *hwaddr;
> + int removable;
> + } priv;
> };
>
> struct device **getDevices(enum deviceType type);
> diff --git a/isys/eddsupport.c b/isys/eddsupport.c
> index c2b7a3c..1f310f0 100644
> --- a/isys/eddsupport.c
> +++ b/isys/eddsupport.c
> @@ -36,7 +36,6 @@
> #include <sys/types.h>
> #include <linux/types.h>
>
> -
> #include "eddsupport.h"
> #include "devices.h"
> #include "isys.h"
> @@ -47,30 +46,27 @@
>
> #define HASH_TABLE_SIZE 17
>
> -
> -struct diskMapEntry{
> - uint32_t key;
> - char *diskname;
> - struct diskMapEntry *next;
> +struct diskMapEntry {
> + uint32_t key;
> + char *diskname;
> + struct diskMapEntry *next;
> };
>
> struct diskMapTable {
> - struct diskMapEntry **table;
> - int tableSize;
> + struct diskMapEntry **table;
> + int tableSize;
> };
>
> static struct diskMapTable *mbrSigToName = NULL;
> static int diskHashInit = 0;
>
> -
> -
> -static struct diskMapTable* initializeHashTable(int);
> +static struct diskMapTable *initializeHashTable(int);
> static int insertHashItem(struct diskMapTable *, struct diskMapEntry
> *);
> -static struct diskMapEntry* lookupHashItem(struct diskMapTable *,
> uint32_t);
> -static int addToHashTable(struct diskMapTable *, uint32_t , char *);
> -static struct device ** createDiskList();
> -static int mapBiosDisks(struct device ** , const char *);
> -static int readDiskSig(char *, uint32_t *);
> +static struct diskMapEntry *lookupHashItem(struct diskMapTable *,
> uint32_t);
> +static int addToHashTable(struct diskMapTable *, uint32_t, char *);
> +static struct device **createDiskList();
> +static int mapBiosDisks(struct device **, const char *);
> +static int readDiskSig(char *, uint32_t *);
> static int readMbrSig(char *, uint32_t *);
>
> /* This is the top level function that creates a disk list present in
> the
> @@ -79,263 +75,274 @@ static int readMbrSig(char *, uint32_t *);
> * corresponding hd/sd device names. Otherwise, we'll avoid mapping
> drives.
> */
>
> -int probeBiosDisks() {
> - struct device ** devices = NULL;
> +int probeBiosDisks()
> +{
> + struct device **devices = NULL;
>
> - devices = createDiskList();
> - if(!devices){
> + devices = createDiskList();
> + if (!devices) {
> #ifdef STANDALONE
> - fprintf(stderr, "No disks!
");
> + fprintf(stderr, "No disks!
");
> #endif
> - return -1;
> - }
> + return -1;
> + }
>
> - if(!mapBiosDisks(devices, EDD_DIR)){
> + if (!mapBiosDisks(devices, EDD_DIR)) {
> #ifdef STANDALONE
> - fprintf(stderr, "WARNING: couldn't map BIOS disks
");
> + fprintf(stderr, "WARNING: couldn't map BIOS disks
");
> #endif
> - return -1;
> - }
> - return 0;
> + return -1;
> + }
> + return 0;
> }
>
> -
> -static struct device ** createDiskList(){
> - return getDevices (DEVICE_DISK);
> +static struct device **createDiskList()
> +{
> + return getDevices(DEVICE_DISK);
> }
>
> -static int readDiskSig(char *device, uint32_t *disksig) {
> - int fd, rc;
> - char devnodeName[64];
> +static int readDiskSig(char *device, uint32_t * disksig)
> +{
> + int fd, rc;
> + char devnodeName[64];
>
> - snprintf(devnodeName, sizeof(devnodeName), "/dev/%s", device);
> - fd = open(devnodeName, O_RDONLY);
> - if (fd < 0) {
> -#ifdef STANDALONE
> - fprintf(stderr, "Error opening device %s: %s
", device,
> - strerror(errno));
> -#endif
> - return -errno;
> - }
> + snprintf(devnodeName, sizeof(devnodeName), "/dev/%s", device);
> + fd = open(devnodeName, O_RDONLY);
> + if (fd < 0) {
> +#ifdef STANDALONE
> + fprintf(stderr, "Error opening device %s: %s
", device,
> + strerror(errno));
> +#endif
> + return -errno;
> + }
>
> - rc = lseek(fd, MBRSIG_OFFSET, SEEK_SET);
> - if (rc < 0){
> - close(fd);
> + rc = lseek(fd, MBRSIG_OFFSET, SEEK_SET);
> + if (rc < 0) {
> + close(fd);
>
> #ifdef STANDALONE
> - fprintf(stderr, "Error seeking to MBRSIG_OFFSET in %s: %s
",
>
> - device, strerror(errno));
> + fprintf(stderr, "Error seeking to MBRSIG_OFFSET in %s: %s
",
> + device, strerror(errno));
> #endif
> - return -1;
> - }
> + return -1;
> + }
>
> - rc = read(fd, disksig, sizeof(uint32_t));
> - if (rc < sizeof(uint32_t)) {
> - close(fd);
> + rc = read(fd, disksig, sizeof(uint32_t));
> + if (rc < sizeof(uint32_t)) {
> + close(fd);
>
> #ifdef STANDALONE
> - fprintf(stderr, "Failed to read signature from %s
",
> device);
> + fprintf(stderr, "Failed to read signature from %s
", device);
> #endif
> - return -1;
> - }
> + return -1;
> + }
>
> - close(fd);
> - return 0;
> + close(fd);
> + return 0;
> }
>
> -static int mapBiosDisks(struct device** devices,const char *path) {
> - DIR *dirHandle;
> - struct dirent *entry;
> - char * sigFileName;
> - uint32_t mbrSig, biosNum, currentSig;
> - struct device **currentDev, **foundDisk;
> - int i, rc, ret, dm_nr, highest_dm;
> -
> - dirHandle = opendir(path);
> - if(!dirHandle){
> +static int mapBiosDisks(struct device **devices, const char *path)
> +{
> + DIR *dirHandle;
> + struct dirent *entry;
> + char *sigFileName;
> + uint32_t mbrSig, biosNum, currentSig;
> + struct device **currentDev, **foundDisk;
> + int i, rc, ret, dm_nr, highest_dm;
> +
> + dirHandle = opendir(path);
> + if (!dirHandle) {
> #ifdef STANDALONE
> - fprintf(stderr, "Failed to open directory %s: %s
", path,
> - strerror(errno));
> + fprintf(stderr, "Failed to open directory %s: %s
", path,
> + strerror(errno));
> #endif
> - return 0;
> - }
> + return 0;
> + }
>
> - mbrSigToName = initializeHashTable(HASH_TABLE_SIZE);
> - if(!mbrSigToName){
> + mbrSigToName = initializeHashTable(HASH_TABLE_SIZE);
> + if (!mbrSigToName) {
> #ifdef STANDALONE
> - fprintf(stderr, "Error initializing mbrSigToName table
");
> + fprintf(stderr, "Error initializing mbrSigToName table
");
> #endif
> - closedir(dirHandle);
> - return 0;
> - }
> -
> - while ((entry = readdir(dirHandle)) != NULL) {
> - if(!strncmp(entry->d_name,".",1) ||
> !strncmp(entry->d_name,"..",2)) {
> - continue;
> - }
> - ret = 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);
> - if (readMbrSig(sigFileName, &mbrSig) == 0) {
> - for (currentDev = devices, i = 0, foundDisk=NULL,
> highest_dm=-1;
> - (*currentDev) != NULL;
> - currentDev++) {
> - if (!(*currentDev)->device)
> - continue;
> -
> - if ((rc=readDiskSig((*currentDev)->device,
> &currentSig)) < 0) {
> - if (rc == -ENOMEDIUM || rc == -ENXIO)
> - continue;
> - closedir(dirHandle);
> - return 0;
> - }
> -
> - if (mbrSig == currentSig) {
> - /* When we have a fakeraid setup we will find
> multiple hits
> - a number for the raw disks (1 when striping, 2
> when
> - mirroring, more with raid on raid like raid 01
> or 10)
> - and a number for the dm devices (normally only
> one dm
> - device will match, but more with raid on
> raid).
> - Since with raid on raid the last dm device
> created
> - will be the top layer raid, we want the
> highest matching
> - dm device. */
> - if (!strncmp((*currentDev)->device, "dm-", 3) &&
> - sscanf((*currentDev)->device+3, "%d",
> &dm_nr) == 1) {
> - if (dm_nr > highest_dm) {
> - highest_dm = dm_nr;
> - foundDisk=currentDev;
> - i = 1;
> - }
> - } else if (!foundDisk ||
> - strncmp((*foundDisk)->device, "dm-",
> 3)) {
> - foundDisk=currentDev;
> - i++;
> - }
> - }
> - }
> -
> - if (i==1) {
> - if(!addToHashTable(mbrSigToName, (uint32_t)biosNum,
> - (*foundDisk)->device)) {
> - closedir(dirHandle);
> - return 0;
> - }
> - }
> - }
> - }
> - closedir(dirHandle);
> - return 1;
> -}
> -
> -
> -static int readMbrSig(char *filename, uint32_t *int_sig){
> - FILE* fh;
> -
> - fh = fopen(filename,"r");
> - if(fh == NULL) {
> + closedir(dirHandle);
> + return 0;
> + }
> +
> + while ((entry = readdir(dirHandle)) != NULL) {
> + if (!strncmp(entry->d_name, ".", 1)
> + || !strncmp(entry->d_name, "..", 2)) {
> + continue;
> + }
> + ret = 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);
> + if (readMbrSig(sigFileName, &mbrSig) == 0) {
> + for (currentDev = devices, i = 0, foundDisk =
> + NULL, highest_dm = -1; (*currentDev) != NULL;
> + currentDev++) {
> + if (!(*currentDev)->device)
> + continue;
> +
> + if ((rc =
> + readDiskSig((*currentDev)->device,
> + &currentSig)) < 0) {
> + if (rc == -ENOMEDIUM || rc == -ENXIO)
> + continue;
> + closedir(dirHandle);
> + return 0;
> + }
> +
> + if (mbrSig == currentSig) {
> + /* When we have a fakeraid setup we will find multiple hits
> + a number for the raw disks (1 when striping, 2 when
> + mirroring, more with raid on raid like raid 01 or 10)
> + and a number for the dm devices (normally only one dm
> + device will match, but more with raid on raid).
> + Since with raid on raid the last dm device created
> + will be the top layer raid, we want the highest matching
> + dm device. */
> + if (!strncmp
> + ((*currentDev)->device, "dm-", 3)
> + && sscanf((*currentDev)->device + 3,
> + "%d", &dm_nr) == 1) {
> + if (dm_nr > highest_dm) {
> + highest_dm = dm_nr;
> + foundDisk = currentDev;
> + i = 1;
> + }
> + } else if (!foundDisk ||
> + strncmp((*foundDisk)->device,
> + "dm-", 3)) {
> + foundDisk = currentDev;
> + i++;
> + }
> + }
> + }
> +
> + if (i == 1) {
> + if (!addToHashTable
> + (mbrSigToName, (uint32_t) biosNum,
> + (*foundDisk)->device)) {
> + closedir(dirHandle);
> + return 0;
> + }
> + }
> + }
> + }
> + closedir(dirHandle);
> + return 1;
> +}
> +
> +static int readMbrSig(char *filename, uint32_t * int_sig)
> +{
> + FILE *fh;
> +
> + fh = fopen(filename, "r");
> + if (fh == NULL) {
> #ifdef STANDALONE
> - fprintf(stderr, "Error opening mbr_signature file %s: %s
",
> filename,
> - strerror(errno));
> + fprintf(stderr, "Error opening mbr_signature file %s: %s
",
> + filename, strerror(errno));
> #endif
> - return -1;
> - }
> - fseek(fh, 0, SEEK_SET);
> - if (fscanf(fh, "%x", int_sig) != 1) {
> + return -1;
> + }
> + fseek(fh, 0, SEEK_SET);
> + if (fscanf(fh, "%x", int_sig) != 1) {
> #ifdef STANDALONE
> - fprintf(stderr, "Error reading %s
", filename);
> + fprintf(stderr, "Error reading %s
", filename);
> #endif
> - fclose(fh);
> - return -1;
> - }
> -
> - fclose(fh);
> - return 0;
> -}
> + fclose(fh);
> + return -1;
> + }
>
> + fclose(fh);
> + return 0;
> +}
>
> -static struct diskMapTable* initializeHashTable(int size) {
> - struct diskMapTable *hashTable;
> +static struct diskMapTable *initializeHashTable(int size)
> +{
> + struct diskMapTable *hashTable;
>
> - hashTable = malloc(sizeof(struct diskMapTable));
> - hashTable->tableSize = size;
> - hashTable->table = malloc(sizeof(struct diskMapEntry *) * size);
> - memset(hashTable->table,0,(sizeof(struct diskMapEntry *) *
> size));
> - return hashTable;
> + hashTable = malloc(sizeof(struct diskMapTable));
> + hashTable->tableSize = size;
> + hashTable->table = malloc(sizeof(struct diskMapEntry *) * size);
> + memset(hashTable->table, 0, (sizeof(struct diskMapEntry *) *
> size));
> + return hashTable;
> }
>
> -
> static int insertHashItem(struct diskMapTable *hashTable,
> - struct diskMapEntry *hashItem) {
> - int index;
> -
> - index = (hashItem->key) % (hashTable->tableSize);
> -
> - if(hashTable->table[index] == NULL){
> - hashTable->table[index] = hashItem;
> - return index;
> - } else {
> - hashItem->next = hashTable->table[index];
> - hashTable->table[index] = hashItem;
> - return index;
> - }
> + struct diskMapEntry *hashItem)
> +{
> + int index;
> +
> + index = (hashItem->key) % (hashTable->tableSize);
> +
> + if (hashTable->table[index] == NULL) {
> + hashTable->table[index] = hashItem;
> + return index;
> + } else {
> + hashItem->next = hashTable->table[index];
> + hashTable->table[index] = hashItem;
> + return index;
> + }
> }
>
> -
> -static struct diskMapEntry * lookupHashItem(struct diskMapTable
> *hashTable,
> - uint32_t itemKey) {
> - int index;
> - struct diskMapEntry *hashItem;
> -
> - index = itemKey % (hashTable->tableSize);
> - for (hashItem = hashTable->table[index];
> - (hashItem != NULL) && (hashItem->key != itemKey);
> - hashItem = hashItem->next) {
> - ;
> - }
> - return hashItem;
> +static struct diskMapEntry *lookupHashItem(struct diskMapTable
> *hashTable,
> + uint32_t itemKey)
> +{
> + int index;
> + struct diskMapEntry *hashItem;
> +
> + index = itemKey % (hashTable->tableSize);
> + for (hashItem = hashTable->table[index];
> + (hashItem != NULL) && (hashItem->key != itemKey);
> + hashItem = hashItem->next) {
> + ;
> + }
> + return hashItem;
> }
>
> +static int addToHashTable(struct diskMapTable *hashTable,
> + uint32_t itemKey, char *diskName)
> +{
> + int index;
> + struct diskMapEntry *diskSigToNameEntry;
>
> -static int addToHashTable(struct diskMapTable *hashTable,
> - uint32_t itemKey, char *diskName) {
> - int index;
> - struct diskMapEntry *diskSigToNameEntry;
> + diskSigToNameEntry = malloc(sizeof(struct diskMapEntry));
> + diskSigToNameEntry->next = NULL;
> + diskSigToNameEntry->key = itemKey;
> + diskSigToNameEntry->diskname = diskName;
>
> - diskSigToNameEntry = malloc(sizeof(struct diskMapEntry));
> - diskSigToNameEntry->next = NULL;
> - diskSigToNameEntry->key = itemKey;
> - diskSigToNameEntry->diskname = diskName;
> -
> - if ((index = insertHashItem(hashTable, diskSigToNameEntry)) <
> 0){
> + if ((index = insertHashItem(hashTable, diskSigToNameEntry)) < 0) {
> #ifdef STANDALONE
> - fprintf(stderr, "Unable to insert item
");
> + fprintf(stderr, "Unable to insert item
");
> #endif
> - return 0;
> - } else {
> - return 1;
> - }
> + return 0;
> + } else {
> + return 1;
> + }
> }
>
> +char *getBiosDisk(char *biosStr)
> +{
> + uint32_t biosNum;
> + struct diskMapEntry *disk;
> + int ret;
>
> -char * getBiosDisk(char *biosStr) {
> - uint32_t biosNum;
> - struct diskMapEntry * disk;
> - int ret;
> -
> - if (diskHashInit == 0) {
> - probeBiosDisks();
> - diskHashInit = 1;
> - }
> + if (diskHashInit == 0) {
> + probeBiosDisks();
> + diskHashInit = 1;
> + }
>
> - if (mbrSigToName == NULL)
> - return NULL;
> + if (mbrSigToName == NULL)
> + return NULL;
>
> - ret = sscanf(biosStr,"%x",&biosNum);
> - disk = lookupHashItem(mbrSigToName, biosNum);
> - if (disk) return disk->diskname;
> + ret = sscanf(biosStr, "%x", &biosNum);
> + disk = lookupHashItem(mbrSigToName, biosNum);
> + if (disk)
> + return disk->diskname;
>
> - return NULL;
> + return NULL;
> }
>
> /* vim:set sw=8 noet */
> diff --git a/isys/eddsupport.h b/isys/eddsupport.h
> index ec7d3f4..51427bd 100644
> --- a/isys/eddsupport.h
> +++ b/isys/eddsupport.h
> @@ -21,10 +21,8 @@
> #define EDDSUPPORT_H
>
> int probeBiosDisks();
> -char* getBiosDisk(char *);
> +char *getBiosDisk(char *);
>
> #endif
>
> -
> -
> /* vim:set sw=8 noet */
> diff --git a/isys/ethtool.c b/isys/ethtool.c
> index eb4e592..657c2f6 100644
> --- a/isys/ethtool.c
> +++ b/isys/ethtool.c
> @@ -33,89 +33,92 @@
> #include <linux/sockios.h>
> #include "ethtool.h"
>
> -static int set_intf_up(struct ifreq ifr, int sock) {
> - if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
> - return (-1);
> - }
> - ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
> - if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
> - fprintf(stderr, "failed to bring up interface %s: %s",
> ifr.ifr_name,
> - strerror(errno));
> - return -1;
> - }
> - return (0);
> +static int set_intf_up(struct ifreq ifr, int sock)
> +{
> + if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
> + return (-1);
> + }
> + ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
> + if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
> + fprintf(stderr, "failed to bring up interface %s: %s",
> + ifr.ifr_name, strerror(errno));
> + return -1;
> + }
> + return (0);
> }
>
> -int setEthtoolSettings(char * dev, ethtool_speed speed,
> - ethtool_duplex duplex) {
> - int sock, err;
> - struct ethtool_cmd ecmd;
> - struct ifreq ifr;
> -
> - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
> - perror("Unable to create socket");
> - return -1;
> - }
> -
> - /* Setup our control structures. */
> - memset(&ifr, 0, sizeof(ifr));
> - strcpy(ifr.ifr_name, dev);
> -
> - if (set_intf_up(ifr, sock) == -1) {
> - fprintf(stderr, "unable to bring up interface %s: %s", dev,
> - strerror(errno));
> - return -1;
> - }
> -
> - ecmd.cmd = ETHTOOL_GSET;
> - ifr.ifr_data = (caddr_t)&ecmd;
> - err = ioctl(sock, SIOCETHTOOL, &ifr);
> - if (err < 0) {
> - perror("Unable to get settings via ethtool. Not setting");
> - return -1;
> - }
> -
> - if (speed != ETHTOOL_SPEED_UNSPEC)
> - ecmd.speed = speed;
> - if (duplex != ETHTOOL_DUPLEX_UNSPEC)
> - ecmd.duplex = duplex;
> - if ((duplex != ETHTOOL_DUPLEX_UNSPEC) || (speed !=
> ETHTOOL_SPEED_UNSPEC))
> - ecmd.autoneg = AUTONEG_DISABLE;
> -
> - ecmd.cmd = ETHTOOL_SSET;
> - ifr.ifr_data = (caddr_t)&ecmd;
> - err = ioctl(sock, SIOCETHTOOL, &ifr);
> - if (err < 0) {
> - // perror("Unable to set settings via ethtool. Not
> setting");
> - return -1;
> - }
> -
> - return 0;
> +int setEthtoolSettings(char *dev, ethtool_speed speed, ethtool_duplex
> duplex)
> +{
> + int sock, err;
> + struct ethtool_cmd ecmd;
> + struct ifreq ifr;
> +
> + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
> + perror("Unable to create socket");
> + return -1;
> + }
> +
> + /* Setup our control structures. */
> + memset(&ifr, 0, sizeof(ifr));
> + strcpy(ifr.ifr_name, dev);
> +
> + if (set_intf_up(ifr, sock) == -1) {
> + fprintf(stderr, "unable to bring up interface %s: %s", dev,
> + strerror(errno));
> + return -1;
> + }
> +
> + ecmd.cmd = ETHTOOL_GSET;
> + ifr.ifr_data = (caddr_t) & ecmd;
> + err = ioctl(sock, SIOCETHTOOL, &ifr);
> + if (err < 0) {
> + perror("Unable to get settings via ethtool. Not setting");
> + return -1;
> + }
> +
> + if (speed != ETHTOOL_SPEED_UNSPEC)
> + ecmd.speed = speed;
> + if (duplex != ETHTOOL_DUPLEX_UNSPEC)
> + ecmd.duplex = duplex;
> + if ((duplex != ETHTOOL_DUPLEX_UNSPEC)
> + || (speed != ETHTOOL_SPEED_UNSPEC))
> + ecmd.autoneg = AUTONEG_DISABLE;
> +
> + ecmd.cmd = ETHTOOL_SSET;
> + ifr.ifr_data = (caddr_t) & ecmd;
> + err = ioctl(sock, SIOCETHTOOL, &ifr);
> + if (err < 0) {
> + // perror("Unable to set settings via ethtool. Not
> setting");
> + return -1;
> + }
> +
> + return 0;
> }
>
> -int identifyNIC(char *iface, int seconds) {
> - int sock;
> - struct ethtool_value edata;
> - struct ifreq ifr;
> +int identifyNIC(char *iface, int seconds)
> +{
> + int sock;
> + struct ethtool_value edata;
> + struct ifreq ifr;
>
> - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
> - perror("Unable to create socket");
> - return -1;
> - }
> + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
> + perror("Unable to create socket");
> + return -1;
> + }
>
> - memset(&ifr, 0, sizeof(ifr));
> - memset(&edata, 0, sizeof(edata));
> + memset(&ifr, 0, sizeof(ifr));
> + memset(&edata, 0, sizeof(edata));
>
> - strcpy(ifr.ifr_name, iface);
> - edata.cmd = ETHTOOL_PHYS_ID;
> - edata.data = seconds;
> - ifr.ifr_data = (caddr_t) &edata;
> + strcpy(ifr.ifr_name, iface);
> + edata.cmd = ETHTOOL_PHYS_ID;
> + edata.data = seconds;
> + ifr.ifr_data = (caddr_t) & edata;
>
> - if (ioctl(sock, SIOCETHTOOL, &ifr) < 0) {
> - perror("Unable to identify NIC");
> - }
> + if (ioctl(sock, SIOCETHTOOL, &ifr) < 0) {
> + perror("Unable to identify NIC");
> + }
>
> - return 0;
> + return 0;
> }
>
> /* vim:set sw=8 noet */
> diff --git a/isys/ethtool.h b/isys/ethtool.h
> index e661ceb..d63177e 100644
> --- a/isys/ethtool.h
> +++ b/isys/ethtool.h
> @@ -26,16 +26,18 @@
> /* returns 1 for link, 0 for no link, -1 for unknown */
> int get_link_status(char *ifname);
>
> -typedef enum ethtool_speed_t { ETHTOOL_SPEED_UNSPEC = -1,
> - ETHTOOL_SPEED_10 = SPEED_10,
> - ETHTOOL_SPEED_100 = SPEED_100,
> - ETHTOOL_SPEED_1000 = SPEED_1000 }
> ethtool_speed;
> -typedef enum ethtool_duplex_t { ETHTOOL_DUPLEX_UNSPEC = -1,
> - ETHTOOL_DUPLEX_HALF = DUPLEX_HALF,
> - ETHTOOL_DUPLEX_FULL = DUPLEX_FULL }
> ethtool_duplex;
> +typedef enum ethtool_speed_t { ETHTOOL_SPEED_UNSPEC = -1,
> + ETHTOOL_SPEED_10 = SPEED_10,
> + ETHTOOL_SPEED_100 = SPEED_100,
> + ETHTOOL_SPEED_1000 = SPEED_1000
> +} ethtool_speed;
> +typedef enum ethtool_duplex_t { ETHTOOL_DUPLEX_UNSPEC = -1,
> + ETHTOOL_DUPLEX_HALF = DUPLEX_HALF,
> + ETHTOOL_DUPLEX_FULL = DUPLEX_FULL
> +} ethtool_duplex;
>
> /* set ethtool settings */
> -int setEthtoolSettings(char * dev, ethtool_speed speed,
> ethtool_duplex duplex);
> +int setEthtoolSettings(char *dev, ethtool_speed speed, ethtool_duplex
> duplex);
> int identifyNIC(char *iface, int seconds);
>
> #endif
> diff --git a/isys/iface.c b/isys/iface.c
> index 1af53ef..cb48236 100644
> --- a/isys/iface.c
> +++ b/isys/iface.c
> @@ -63,93 +63,97 @@ static int _iface_redirect_io(char *device, int
> fd, int mode);
> /*
> * Return a libnl handle for NETLINK_ROUTE.
> */
> -static struct nl_handle *_iface_get_handle(void) {
> - struct nl_handle *handle = NULL;
> +static struct nl_handle *_iface_get_handle(void)
> +{
> + struct nl_handle *handle = NULL;
>
> - if ((handle = nl_handle_alloc()) == NULL) {
> - return NULL;
> - }
> + if ((handle = nl_handle_alloc()) == NULL) {
> + return NULL;
> + }
>
> - if (nl_connect(handle, NETLINK_ROUTE)) {
> - nl_handle_destroy(handle);
> - return NULL;
> - }
> + if (nl_connect(handle, NETLINK_ROUTE)) {
> + nl_handle_destroy(handle);
> + return NULL;
> + }
>
> - return handle;
> + return handle;
> }
>
> /*
> * Return an NETLINK_ROUTE cache.
> */
> -static struct nl_cache *_iface_get_link_cache(struct nl_handle
> **handle) {
> - struct nl_cache *cache = NULL;
> +static struct nl_cache *_iface_get_link_cache(struct nl_handle
> **handle)
> +{
> + struct nl_cache *cache = NULL;
>
> - if ((*handle = _iface_get_handle()) == NULL) {
> - return NULL;
> - }
> + if ((*handle = _iface_get_handle()) == NULL) {
> + return NULL;
> + }
>
> - if ((cache = rtnl_link_alloc_cache(*handle)) == NULL) {
> - nl_close(*handle);
> - nl_handle_destroy(*handle);
> - return NULL;
> - }
> + if ((cache = rtnl_link_alloc_cache(*handle)) == NULL) {
> + nl_close(*handle);
> + nl_handle_destroy(*handle);
> + return NULL;
> + }
>
> - return cache;
> + return cache;
> }
>
> /*
> * Determine if a struct in_addr or struct in6_addr contains a valid
> address.
> */
> -static int _iface_have_valid_addr(void *addr, int family, int length)
> {
> - char buf[length+1];
> -
> - if ((addr == NULL) || (family != AF_INET && family != AF_INET6))
> {
> - return 0;
> - }
> -
> - memset(buf, '', sizeof(buf));
> -
> - if (inet_ntop(family, addr, buf, length) == NULL) {
> - return 0;
> - } else {
> - /* check for unknown addresses */
> - if (family == AF_INET) {
> - if (!strncmp(buf, "0.0.0.0", 7)) {
> - return 0;
> - }
> - } else if (family == AF_INET6) {
> - if (!strncmp(buf, "::", 2)) {
> - return 0;
> - }
> - }
> - }
> -
> - return 1;
> +static int _iface_have_valid_addr(void *addr, int family, int
> length)
> +{
> + char buf[length + 1];
> +
> + if ((addr == NULL) || (family != AF_INET && family != AF_INET6)) {
> + return 0;
> + }
> +
> + memset(buf, '', sizeof(buf));
> +
> + if (inet_ntop(family, addr, buf, length) == NULL) {
> + return 0;
> + } else {
> + /* check for unknown addresses */
> + if (family == AF_INET) {
> + if (!strncmp(buf, "0.0.0.0", 7)) {
> + return 0;
> + }
> + } else if (family == AF_INET6) {
> + if (!strncmp(buf, "::", 2)) {
> + return 0;
> + }
> + }
> + }
> +
> + return 1;
> }
>
> /*
> * Redirect I/O to another device (e.g., stdout to /dev/tty5)
> */
> -int _iface_redirect_io(char *device, int fd, int mode) {
> - int io = -1;
> +int _iface_redirect_io(char *device, int fd, int mode)
> +{
> + int io = -1;
>
> - if ((io = open(device, mode)) == -1) {
> - return 1;
> - }
> + if ((io = open(device, mode)) == -1) {
> + return 1;
> + }
>
> - if (close(fd) == -1) {
> - return 2;
> - }
> + if (close(fd) == -1) {
> + return 2;
> + }
>
> - if (dup2(io, fd) == -1) {
> - return 3;
> - }
> + if (dup2(io, fd) == -1) {
> + return 3;
> + }
>
> - if (close(io) == -1) {
> - return 4;
> - }
> + if (close(io) == -1) {
> + return 4;
> + }
>
> - return 0;
> + return 0;
> }
>
> /*
> @@ -157,388 +161,402 @@ int _iface_redirect_io(char *device, int fd,
> int mode) {
> * return the IP address in human readable format (i.e., the output
> from
> * inet_ntop()). Return NULL for no match or error.
> */
> -char *iface_ip2str(char *ifname, int family) {
> - int i;
> - NMClient *client = NULL;
> - NMIP4Config *ip4config = NULL;
> - NMIP4Address *ipaddr = NULL;
> - NMDevice *candidate = NULL;
> - struct in_addr tmp_addr;
> - const GPtrArray *devices;
> - const char *iface;
> - char ipstr[INET_ADDRSTRLEN+1];
> -
> - if (ifname == NULL) {
> - return NULL;
> - }
> -
> - /* DCFIXME: add IPv6 once NM gains support */
> - if (family != AF_INET) {
> - return NULL;
> - }
> -
> - g_type_init();
> -
> - client = nm_client_new();
> - if (!client) {
> - return NULL;
> - }
> -
> - if (nm_client_get_state(client) != NM_STATE_CONNECTED) {
> - g_object_unref(client);
> - return NULL;
> - }
> -
> - devices = nm_client_get_devices(client);
> - for (i=0; i < devices->len; i++) {
> - candidate = g_ptr_array_index(devices, i);
> - iface = nm_device_get_iface(candidate);
> -
> - if (nm_device_get_state(candidate) !=
> NM_DEVICE_STATE_ACTIVATED)
> - continue;
> -
> - if (!iface || strcmp(iface, ifname))
> - continue;
> -
> - if (!(ip4config = nm_device_get_ip4_config(candidate)))
> - continue;
> -
> - if (!(ipaddr =
> nm_ip4_config_get_addresses(ip4config)->data))
> - continue;
> -
> - memset(&ipstr, '', sizeof(ipstr));
> - tmp_addr.s_addr = nm_ip4_address_get_address(ipaddr);
> -
> - if (inet_ntop(AF_INET, &tmp_addr, ipstr, INET_ADDRSTRLEN) ==
> NULL) {
> - g_object_unref(client);
> - return NULL;
> - }
> -
> - g_object_unref(client);
> - return g_strdup(ipstr);
> - }
> -
> - g_object_unref(client);
> - return NULL;
> +char *iface_ip2str(char *ifname, int family)
> +{
> + int i;
> + NMClient *client = NULL;
> + NMIP4Config *ip4config = NULL;
> + NMIP4Address *ipaddr = NULL;
> + NMDevice *candidate = NULL;
> + struct in_addr tmp_addr;
> + const GPtrArray *devices;
> + const char *iface;
> + char ipstr[INET_ADDRSTRLEN + 1];
> +
> + if (ifname == NULL) {
> + return NULL;
> + }
> +
> + /* DCFIXME: add IPv6 once NM gains support */
> + if (family != AF_INET) {
> + return NULL;
> + }
> +
> + g_type_init();
> +
> + client = nm_client_new();
> + if (!client) {
> + return NULL;
> + }
> +
> + if (nm_client_get_state(client) != NM_STATE_CONNECTED) {
> + g_object_unref(client);
> + return NULL;
> + }
> +
> + devices = nm_client_get_devices(client);
> + for (i = 0; i < devices->len; i++) {
> + candidate = g_ptr_array_index(devices, i);
> + iface = nm_device_get_iface(candidate);
> +
> + if (nm_device_get_state(candidate) != NM_DEVICE_STATE_ACTIVATED)
> + continue;
> +
> + if (!iface || strcmp(iface, ifname))
> + continue;
> +
> + if (!(ip4config = nm_device_get_ip4_config(candidate)))
> + continue;
> +
> + if (!(ipaddr = nm_ip4_config_get_addresses(ip4config)->data))
> + continue;
> +
> + memset(&ipstr, '', sizeof(ipstr));
> + tmp_addr.s_addr = nm_ip4_address_get_address(ipaddr);
> +
> + if (inet_ntop(AF_INET, &tmp_addr, ipstr, INET_ADDRSTRLEN) ==
> + NULL) {
> + g_object_unref(client);
> + return NULL;
> + }
> +
> + g_object_unref(client);
> + return g_strdup(ipstr);
> + }
> +
> + g_object_unref(client);
> + return NULL;
> }
>
> /* Given an interface's MAC address, return the name (e.g., eth0) in
> human
> * readable format. Return NULL for no match
> */
> -char *iface_mac2device(char *mac) {
> - struct nl_handle *handle = NULL;
> - struct nl_cache *cache = NULL;
> - struct rtnl_link *link = NULL;
> - struct nl_addr *mac_as_nl_addr = NULL;
> - char *retval = NULL;
> - int i, n;
> -
> - if (mac == NULL) {
> - return NULL;
> - }
> -
> - if ((mac_as_nl_addr = nl_addr_parse(mac, AF_LLC)) == NULL) {
> - return NULL;
> - }
> -
> - if ((cache = _iface_get_link_cache(&handle)) == NULL) {
> - return NULL;
> - }
> -
> - n = nl_cache_nitems(cache);
> - for (i = 0; i <= n; i++) {
> - struct nl_addr *addr;
> -
> - if ((link = rtnl_link_get(cache, i)) == NULL) {
> - continue;
> - }
> -
> - addr = rtnl_link_get_addr(link);
> -
> - if (!nl_addr_cmp(mac_as_nl_addr, addr)) {
> - retval = strdup(rtnl_link_get_name(link));
> - rtnl_link_put(link);
> - break;
> - }
> -
> - rtnl_link_put(link);
> - }
> -
> - nl_close(handle);
> - nl_handle_destroy(handle);
> -
> - return retval;
> +char *iface_mac2device(char *mac)
> +{
> + struct nl_handle *handle = NULL;
> + struct nl_cache *cache = NULL;
> + struct rtnl_link *link = NULL;
> + struct nl_addr *mac_as_nl_addr = NULL;
> + char *retval = NULL;
> + int i, n;
> +
> + if (mac == NULL) {
> + return NULL;
> + }
> +
> + if ((mac_as_nl_addr = nl_addr_parse(mac, AF_LLC)) == NULL) {
> + return NULL;
> + }
> +
> + if ((cache = _iface_get_link_cache(&handle)) == NULL) {
> + return NULL;
> + }
> +
> + n = nl_cache_nitems(cache);
> + for (i = 0; i <= n; i++) {
> + struct nl_addr *addr;
> +
> + if ((link = rtnl_link_get(cache, i)) == NULL) {
> + continue;
> + }
> +
> + addr = rtnl_link_get_addr(link);
> +
> + if (!nl_addr_cmp(mac_as_nl_addr, addr)) {
> + retval = strdup(rtnl_link_get_name(link));
> + rtnl_link_put(link);
> + break;
> + }
> +
> + rtnl_link_put(link);
> + }
> +
> + nl_close(handle);
> + nl_handle_destroy(handle);
> +
> + return retval;
> }
>
> /*
> * Given an interface name (e.g., eth0), return the MAC address in
> human
> * readable format (e.g., 00:11:52:129:A0). Return NULL for no
> match.
> */
> -char *iface_mac2str(char *ifname) {
> - int buflen = 20;
> - char *buf = NULL;
> - struct nl_handle *handle = NULL;
> - struct nl_cache *cache = NULL;
> - struct rtnl_link *link = NULL;
> - struct nl_addr *addr = NULL;
> -
> - if (ifname == NULL) {
> - return NULL;
> - }
> -
> - if ((cache = _iface_get_link_cache(&handle)) == NULL) {
> - return NULL;
> - }
> -
> - if ((link = rtnl_link_get_by_name(cache, ifname)) == NULL) {
> - goto mac2str_error2;
> - }
> -
> - if ((addr = rtnl_link_get_addr(link)) == NULL) {
> - goto mac2str_error3;
> - }
> -
> - if ((buf = calloc(sizeof(char *), buflen)) == NULL) {
> - goto mac2str_error4;
> - }
> -
> - if ((buf = nl_addr2str(addr, buf, buflen)) != NULL) {
> - buf = str2upper(buf);
> - }
> +char *iface_mac2str(char *ifname)
> +{
> + int buflen = 20;
> + char *buf = NULL;
> + struct nl_handle *handle = NULL;
> + struct nl_cache *cache = NULL;
> + struct rtnl_link *link = NULL;
> + struct nl_addr *addr = NULL;
> +
> + if (ifname == NULL) {
> + return NULL;
> + }
> +
> + if ((cache = _iface_get_link_cache(&handle)) == NULL) {
> + return NULL;
> + }
> +
> + if ((link = rtnl_link_get_by_name(cache, ifname)) == NULL) {
> + goto mac2str_error2;
> + }
> +
> + if ((addr = rtnl_link_get_addr(link)) == NULL) {
> + goto mac2str_error3;
> + }
> +
> + if ((buf = calloc(sizeof(char *), buflen)) == NULL) {
> + goto mac2str_error4;
> + }
> +
> + if ((buf = nl_addr2str(addr, buf, buflen)) != NULL) {
> + buf = str2upper(buf);
> + }
>
> mac2str_error4:
> - nl_addr_destroy(addr);
> + nl_addr_destroy(addr);
> mac2str_error3:
> - rtnl_link_put(link);
> + rtnl_link_put(link);
> mac2str_error2:
> - nl_close(handle);
> - nl_handle_destroy(handle);
> + nl_close(handle);
> + nl_handle_destroy(handle);
>
> - return buf;
> + return buf;
> }
>
> /*
> * Convert an IPv4 CIDR prefix to a dotted-quad netmask. Return NULL
> on
> * failure.
> */
> -struct in_addr *iface_prefix2netmask(int prefix) {
> - int mask = 0;
> - char *buf = NULL;
> - struct in_addr *ret;
> +struct in_addr *iface_prefix2netmask(int prefix)
> +{
> + int mask = 0;
> + char *buf = NULL;
> + struct in_addr *ret;
>
> - if ((buf = calloc(sizeof(char *), INET_ADDRSTRLEN + 1)) == NULL)
> {
> - return NULL;
> - }
> + if ((buf = calloc(sizeof(char *), INET_ADDRSTRLEN + 1)) == NULL) {
> + return NULL;
> + }
>
> - mask = htonl(~((1 << (32 - prefix)) - 1));
> + mask = htonl(~((1 << (32 - prefix)) - 1));
>
> - if (inet_ntop(AF_INET, (struct in_addr *) &mask, buf,
> - INET_ADDRSTRLEN) == NULL) {
> - return NULL;
> - }
> + if (inet_ntop(A
 
Old 12-17-2009, 02:17 PM
Jeremy Katz
 
Default Run everything through Lindent.

On Thu, Dec 17, 2009 at 9:04 AM, Martin Sivak <msivak@redhat.com> wrote:
> No way. As I said before, this breaks git blame history. We decided not to do this before and the arguments against it are still valid.

Check out 'git blame -w'[1]

- Jeremy

[1] Which didn't exist the last time we had this discussion afaik

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-17-2009, 02:30 PM
Chris Lumens
 
Default Run everything through Lindent.

> Check out 'git blame -w'[1]
>
> - Jeremy
>
> [1] Which didn't exist the last time we had this discussion afaik

Would be pretty excellent if this were controllable by git config, but
the man page is silent.

- Chris

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

Thread Tools




All times are GMT. The time now is 11:44 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org