Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 167080 - ftw() syscall incompatible pointer type with gcc4
ftw() syscall incompatible pointer type with gcc4
Product: Fedora
Classification: Fedora
Component: gcc4 (Show other bugs)
i586 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2005-08-29 22:19 EDT by J. Erik Hemdal
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-08-30 03:25:09 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Testcase: compile with 'gcc ftw.c' (792 bytes, text/plain)
2005-08-29 22:19 EDT, J. Erik Hemdal
no flags Details

  None (edit)
Description J. Erik Hemdal 2005-08-29 22:19:13 EDT
Description of problem:
The ftw() syscall needs a pointer to a callback function that returns an int,
according to the manpage for ftw(3).

But a program that uses ftw() produces an warning for an incompatible pointer
type for this argument (test case attached).

I am not sure if this is a user error, a syscall issue or a manpage erratum.

Version-Release number of selected component (if applicable):

gcc -v produces

Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)

How reproducible:


Steps to Reproduce:

1.  Compile the attached testcase ftw.c using GCC, and see the warning

ftw.c: In function ‘main’:
ftw.c:38: warning: passing argument 2 of ‘ftw’ from incompatible pointer type

2.  The program appears to run correctly (it lists filetypes for all files
under "/home").  But the warning persists.

Actual results:

Warning as shown above.

Expected results:

No warnings.

Additional info:

Casts to (int *) and to __ftw_func_t did not clear the warning.
Comment 1 J. Erik Hemdal 2005-08-29 22:19:14 EDT
Created attachment 118234 [details]
Testcase: compile with 'gcc ftw.c'
Comment 2 Jakub Jelinek 2005-08-30 03:25:09 EDT
1) ftw is not a syscall
2) this is a user error
Look at ftw prototype from man page:
int ftw(const char *dir, int (*fn)(const char *file, const struct stat *sb, int
flag), int nopenfd);
info libc --index-search="ftw"
where __ftw_func_t has
int (*) (const char *, const struct stat *, int)
type.  But you are passing a funciton with incompatible type - 
int (*) (char *, struct stat *, int).
Add the const keywords and the warnings will go away.

Note You need to log in before you can comment on or make changes to this bug.