Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Sep 1995 22:06:59 -0400 (EDT)
From:      John Capo <jc@irbs.com>
To:        jmacd@cory.EECS.Berkeley.EDU (Josh MacDonald)
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: 64 bit off_t and varargs/printf
Message-ID:  <199509170207.WAA18567@irbs.irbs.com>
In-Reply-To: <199509170122.SAA12369@cory.EECS.Berkeley.EDU> from "Josh MacDonald" at Sep 16, 95 06:22:06 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Josh MacDonald writes:
> 
> 
> I'm working on porting rdist-6.1 to FreeBSD.  Its been a pain,
> because, for reasons I have not been able to determine, it is puking
> on a vsprintf() call with off_t's involved.  I wondered if anyone else
> has experienced this problem.  I'm really clueless about var_args and
> for me to debug this would require a lot of research.  I remember a
> discussion perhaps 6 months ago about a bug in wu-ftpd that was
> related to the off_t size, though I don't remember the conclusions
> made.  Basically, a call like this:
> 
> 	char num[10];
> 	num = "1234"
> 	off_t size;
> 	size = strtoq(num, &num, 10);
> 	printf("%d\n", size);
> 
> is causing it troubles.  Replacing the off_t type with a long fixes
> things.  Anyone know what might be happening?
> 

In FreeBSD an off_t is a 64 bit integer or a long long.  printf()
and friends know how to print this type even though the man page
does not mention it.

    printf("%d\n", (int)size);
	or
    printf("%qd\n", size);

Compiling with -Wformat should show you the places where arguments
to printf() and friends do not agree with the format string.

John Capo
IRBS Engineering




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509170207.WAA18567>