tdb2: fix tools warnings with -Wshadow and -Wcast-qual.