ajs124 / ioping

Automatically exported from code.google.com/p/ioping
GNU General Public License v3.0
0 stars 0 forks source link

no fdatasync on FreeBSD platform (possible other BSDs), CLANG warning about incompatible type of VERSION #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Compilation of ioping v0.7 is broken under FreeBSD with follow error:

--
ioping.c:579:17: warning: implicit declaration of function 'fdatasync' is 
invalid in C99 [-Wimplicit-function-declaration]
        if (!cached && fdatasync(fd) < 0)
                       ^
2 warnings generated.
/tmp/ioping-QYo1BH.o: In function `do_pwrite':
ioping.c:(.text+0xb16): undefined reference to `fdatasync'
--

cause there no fdatasync functions. fsync(2) must be used instead.

Also, CLANG out the warning about incompatible format for VERSION variable:

--
ioping.c:225:33: warning: format specifies type 'char *' but the argument has 
type 'double' [-Wformat]
        fprintf(stderr, "ioping %s\n", VERSION);
                                ~~     ^~~~~~~
                                %f
<command line>:1:17: note: expanded from here
#define VERSION 0.7
                ^~~
--

Ive don't know what is correct solution to fix this:

-- fprintf(stderr, "ioping %f\n", VERSION);
++ fprintf(stderr, "ioping %f\n", VERSION);

or

-- #define VERSION 0.7
++ #define VERSION "0.7"

or  (char *)VERSION

Temporary ive apply %f type for fprintf.

Please review attached patch.

Original issue reported on code.google.com by oleg.gin...@nevosoft.ru on 23 Jul 2013 at 12:18

Attachments:

GoogleCodeExporter commented 9 years ago
FreeBSD really still doesn't have fdatasync? Try patch from git.

VERSION came from Makefile where it's defined as string contant: 
-DVERSION=\"${VERSION}\"
So probably this doesn't work with your 'make'. Please try normal gnu make.

Original comment by koct9i on 24 Jul 2013 at 7:04

GoogleCodeExporter commented 9 years ago
On Wednesday 24 July 2013 19:04:15 you wrote:

Thanks, patch works for me. 

I'm not sure that the root of problem in "not gnu" make, as it is the compiler 
generates a warning. A short example on MacOSX 10.8.3 Mountain Lion:

mac-builder$ cat test.c
#include <stdio.h>

#define TEST 0.1

int main()
{
printf("%s",TEST);
}

mac-builder$ cc test.c 
test.c:8:10: warning: format specifies type 'char *' but the argument has type 
'double' [-Wformat]
printf("%s",TEST);
        ~^  ~~~~
        %f
1 warning generated.

mac-builder$ cc -v
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix

Original comment by oleg.gin...@nevosoft.ru on 24 Jul 2013 at 8:10

GoogleCodeExporter commented 9 years ago
VERSION must be defined as string "0.7" not as float 0.7
Escaped quotation marks in makefile must be part of it.

Original comment by koct9i on 24 Jul 2013 at 8:15

GoogleCodeExporter commented 9 years ago
Ok. Thank you for detail. Please close this ticket.

Original comment by oleg.gin...@nevosoft.ru on 24 Jul 2013 at 8:26

GoogleCodeExporter commented 9 years ago

Original comment by koct9i on 25 Jul 2013 at 5:52