Unix: update clear() function and use it to flush IO buffers when opening the serial port
The IO buffers may contain some leftovers from the previous data, which
was possibly received with different parameters. This can lead to
reading some garbage bytes right after opening the serial port.
Fix it by explicitly clearing the IO buffers during the initialization
of the port.
Do it by calling the pre-existing clear() function. Do not handle the
return value, because failing here wouldn't be a hard error.
Note that this fix really depends on the device driver
implementation - if it does not support flushing the IO buffers, then
this change actually does nothing. It's known that some
USB <-> serial converters do not implement it.
Task-number: QTBUG-115205
Pick-to: 6.6 6.5 6.2
Change-Id: I6feb1a5d6d95b8d90d23428f48147fc664edf9fa
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>