session: Fix crash on detaching a device in programming mode (Mac OS)
session: Fix crash on detaching a device in programming mode (Mac OS)

While running Pixelpulse2 on Mac OS and  a device (ADALM1000) set in programming mode gets detached the application crashes with the following output:
Session::detached ser: Interrupt signal (11) received.
Call Stack:
  1   libsystem_platform.dylib            0x00007fff8f5a7f1a _sigtramp + 26
  2   ???                                 0x0000000000000000 0x0 + 0
  3   pixelpulse2                         0x000000010020c611 hotplug_callback_usbthread + 17
  4   pixelpulse2                         0x000000010021c8be usbi_hotplug_match + 110
  5   pixelpulse2                         0x000000010021befb handle_events + 549
  6   pixelpulse2                         0x000000010021baae libusb_handle_events_timeout_completed + 240
  7   pixelpulse2                         0x000000010021c0a2 libusb_handle_events + 34
  8   pixelpulse2                         0x000000010020e0dc _ZNSt3__114__thread_proxyINS_5tupleIJZN7Session16start_usb_threadEvE3$_0EEEEEPvS5_ + 124
  9   libsystem_pthread.dylib             0x00007fff8f4a605a _pthread_body + 131
  10  libsystem_pthread.dylib             0x00007fff8f4a5fd7 _pthread_body + 0
  11  libsystem_pthread.dylib             0x00007fff8f4a33ed thread_start + 13
/Users/analog/Workspace/build-pixelpulse2-Desktop_Qt_5_5_1_clang_64bit-Debug/pixelpulse2.app/Contents/MacOS/pixelpulse2 exited with code 11

This doesn't happend when the application is compiled for debug. Looks like the compiler optimizes the code making the if (dev) to always be evaluated as true.

This commit refactors the code in order to avoid the situation described above.

Signed-off-by: Dan Nechita <0d348f54705b7a521d732c6906bfe1864d17d562@analog.com>

radhermit/libsmu,radhermit/libsmu,radhermit/libsmu