diff options
author | Eric Anholt <eric@anholt.net> | 2009-10-06 16:30:08 -0700 |
---|---|---|
committer | Owain G. Ainsworth <oga@openbsd.org> | 2010-02-28 23:35:15 +0000 |
commit | 503357c5c0b28d60f7cc608887f0bbd270cf2b45 (patch) | |
tree | cd2f807b284b2d7f55c275fdedcfcf2d85760cba /src/bios_reader/bios_dumper.c | |
parent | 9f587cfdc59484fca2cf466679c526983114fd22 (diff) |
Move to kernel coding style.
We've talked about doing this since the start of the project, putting it off
until "some convenient time". Just after removing a third of the driver seems
like a convenient time, when backporting's probably not happening much anyway.
(cherry picked from 8ae0e44e42db645abe6d385f561260d2ae4a1960 commit)
Diffstat (limited to 'src/bios_reader/bios_dumper.c')
-rw-r--r-- | src/bios_reader/bios_dumper.c | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/src/bios_reader/bios_dumper.c b/src/bios_reader/bios_dumper.c index 1353edaa..53293ebd 100644 --- a/src/bios_reader/bios_dumper.c +++ b/src/bios_reader/bios_dumper.c @@ -37,68 +37,71 @@ #include <err.h> #ifndef DEFFILEMODE -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* 0666*/ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* 0666 */ #endif static void usage(void) { - fprintf(stderr, "usage: bios_dumper <filename>\n"); - exit(1); + fprintf(stderr, "usage: bios_dumper <filename>\n"); + exit(1); } int main(int argc, char **argv) { - struct pci_device *dev; - void *bios; - int err, fd; + struct pci_device *dev; + void *bios; + int err, fd; - if (argc != 2) - usage(); + if (argc != 2) + usage(); - err = pci_system_init(); - if (err != 0) { - fprintf(stderr, "Couldn't initialize PCI system: %s\n", strerror(err)); - exit(1); - } + err = pci_system_init(); + if (err != 0) { + fprintf(stderr, "Couldn't initialize PCI system: %s\n", + strerror(err)); + exit(1); + } - /* Grab the graphics card */ - dev = pci_device_find_by_slot(0, 0, 2, 0); - if (dev == NULL) - errx(1, "Couldn't find graphics card"); + /* Grab the graphics card */ + dev = pci_device_find_by_slot(0, 0, 2, 0); + if (dev == NULL) + errx(1, "Couldn't find graphics card"); - err = pci_device_probe(dev); - if (err != 0) { - fprintf(stderr, "Couldn't probe graphics card: %s\n", strerror(err)); - exit(1); - } + err = pci_device_probe(dev); + if (err != 0) { + fprintf(stderr, "Couldn't probe graphics card: %s\n", + strerror(err)); + exit(1); + } - if (dev->vendor_id != 0x8086) - errx(1, "Graphics card is non-intel"); + if (dev->vendor_id != 0x8086) + errx(1, "Graphics card is non-intel"); - bios = malloc(dev->rom_size); - if (bios == NULL) - errx(1, "Couldn't allocate memory for BIOS data\n"); + bios = malloc(dev->rom_size); + if (bios == NULL) + errx(1, "Couldn't allocate memory for BIOS data\n"); - err = pci_device_read_rom(dev, bios); - if (err != 0) { - fprintf(stderr, "Couldn't read graphics card ROM: %s\n", - strerror(err)); - exit(1); - } + err = pci_device_read_rom(dev, bios); + if (err != 0) { + fprintf(stderr, "Couldn't read graphics card ROM: %s\n", + strerror(err)); + exit(1); + } - fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE); - if (fd < 0) { - fprintf(stderr, "Couldn't open output: %s\n", strerror(errno)); - exit(1); - } + fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE); + if (fd < 0) { + fprintf(stderr, "Couldn't open output: %s\n", strerror(errno)); + exit(1); + } - if (write(fd, bios, dev->rom_size) < dev->rom_size) { - fprintf(stderr, "Couldn't write BIOS data: %s\n", strerror(errno)); - exit(1); - } + if (write(fd, bios, dev->rom_size) < dev->rom_size) { + fprintf(stderr, "Couldn't write BIOS data: %s\n", + strerror(errno)); + exit(1); + } - close(fd); - pci_system_cleanup(); + close(fd); + pci_system_cleanup(); - return 0; + return 0; } |