Windows code style fixes.
Fixed missing variable declaration and use snprintf instead of sprintf_s.
Make default_device thread-local

Signed-off-by: Philipp Wolfer <ph.wolfer@gmail.com>