commonsmachinery / blockhash

blockhash.io
MIT License
86 stars 28 forks source link

Compiler warnings with clang #20

Closed ilovezfs closed 7 years ago

ilovezfs commented 7 years ago
==> ./waf configure --prefix=/usr/local/Cellar/blockhash/0.2
Setting top to                           : /private/tmp/blockhash-20170113-97602-92yo9u/blockhash-0.2 
Setting out to                           : /private/tmp/blockhash-20170113-97602-92yo9u/blockhash-0.2/build 
Checking for 'gcc' (c compiler)          : clang 
Checking for library m                   : yes 
Checking for program pkg-config          : /usr/local/opt/pkg-config/bin/pkg-config 
Checking for 'MagickWand'                : yes 
Checking for 'MagickWand' version        : yes 
'configure' finished successfully (0.175s)
==> ./waf
Waf: Entering directory `/private/tmp/blockhash-20170113-97602-92yo9u/blockhash-0.2/build'
[1/2] c: blockhash.c -> build/blockhash.c.1.o
../blockhash.c:96:35: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
            blocks[j] = v > m || (abs(v - m) < 1 && m > half_block_value);
                                  ^
../blockhash.c:96:35: note: use function 'fabsf' instead
            blocks[j] = v > m || (abs(v - m) < 1 && m > half_block_value);
                                  ^~~
                                  fabsf
../blockhash.c:114:35: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
            result[j] = v > m || (abs(v - m) < 1 && m > half_block_value);
                                  ^
../blockhash.c:114:35: note: use function 'fabsf' instead
            result[j] = v > m || (abs(v - m) < 1 && m > half_block_value);
                                  ^~~
                                  fabsf
../blockhash.c:352:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
../blockhash.c:364:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main (int argc, char **argv) {
^
../blockhash.c:364:1: note: change return type to 'int'
void main (int argc, char **argv) {
^~~~
int
4 warnings generated.
[2/2] cprogram: build/blockhash.c.1.o -> build/blockhash
Waf: Leaving directory `/private/tmp/blockhash-20170113-97602-92yo9u/blockhash-0.2/build'
'build' finished successfully (0.232s)
artfwo commented 7 years ago

Hey, @ilovezfs, please try buliding current master, I don't have a clang at hand to test the changes above.

ilovezfs commented 7 years ago

Looks like it's happy now!

azyobuzin commented 7 years ago

I think it is not necessary to use abs to compare two numbers at blockhash.c#L96 because m and v in translate_blocks_to_bits are declared as int.