Skip to content

WIP: Patch bmxd v0.5

Sven enniK requested to merge patch-bmxd-v0.5 into master

see: https://github.com/Freifunk-Dresden/ffdd-server/issues/14

after some changes: https://github.com/Freifunk-Dresden/ffdd-server/compare/patch-bmxd

stderr:
In file included from batman.h:28,
               from control.c:35:
control.c: In function 'remove_dbgl_node':
control.c:94:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 list_for_each_safe( list_pos, list_tmp, (struct list_head *)&dbgl_clients[i] ) {
list-batman.h:96:14: note: in definition of macro 'list_for_each_safe'
for (pos = (head)->next, n = pos->next; pos != (struct list_head *)(head); \
            ^~~~
control.c: In function 'debug_output':
control.c:591:29: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 list_for_each ( list_pos, (struct list_head *)&(dbgl_clients[level]) ) {
list-batman.h:85:14: note: in definition of macro 'list_for_each'
for (pos = (head)->next; pos != (struct list_head *)(head); \
            ^~~~
stdout:
rm -f bmxd *.o posix/*.o linux/*.o
make -C lib clean
make[1]: Entering directory '/usr/local/src/bmxd/lib'
for d in ./bmx_gsf_map ./bmx_howto_plugin ./bmx_http_info ./bmx_uci_config; do make -C $d clean || echo compiling $d failed; echo;echo; done
make[2]: Entering directory '/usr/local/src/bmxd/lib/bmx_gsf_map'
rm -f *.o *.so.1
make[2]: Leaving directory '/usr/local/src/bmxd/lib/bmx_gsf_map'


make[2]: Entering directory '/usr/local/src/bmxd/lib/bmx_howto_plugin'
rm -f *.o *.so.1
make[2]: Leaving directory '/usr/local/src/bmxd/lib/bmx_howto_plugin'


make[2]: Entering directory '/usr/local/src/bmxd/lib/bmx_http_info'
rm -f *.o *.so.1
make[2]: Leaving directory '/usr/local/src/bmxd/lib/bmx_http_info'


make[2]: Entering directory '/usr/local/src/bmxd/lib/bmx_uci_config'
rm -f *.o *.so.1
make[2]: Leaving directory '/usr/local/src/bmxd/lib/bmx_uci_config'


make[1]: Leaving directory '/usr/local/src/bmxd/lib'
make bmxd
make[1]: Entering directory '/usr/local/src/bmxd'
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c batman.c -o batman.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c originator.c -o originator.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c hna.c -o hna.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c schedule.c -o schedule.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c plugin.c -o plugin.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c list-batman.c -o list-batman.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c allocate.c -o allocate.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c avl.c -o avl.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c profile.c -o profile.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c control.c -o control.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c metrics.c -o metrics.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c linux/route.c -o linux/route.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c posix/posix.c -o posix/posix.o
cc -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DREVISION_VERSION=\"-src:[a13362f398]\" -DSTEPHAN_NO_DYNAMIC_PLUGIN -DNODEPRECATED -DNOVIS -DNOHNA -c posix/tunnel.c -o posix/tunnel.o
cc  batman.o originator.o hna.o schedule.o plugin.o list-batman.o allocate.o avl.o profile.o control.o metrics.o linux/route.o posix/posix.o posix/tunnel.o -o bmxd  -g3 
make[1]: Leaving directory '/usr/local/src/bmxd'
# further make targets: help, libs, build_all, strip[_libs|_all], install[_libs|_all], clean[_libs|_all]
make bmxd
make[1]: Entering directory '/usr/local/src/bmxd'
make[1]: 'bmxd' is up to date.
make[1]: Leaving directory '/usr/local/src/bmxd'
# further make targets: help, libs, build_all, strip[_libs|_all], install[_libs|_all], clean[_libs|_all]
strip bmxd

in list-batman.h für Header-Dateien, list-batman.c für Definitionen

Die gegebene Funktion ist

void list_add_before( struct list_head *prev_node, struct list_head *next_node, struct list_head *new_node ) {
 prev_node->next = new_node;
 new_node->next = next_node;
}

es benutzt nur -> next nicht -> prev

Die Neufassung sollte sich also hoffentlich nicht darauf auswirken zumal der Zeiger neu erstellt wird, nicht die Struktur selbst aber nur um sicher zu gehen.
siehe: https://locklessinc.com/articles/overloading/
search: "warning: dereferencing type-punned pointer will break strict-aliasing rules"

aber die beste Lösung ist wie folgt
erstelle eine andere Funktion:

void list_add_before_fxx( struct list_head_first *prev_node, struct list_head *next_node, struct list_head *new_node ) {
same body
}

dann ein anderer:
void list_add_before_xfx(struct list_head *prev_node, struct list_head_first *next_node, struct list_head *new_node){samebody}

wir müssen 2 * 2 * 2 = 8 Funktionen erstellen , 7 Funktionen
Der xxx-Fall ist nur die ursprüngliche Funktion
dann die richtige Version mit dem richtigen Typ verwenden
das ist es oder?

Edited by Sven enniK

Merge request reports