X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=probe_roms.c;h=a8e3a5896f76f6a5d3fb85c9ffd6498e8b253ea3;hb=d0ab945ee11ddc5d4ff301d09b6b91b95770bf31;hp=a9a86388f394233fd36796e7713ea43ce8d71a2f;hpb=823f06865e1c79865004b81de35fc4b6338d9492;p=thirdparty%2Fmdadm.git diff --git a/probe_roms.c b/probe_roms.c index a9a86388..a8e3a589 100644 --- a/probe_roms.c +++ b/probe_roms.c @@ -30,7 +30,7 @@ static void *rom_mem = MAP_FAILED; static int rom_fd = -1; -const static int rom_len = 0xf0000 - 0xc0000; /* option-rom memory region */ +static const int rom_len = 0xf0000 - 0xc0000; /* option-rom memory region */ static int _sigbus; static unsigned long rom_align; @@ -80,7 +80,7 @@ void probe_roms_exit(void) int probe_roms_init(unsigned long align) { - int fd; + int fd = -1; int rc = 0; /* valid values are 2048 and 512. 512 is for PCI-3.0 compliant @@ -107,9 +107,11 @@ int probe_roms_init(unsigned long align) if (rc == 0) rom_fd = fd; - else + else { + if (fd >= 0) + close(fd); probe_roms_exit(); - + } return rc; } @@ -197,7 +199,7 @@ static int romchecksum(const unsigned char *rom, unsigned long length) int scan_adapter_roms(scan_fn fn) { /* let scan_fn examing each of the adapter roms found by probe_roms */ - int i; + unsigned int i; int found; if (rom_fd < 0) @@ -229,7 +231,7 @@ void probe_roms(void) const void *rom; unsigned long start, length, upper; unsigned char c; - int i; + unsigned int i; if (rom_fd < 0) return;