[Live-devel] scheduleNextQOSMeasurement() bug?

Skaarj NaPali skaarj1 at gmail.com
Sun Sep 8 05:06:54 PDT 2013


Yes, I was referring to function "scheduleNextQOSMeasurement()" at line
1049 of "testProgs/playCommon.cpp" (the "openRTSP" code). I wanted to refer
my mail to an already existing thread in the mailing list with subject
"scheduleNextQOSMeasurement() bug?" from "Thu Jan 15 05:41:40 PST 2009",
sorry if that didn't work.

The change which you applied in version 2013.09.08 does not change
anything, because it does not cause the needed sign extension. In fact
declaring "usecsToDelay" as "int64_t" and assigning it the result of an
"unsigned" term is the same as passing an "unsigned" type to an "int64_t"
parameter to a function. It's the way how C/C++ propagates types.

To get a sign extension from "unsigned" (32-bit) to "signed" (64-bit), the
"unsigned" (32-bit) has to get propagated first to a "signed" (32-bit)
type. This can be done in several ways.


unsigned nextQOSMeasurementUSecs;
unsigned timeNowUSecs;
...
int usecsToDelay = nextQOSMeasurementUSecs - timeNowUSecs;

----or----

int64_t nextQOSMeasurementUSecs; // or "uint64_t"
int64_t timeNowUSecs; // or "uint64_t"
...
int64_t usecsToDelay = nextQOSMeasurementUSecs - timeNowUSecs;

----or----

unsigned nextQOSMeasurementUSecs;
unsigned timeNowUSecs;
...
int64_t usecsToDelay = (int)(nextQOSMeasurementUSecs - timeNowUSecs);


The 1st one avoids an explicit cast and if the types of
"nextQOSMeasurementUSecs" or "timeNowUSecs" once get changed to "int64_t"
it would cause the compiler to throw a warning about type truncation.

The 2nd one solves the problem implicitly because all types are of the same
size, but it would require more changes in the code.

The 3rd one may become problematic once the types of
"nextQOSMeasurementUSecs" or "timeNowUSecs" are changed in the future,
because the explicit cast prevents compiler warnings.

Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20130908/6ce08660/attachment.html>


More information about the live-devel mailing list