Bug 167080 - ftw() syscall incompatible pointer type with gcc4
Summary: ftw() syscall incompatible pointer type with gcc4
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc4   
(Show other bugs)
Version: 4
Hardware: i586
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-08-30 02:19 UTC by J. Erik Hemdal
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-08-30 07:25:09 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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-30 02:19 UTC, J. Erik Hemdal
no flags Details

Description J. Erik Hemdal 2005-08-30 02:19:13 UTC
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
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=i386-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)


How reproducible:

Always

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-30 02:19:14 UTC
Created attachment 118234 [details]
Testcase: compile with 'gcc ftw.c'

Comment 2 Jakub Jelinek 2005-08-30 07:25:09 UTC
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);
or
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.