Skip to content

Commit

Permalink
[zbin] Fix compiler warning with GCC 9
Browse files Browse the repository at this point in the history
GCC 9 warns that abs() may truncate its signed long argument.  Fix by
using labs() instead.

Reported-by: Martin Liška <mliska@suse.cz>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jan 21, 2019
1 parent 3946aa9 commit 956f6a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/util/zbin.c
Expand Up @@ -386,16 +386,16 @@ static int process_zinfo_add ( struct input_file *input
( ( 1UL << ( 8 * datasize ) ) - 1 ) : ~0UL );

if ( val < 0 ) {
fprintf ( stderr, "Add %s%#x+%#lx at %#zx %sflows field\n",
( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
fprintf ( stderr, "Add %s%#lx+%#lx at %#zx %sflows field\n",
( ( addend < 0 ) ? "-" : "" ), labs ( addend ), size,
offset, ( ( addend < 0 ) ? "under" : "over" ) );
return -1;
}

if ( val & ~mask ) {
fprintf ( stderr, "Add %s%#x+%#lx at %#zx overflows %zd-byte "
fprintf ( stderr, "Add %s%#lx+%#lx at %#zx overflows %zd-byte "
"field (%d bytes too big)\n",
( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
( ( addend < 0 ) ? "-" : "" ), labs ( addend ), size,
offset, datasize,
( int )( ( val - mask - 1 ) * add->divisor ) );
return -1;
Expand All @@ -414,9 +414,9 @@ static int process_zinfo_add ( struct input_file *input
}

if ( DEBUG ) {
fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#zx/%#x)) = "
fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#lx+(%#zx/%#x)) = "
"%#lx\n", offset, ( offset + datasize ),
( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
( ( addend < 0 ) ? "-" : "" ), labs ( addend ),
len, add->divisor, val );
}

Expand Down

0 comments on commit 956f6a7

Please sign in to comment.