From nobody@FreeBSD.org  Tue Apr 26 21:35:00 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9808C16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Apr 2005 21:35:00 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 72D4543D5A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Apr 2005 21:35:00 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j3QLYx4i099182
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Apr 2005 21:34:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j3QLYxoB099181;
	Tue, 26 Apr 2005 21:34:59 GMT
	(envelope-from nobody)
Message-Id: <200504262134.j3QLYxoB099181@www.freebsd.org>
Date: Tue, 26 Apr 2005 21:34:59 GMT
From: John Engelhart <johne@zang.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Possible mis-declaration of __sglue in /usr/src/lib/libc/stdio/glue.h
X-Send-Pr-Version: www-2.3

>Number:         80378
>Category:       kern
>Synopsis:       [patch] Possible mis-declaration of __sglue in /usr/src/lib/libc/stdio/glue.h
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    stefanf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 26 21:40:19 GMT 2005
>Closed-Date:    Thu May 26 19:54:48 GMT 2005
>Last-Modified:  Thu May 26 19:54:48 GMT 2005
>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@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:
Responsible-Changed-From-To: freebsd-bugs->stefanf@FreeBSD.org 
Responsible-Changed-By: stefanf 
Responsible-Changed-When: Tue May 3 21:24:50 GMT 2005 
Responsible-Changed-Why:  
Over to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80378 
State-Changed-From-To: open->patched 
State-Changed-By: stefanf 
State-Changed-When: Fri May 13 21:13:14 GMT 2005 
State-Changed-Why:  
Committed to -current, thanks! 


Responsible-Changed-From-To: stefanf@FreeBSD.org->stefanf 
Responsible-Changed-By: stefanf 
Responsible-Changed-When: Fri May 13 21:13:14 GMT 2005 
Responsible-Changed-Why:  
Committed to -current, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80378 
State-Changed-From-To: patched->closed 
State-Changed-By: stefanf 
State-Changed-When: Thu May 26 19:53:22 GMT 2005 
State-Changed-Why:  
Merged to stable. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80378 
>Unformatted:
