From: Karel Zak Date: Tue, 23 Oct 2012 13:10:26 +0000 (+0200) Subject: fdisk: fix compiler warning [-Wpointer-arith] and floating point exception X-Git-Tag: v2.23-rc1~577 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f3b568cd7c7f618ad22ef7a3d07c3db28dfa77e;p=thirdparty%2Futil-linux.git fdisk: fix compiler warning [-Wpointer-arith] and floating point exception Signed-off-by: Karel Zak --- diff --git a/fdisks/fdisksgilabel.c b/fdisks/fdisksgilabel.c index 665d3e75b3..79313624ef 100644 --- a/fdisks/fdisksgilabel.c +++ b/fdisks/fdisksgilabel.c @@ -393,25 +393,26 @@ compare_start(struct fdisk_context *cxt, const void *x, const void *y) { return (a > b) ? 1 : -1; } -static void generic_swap(void *a, void *b, int size) +static void generic_swap(void *a0, void *b0, int size) { - char t; + char *a = a0, *b = b0; - do { - t = *(char *)a; - *(char *)a++ = *(char *)b; - *(char *)b++ = t; - } while (--size > 0); + for (; size > 0; --size, a++, b++) { + char t = *a; + *a = *b; + *b = t; + } } /* heap sort, based on Matt Mackall's linux kernel version */ -static void sort(void *base, size_t num, size_t size, struct fdisk_context *cxt, +static void sort(void *base0, size_t num, size_t size, struct fdisk_context *cxt, int (*cmp_func)(struct fdisk_context *, const void *, const void *)) { /* pre-scale counters for performance */ int i = (num/2 - 1) * size; size_t n = num * size, c, r; + char *base = base0; /* heapify */ for ( ; i >= 0; i -= size) { @@ -493,13 +494,14 @@ static int sgi_verify_disklabel(struct fdisk_context *cxt) } for (i=1, start=0; i 1) { if (verbose) diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c index 04d9c73753..5b77c49561 100644 --- a/sys-utils/readprofile.c +++ b/sys-utils/readprofile.c @@ -229,7 +229,7 @@ int main(int argc, char **argv) to_write = 1; } /* try to become root, just in case */ - setuid(0); + ignore_result( setuid(0) ); fd = open(defaultpro, O_WRONLY); if (fd < 0) err(EXIT_FAILURE, "%s", defaultpro);