[Live-devel] RTSPServer: redeclaration and one cycle only

Ross Finlayson finlayson+mobile at live555.com
Fri Jul 25 12:44:18 PDT 2008


Yes, you found a bug on the code. The second declaration of ourSocket  
was incorrect. This will get fixed in the next release of the code.

Also, "do { ... } while (0);" is a common C++ idiom used to create a  
block of code that's easy to break out of (if an error occurs),  
without using exceptions (or goto).

         Ross.
----------
Sent from my jesusPhone


On Jul 25, 2008, at 10:15 AM, "Renato MAURO \(Libero\)" <renatomauro at libero.it 
 > wrote:

> Hi Ross.
>
>   Don't worry, this is not an help request, only an explanation one.
>
>   Watching this code
>
> TSPServer*
> RTSPServer::createNew(UsageEnvironment& env, Port ourPort,
>       UserAuthenticationDatabase* authDatabase,
>       unsigned reclamationTestSeconds) {
> int ourSocket = -1;
>
> do {
>   int ourSocket = setUpOurSocket(env, ourPort);
>   if (ourSocket == -1) break;
>
>   return new RTSPServer(env, ourSocket, ourPort, authDatabase,
>    reclamationTestSeconds);
> } while (0);
>
> if (ourSocket != -1) ::closeSocket(ourSocket);
> return NULL;
> }
>
> we see that 'ourSocket' is redeclared in the do-while loop.
>
> 1) I'm wondering if the redeclaration is intentional or not and so  
> if the last 'if' is useful or not.
>
> 2) Maybe it's my lack of knowledge: why write a single do-while  
> cicle instead of use an if-else structure?
>
> Thank you very much,
>
>   Renato MAURO
>
>
>
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live555.com
> http://lists.live555.com/mailman/listinfo/live-devel
>


More information about the live-devel mailing list