cms-gem-daq-project / ctp7_modules

0 stars 13 forks source link

Ambiguous call to sleep (potential bug) #128

Closed lmoureaux closed 4 years ago

lmoureaux commented 5 years ago

Brief summary of issue

One can find the following call to sleep(unsigned) at src/optohybrid.cpp:465:

sleep(0.1);

This is compiled as sleep(0) and therefore there's no real sleep.

clang 6 warns:

src/optohybrid.cpp:465:15: warning: implicit conversion from 'double' to 'unsigned int' changes value from 0.1 to 0 [-Wliteral-conversion]
        sleep(0.1);
        ~~~~~ ^~~
1 warning generated.

Types of issue

Expected Behavior

If a call to sleep(0) is intended, use that instead. If a waiting time of 0.1s is intended, use std::this_thread::sleep_for(std::chrono::milliseconds(100)) (the C++ version is safer because it's not sensitive to signals).

Current Behavior

Code is unclear.

Your Environment

lpetre-ulb commented 4 years ago

No longer present in the new repository.