ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 36513: /trunk/wiretap/ /trunk/wireta

From: Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Apr 2011 10:13:16 -0600
This revision broke builds on FreeBSD 8.2-RELEASE (64-bit):

file_access.c:924: warning: dereferencing 'void *' pointer
file_access.c:924: error: request for member '_file' in something not a 
structure or union
file_access.c: In function 'wtap_dump_file_write':
file_access.c:1084: warning: dereferencing 'void *' pointer
file_access.c:1084: error: request for member '_flags' in something not 
a structure or union
gmake[2]: *** [libwiretap_la-file_access.lo] Error 1

It is referring to these two lines:

 924: fd = fileno(wdh->fh);
1084: if (ferror(wdh->fh))

"wdh" is a wtap_dumper struct, which contains (wtap-int.h):

struct wtap_dumper {
	WFILE_T			fh;

"WFILE_T" is defined in my case to be a gzFile:

#ifdef HAVE_LIBZ
#include <zlib.h>
#define WFILE_T	gzFile
#else /* No zLib */
#define WFILE_T	FILE *
#endif /* HAVE_LIBZ */

And "gzFile" is (from /usr/include/zlib.h):

typedef voidp gzFile;

But it would still work if I don't have zLib, in which case WFILE_T 
would be a "FILE*" (from /usr/include/stdio.h), which is a struct with 
many items including:

short   _flags;         /* (*) flags, below; this FILE is free if 0 */
short   _file;          /* (*) fileno, if Unix descriptor, else -1 */

... which the fileno() and ferror() functions are trying to use:

(from /usr/src/lib/libc/stdio/fileno.c)

int
fileno(FILE *fp)
{
        int fd;

        FLOCKFILE(fp);
        fd = __sfileno(fp);
        FUNLOCKFILE(fp);

        return (fd);
}

(from /usr/src/lib/libc/stdio/ferror.c)

int
ferror(FILE *fp)
{
        int     ret;

        FLOCKFILE(fp);
        ret = __sferror(fp);
        FUNLOCKFILE(fp);
        return (ret);
}

__sfileno and __sferror are defined in /usr/include/stdio.h:

#define __sfileno(p)    ((p)->_file)
#define __sferror(p)    (((p)->_flags & __SERR) != 0)


On Fri, Apr 08, 2011 at 12:28:40AM +0000, guy@xxxxxxxxxxxxx wrote:
> http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=36513
> 
> User: guy
> Date: 2011/04/07 05:28 PM
> 
> Log:
>  From Jakub Zawadzki:
>  
>  Steal file_wrappers functions from zlib v2.
> 
> Directory: /trunk/wiretap/
>   Changes    Path               Action
>   +8 -8      file_access.c      Modified
>   +626 -188  file_wrappers.c    Modified
>   +10 -27    file_wrappers.h    Modified
>   +30 -3     wtap-int.h         Modified
>   +0 -2      wtap.c             Modified
> 
> ___________________________________________________________________________
> Sent via:    Wireshark-commits mailing list <wireshark-commits@xxxxxxxxxxxxx>
> Archives:    http://www.wireshark.org/lists/wireshark-commits
> Unsubscribe: https://wireshark.org/mailman/options/wireshark-commits
>              mailto:wireshark-commits-request@xxxxxxxxxxxxx?subject=unsubscribe