[En-Nut-Discussion] ipout.c error

Stefan Profanter stefan at profanter.me
Mon Dec 27 23:36:52 CET 2010


I've now tried to debug and reproduce the error:
../../nut/net/ipout.c: In function 'NutIpOutput':
../../nut/net/ipout.c:226:29: error: operation on 'nif->if_pkt_id' may be undefined
../../nut/net/ipout.c:255:17: error: operation on 'nif->if_pkt_id' may be undefined

Here are the steps:
- Download Ethernut/ NutOS 4.8.8  from http://sourceforge.net/projects/ethernut/files/ethernut/4.8.8%20stable/ethernut-4.8.8.exe/download
- Install it on eg D:\Ethernut
- Download the YAGARTO GNU ARM toolchain from http://www.yagarto.de/ (The newest version is from 23.12.2010. GCC Version:  4.5.2)
- Install it on eg C:\Yagarto
- Modify the file D:\Ethernut\nut\Makedefs.arm-gcc and change "TRGT   = arm-elf-" to "TRGT   = arm-none-eabi-"
- Start Nut Configurator, select Ethernut31d.conf
- Edit-> Settings -> Platform -> arm-gcc
- Edit-> Settings -> Tools -> Tool Paths -> add "C:\yagarto\bin;"
- Now go to Build-> Build Nut/OS

-Ok, now it tries to build, but you get first some other errors:

../../nut/os/osdebug.c: In function 'NutDumpThreadQueue':
../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 7 has type 'unsigned int'
../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 8 has type 'unsigned int'
../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 9 has type 'uintptr_t'
../../nut/os/osdebug.c:132:13: error: format '%9lu' expects type 'long unsigned int', but argument 10 has type 'uintptr_t'
../../nut/os/osdebug.c: In function 'NutDumpThreadList':
../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 7 has type 'unsigned int'
../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 8 has type 'unsigned int'
../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 9 has type 'uintptr_t'
../../nut/os/osdebug.c:176:9: error: format '%9lu' expects type 'long unsigned int', but argument 10 has type 'uintptr_t'
../../nut/os/osdebug.c:187:21: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c: In function 'NutDumpTimerList':
../../nut/os/osdebug.c:226:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c:233:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c: In function 'NutDumpHeap':
../../nut/os/osdebug.c:281:9: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
../../nut/os/osdebug.c:281:9: error: format '%9ld' expects type 'long int', but argument 4 has type 'size_t'
../../nut/os/osdebug.c:287:9: error: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t'
../../nut/os/osdebug.c:287:9: error: format '%lu' expects type 'long unsigned int', but argument 4 has type 'size_t'
../../nut/os/osdebug.c:289:9: error: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t'

- The reason here is, that there is a problem with the expected datatype. You have to change each '%08lX' to '%08X' and '%lu' to '%u' and so on
-Now try again to build and you get a new error:

../../nut/net/ipout.c: In function 'NutIpOutput':
../../nut/net/ipout.c:226:29: error: operation on 'nif->if_pkt_id' may be undefined
../../nut/net/ipout.c:255:17: error: operation on 'nif->if_pkt_id' may be undefined

---------------------------

The problem is the following line:
ip->ip_id = htons(nif->if_pkt_id++);

nif is defined as:
IFNET *nif;

And (if_var.h):
typedef struct ifnet IFNET;
struct ifnet {
...
    uint16_t if_pkt_id;     /*!< \brief Packet identifier. */
...
};





More information about the En-Nut-Discussion mailing list