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

Peter Edwards petere at
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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 31 05:30:06 PDT 2003
>Originator:     Peter Edwards
>Release:        FreeBSD 5.1-CURRENT i386

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


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.

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.


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


(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

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

More information about the freebsd-standards mailing list