standards/55112: glob.h, glob_t's gl_pathc should be "size_t", not "int".

Peter Edwards petere at openet-telecom.com
Thu Jul 31 05:30:13 PDT 2003


>Number:         55112
>Category:       standards
>Synopsis:       glob.h, glob_t's gl_pathc should be "size_t", not "int".
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 31 05:30:06 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Peter Edwards
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:

System: FreeBSD rocklobster 5.1-CURRENT FreeBSD 5.1-CURRENT #8: Wed Jul 9 12:08:31 IST 2003 nfs at archie:/pub/FreeBSD/obj/pub/FreeBSD/current/src/sys/ROCKLOBSTER i386

>Description:

SUSv2 and v3 define the gl_pathc field of glob_t to be size_t.
FreeBSD disagrees. Worst case scenario is annoying warnings when
using glob with C++, so it's not too serious.

>How-To-Repeat:
Compile a construct such as this...

>	size_t i;
>	if (glob(argv[1], 0, 0, &g) == 0)
>		for (i = 0; i < g.gl_pathc; i++)
>			printf("%s\n", g.gl_pathv[i]);

... with g++, using -Wall to be warned about comparing signed and unsigned
values. Solaris, HP-UX, etc, have gl_pathc as size_t.

>Fix:

Apart from updating the header file, the following use gl_pathc in
the base system:

crypto/heimdal/appl/ftp/ftp/cmds.c
crypto/heimdal/appl/ftp/ftpd/ftpd.c
crypto/heimdal/appl/ftp/ftpd/popen.c
crypto/openssh/sftp-int.c
libexec/ftpd/ftpd.c
sbin/restore/interactive.c
usr.bin/login/login_fbtab.c

(tcsh uses its own version of glob, and there are several other
copies of glob.c lying around, but the only objects that get built
seem to be the system one and the csh one.)

Of the above files, only interactive.c and login_fbtab.c assign or
compare gl_pathc with a typed variable. Neither further expose that
type outside their own translation unit, so the changes are all
localised.

I'll supply a patch on request: I don't fancy doing the donkey work
and doing a buildworld/installworld if nothing's going to be
committed.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-standards mailing list