From: Raymund Will Subject: Fix all gcc warnings. + cc -Wall -g -D_FILE_OFFSET_BITS=64 -Isrc/lib -Isrc/include \ -c -o src/lib/disk.o src/lib/disk.c src/lib/disk.c: In function 'disk_get_ide_pci': src/lib/disk.c:195:9: warning: variable 'read_count' set but not used [-Wunused-but-set-variable] src/lib/disk.c: In function 'disk_get_partition_info': src/lib/disk.c:468:8: warning: variable 'offset' set but not used [-Wunused-but-set-variable] + cc -Wall -g -D_FILE_OFFSET_BITS=64 -Isrc/lib -Isrc/include \ -c -o src/lib/efi.o src/lib/efi.c src/lib/efi.c: In function 'is_parent_bridge': src/lib/efi.c:311:16: warning: variable 'primary' set but not used [-Wunused-but-set-variable] src/lib/efi.c: In function 'make_disk_load_option': src/lib/efi.c:536:10: warning: pointer targets in passing argument 5 of 'make_harddrive_device_path' differ in signedness [-Wpointer-sign] src/lib/efi.c:418:1: note: expected 'uint8_t *' but argument is of type 'char *' + cc -Wall -g -D_FILE_OFFSET_BITS=64 -Isrc/lib -Isrc/include \ -c -o src/lib/gpt.o src/lib/gpt.c src/lib/gpt.c: In function 'compare_gpts': src/lib/gpt.c:401:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:401:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:409:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:409:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:417:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:417:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:425:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:425:24: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:462:10: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] src/lib/gpt.c:470:10: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat] Signed-off-by: Raymund Will --- src/lib/disk.c | 10 +++++++++- src/lib/efi.c | 4 +++- src/lib/gpt.c | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) --- a/src/lib/disk.c +++ b/src/lib/disk.c @@ -211,6 +211,7 @@ disk_get_ide_pci(int fd, read_count = read(procfd, infoline, sizeof(infoline)-1); close(procfd); + infoline[(read_count < 0) ? 0 : read_count] = 0; num_scanned = sscanf(infoline, "pci bus %x device %x vid %*x did %*x channel %*x", &b, &d); @@ -375,7 +376,10 @@ msdos_disk_get_partition_info (int fd, l /* Write it to the disk */ lseek(fd, 0, SEEK_SET); - write(fd, mbr, sizeof(*mbr)); + rc = write(fd, mbr, sizeof(*mbr)); + if (rc == -1) { + perror("write unique MBR signature"); + } } *(uint32_t *)signature = mbr->unique_mbr_signature; @@ -478,6 +482,10 @@ disk_get_partition_info (int fd, memset(mbr_sector, '\0', mbr_size); offset = lseek(fd, 0, SEEK_SET); + if (offset) { + rc=1; + goto error_free_mbr; + } this_bytes_read = read(fd, mbr_sector, mbr_size); if (this_bytes_read < sizeof(*mbr)) { rc=1; --- a/src/lib/efi.c +++ b/src/lib/efi.c @@ -316,6 +316,8 @@ is_parent_bridge(struct pci_dev *p, unsi primary=pci_read_byte(p, PCI_PRIMARY_BUS); secondary=pci_read_byte(p, PCI_SECONDARY_BUS); + if (primary == 0xFF) + /* return NULL*/; /* don't care!? */ if (secondary != target_bus) return NULL; @@ -416,7 +418,7 @@ make_scsi_device_path(void *dest, uint16 static uint16_t make_harddrive_device_path(void *dest, uint32_t num, uint64_t start, uint64_t size, - uint8_t *signature, + char *signature, uint8_t mbr_type, uint8_t signature_type) { HARDDRIVE_DEVICE_PATH p; --- a/src/lib/gpt.c +++ b/src/lib/gpt.c @@ -32,7 +32,16 @@ #include #include #include +#if 0 +/* don't use kernel headers! */ #include +#else +#include +#define __le16_to_cpu le16toh +#define __le32_to_cpu le32toh +#define __le64_to_cpu le64toh +#define __cpu_to_le32 htole32 +#endif #include "crc32.h" #include "disk.h" #include "gpt.h"