From c561f24adbce7b2e7aca4c4adf2ad32dae73435f Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 14 Apr 2014 16:39:42 -0400
Subject: [PATCH 02/22] Get a lot more picky with our compiler warnings.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Makefile | 2 +-
src/efibootmgr/efibootmgr.c | 9 ++++++---
src/include/efibootmgr.h | 4 ++--
src/lib/disk.c | 7 ++++---
src/lib/efi.c | 2 +-
src/lib/efichar.c | 4 ++--
src/lib/unparse_path.c | 2 +-
7 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index 610e165..c6e8e4a 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)
CFLAGS = $(EXTRA_CFLAGS) -DEFIBOOTMGR_VERSION=\"$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)\" \
- -Wall -g -D_FILE_OFFSET_BITS=64
+ -Wsign-compare -Wall -Werror -g -D_FILE_OFFSET_BITS=64
MODULES := src
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 98eea81..1bc48b2 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -342,7 +342,7 @@ remove_from_boot_order(uint16_t num)
efi_variable_t *boot_order = NULL;
uint64_t new_data_size;
uint16_t *new_data, *old_data;
- int old_i,new_i;
+ unsigned int old_i,new_i;
int rc;
rc = read_boot_order(&boot_order);
@@ -693,7 +693,7 @@ show_boot_vars()
printf("\n");
continue;
}
- if (optional_data_len > path->length + 4) {
+ if (optional_data_len > (uint64_t)(path->length + 4)) {
printf("(invalid optional data length)\n");
continue;
}
@@ -1083,7 +1083,10 @@ main(int argc, char **argv)
return 0;
}
- if (opts.iface && opts.acpi_hid == -1 && opts.acpi_uid == -1) {
+ if (opts.iface && (
+ opts.acpi_hid < 0 || opts.acpi_uid < 0 ||
+ opts.acpi_hid > UINT32_MAX ||
+ opts.acpi_uid > UINT32_MAX)) {
fprintf(stderr, "\nYou must specify the ACPI HID and UID when using -i.\n\n");
return 1;
}
diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h
index a1cbcec..87c83bb 100644
--- a/src/include/efibootmgr.h
+++ b/src/include/efibootmgr.h
@@ -40,8 +40,8 @@ typedef struct {
int bootnext;
int verbose;
int active;
- uint32_t acpi_hid;
- uint32_t acpi_uid;
+ int64_t acpi_hid;
+ int64_t acpi_uid;
unsigned int delete_boot:1;
unsigned int delete_bootorder:1;
unsigned int delete_bootnext:1;
diff --git a/src/lib/disk.c b/src/lib/disk.c
index eb2f54c..636b509 100644
--- a/src/lib/disk.c
+++ b/src/lib/disk.c
@@ -165,7 +165,8 @@ disk_info_from_fd(int fd, struct disk_info *info)
return 0;
}
- if (get_virtblk_major() != -1 && get_virtblk_major() == info->major) {
+ if (get_virtblk_major() >= 0 &&
+ (uint64_t)get_virtblk_major() == info->major) {
info->interface_type = virtblk;
info->disknum = info->minor >> 4;
info->part = info->minor & 0xF;
@@ -184,7 +185,7 @@ disk_get_virt_pci(const struct disk_info *info, unsigned char *bus,
ssize_t lnksz;
if (snprintf(inbuf, sizeof inbuf, "/sys/dev/block/%" PRIu64 ":%u",
- info->major, info->minor) >= sizeof inbuf) {
+ info->major, info->minor) >= (ssize_t)(sizeof inbuf)) {
return 1;
}
@@ -544,7 +545,7 @@ disk_get_partition_info (int fd,
offset = lseek(fd, 0, SEEK_SET);
this_bytes_read = read(fd, mbr_sector, mbr_size);
- if (this_bytes_read < sizeof(*mbr)) {
+ if (this_bytes_read < (ssize_t)sizeof(*mbr)) {
rc=1;
goto error_free_mbr;
}
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 6e9a01f..078bbc5 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -557,7 +557,7 @@ get_virt_pci(char *name, unsigned char *bus,
ssize_t lnksz;
if (snprintf(inbuf, sizeof inbuf, "/sys/bus/virtio/devices/%s",
- name) >= sizeof inbuf) {
+ name) >= (ssize_t)(sizeof inbuf)) {
return -1;
}
diff --git a/src/lib/efichar.c b/src/lib/efichar.c
index 831c759..b49b5a0 100644
--- a/src/lib/efichar.c
+++ b/src/lib/efichar.c
@@ -71,7 +71,7 @@ efichar_strcmp(const efi_char16_t *s1, const efi_char16_t *s2)
unsigned long
efichar_from_char(efi_char16_t *dest, const char *src, size_t dest_len)
{
- int i, src_len = strlen(src);
+ unsigned int i, src_len = strlen(src);
for (i=0; i < src_len && i < (dest_len/sizeof(*dest)) - 1; i++) {
dest[i] = src[i];
}
@@ -82,7 +82,7 @@ efichar_from_char(efi_char16_t *dest, const char *src, size_t dest_len)
unsigned long
efichar_to_char(char *dest, const efi_char16_t *src, size_t dest_len)
{
- int i, src_len = efichar_strlen(src, -1);
+ unsigned int i, src_len = efichar_strlen(src, -1);
for (i=0; i < src_len && i < (dest_len/sizeof(*dest)) - 1; i++) {
dest[i] = src[i];
}
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index 054ef9d..27e1dbb 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -505,7 +505,7 @@ unparse_path(char *buffer, size_t buffer_size,
buf_offset += needed;
if (path->length + sizeof (END_DEVICE_PATH)
- > pathsize - parsed_length) {
+ > (uint64_t)(pathsize - parsed_length)){
needed = snprintf(p + buf_offset,
buffer_size == 0
? 0
--
1.9.3