[ofa-general] dtest.c: mismatch between %d formats and 64 bit (unsigned) integers
Harold Iuzzolino
iuzzolin at nmia.com
Thu Aug 28 22:45:25 PDT 2008
Dear Openfabrics, general at lists.openfabrics.org
Bug #1 in dtest.c: mismatch between %d formats and 64 bit (unsigned)
integers
gcc complains about the formats used (%d, %llx, %x) for 64 bit integers.
Should the %d be %ld and the %x be %lx? I'm not sure what the %llx should
be
changed to. I'm running on a 64 bit machine, but as far as I can tell,
DAT_PORT_QUAL, DAT_VLEN and DAT_VADDR are defined as 64 bit integers even
on a 32 bit machine.
--------------------------------------
gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I ./../../dat/include -O2 -g
-pipe
-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -MT dtest.o -MD -MP -MF
".deps/dtest.Tpo" -c -o dtest.o dtest.c
dtest.c:362: warning: format '%d' expects type 'int', but argument 4 has
type
'DAT_PORT_QUAL'
dtest.c:367: warning: format '%d' expects type 'int', but argument 4 has
type
'DAT_PORT_QUAL'
dtest.c:583: warning: format '%d' expects type 'int', but argument 4 has
type
'DAT_VLEN'
dtest.c:613: warning: format '%d' expects type 'int', but argument 4 has
type
'long unsigned int'
dtest.c:805: warning: format '%llx' expects type 'long long unsigned int',
but
argument 5 has type 'DAT_VADDR'
dtest.c:805: warning: format '%x' expects type 'unsigned int', but
argument 6
has type 'DAT_VLEN'
dtest.c:868: warning: format '%d' expects type 'int', but argument 5 has
type
'long unsigned int'
dtest.c:876: warning: format '%llx' expects type 'long long unsigned int',
but
argument 5 has type 'DAT_VADDR'
dtest.c:876: warning: format '%x' expects type 'unsigned int', but
argument 6
has type 'DAT_VLEN'
dtest.c:997: warning: format '%d' expects type 'int', but argument 5 has
type
'DAT_VLEN'
dtest.c:1087: warning: format '%d' expects type 'int', but argument 5 has
type
'long unsigned int'
dtest.c:1098: warning: format '%x' expects type 'unsigned int', but
argument 6
has type 'DAT_VLEN'
dtest.c:1197: warning: format '%d' expects type 'int', but argument 4 has
type
'DAT_VLEN'
dtest.c:1279: warning: format '%d' expects type 'int', but argument 5 has
type
'long unsigned int'
dtest.c:1288: warning: format '%x' expects type 'unsigned int', but
argument 6
has type 'DAT_VLEN'
I'm running on a 64 bit machine with Fedora 9.
[root at treebeard BUILD]# uname -a
Linux treebeard 2.6.25-14.fc9.x86_64 #1 SMP Thu May 1 06:06:21 EDT 2008
x86_64
x86_64 x86_64 GNU/Linux
[root at treebeard BUILD]# gcc --version
gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
[root at treebeard BUILD]# pwd
/var/tmp/OFED_topdir/BUILD
To figure out what DAT_PORT_QUAL, DAT_VLEN, DAT_VADDR are defined as, I
ran
for each of those:
[root at treebeard BUILD]# grep -r DAT_PORT_QUAL *|egrep 'typedef|define'
compat-dapl-1.2.8/dat/include/dat/dat.h:typedef DAT_UINT64
DAT_PORT_QUAL;
compat-dapl-1.2.8/dat/include/dat/dat.h:typedef DAT_UINT64 DAT_VLEN;
compat-dapl-1.2.8/dat/include/dat/dat.h:typedef DAT_UINT64
DAT_VADDR;
The important information for DAT_UINT64 is
compat-dapl-1.2.8/dat/include/dat/dat_platform_specific.h:typedef uint64_t
DAT_UINT64; /* unsigned host order, 64 bits */
compat-dapl-1.2.8/dat/include/dat/dat_platform_specific.h:typedef unsigned
__int64 DAT_UINT64; /* unsigned host order, 64 bits */
So instead of %d, should you use %ld, and instead of %x, should you use
%lx?
And somebody needs to figure out what to use for %llx.
Carlyn Iuzzolino
iuzzolin at nmia.com
More information about the general
mailing list