bin/80378: Possible mis-declaration of __sglue in /usr/src/lib/libc/stdio/glue.h

John Engelhart johne at zang.com
Tue Apr 26 14:40:20 PDT 2005


>Number:         80378
>Category:       bin
>Synopsis:       Possible mis-declaration of __sglue in /usr/src/lib/libc/stdio/glue.h
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 26 21:40:19 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     John Engelhart
>Release:        FreeBSD 5.3-RELEASE-p5
>Organization:
>Environment:
FreeBSD new.zang.com 5.3-RELEASE-p5 FreeBSD 5.3-RELEASE-p5 #0: Mon Mar  7 03:05:55 EST 2005     johne at new.zang.com:/usr/src/sys/i386/compile/new  i386
>Description:
Someone should make a quick check as to the intentions of the declaration of __sglue inside /usr/src/lib/libc/stdio/glue.h.

The files stdio/findfp.c and stdio/fwalk.c both refer to it, and glue.h's declaration is:

struct glue {
        struct  glue *next;
        int     niobs;
        FILE    *iobs;
} __sglue;

This causes both files to allocate this symbol, though findfp.c is clearing the one that declares and initilizes the structure, and fwalk.c only makes reference to it.  fwalk.c ends up allocating BSS space for it.  The linker seems to either silently ignore this and "do the right thing", or just.. who knows.  Didn't quite dig that far.

Regardless, I think what was intended was for glue.h to declare it extern, and then findfp.c to create it, and fwalk.c to refer to findfp.c's declaration.
>How-To-Repeat:
n/a, see affected files.      
>Fix:
I believe what was really intended in glue.h was:

struct glue {
        struct  glue *next;
        int     niobs;
        FILE    *iobs;
};
extern struct glue __sglue;
      
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list