static gboolean
gst_fd_src_start (GstBaseSrc * bsrc)
{
GstFdSrc *src = GST_FD_SRC (bsrc);
src->curoffset = 0;
if ((src->fdset = gst_poll_new (TRUE)) == NULL)
goto socket_pair;
gst_fd_src_update_fd (src, -1);
return TRUE;
/* ERRORS */
socket_pair:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL),
GST_ERROR_SYSTEM);
return FALSE;
}
}
why here someone has used goto socket_pair;
i am not getting why this mechanism is used ?
why dont we just write error message there and return ?
note: this is gstreamer plugin code
In larger routines there might be multiple points in the function which need to goto
the error handling code. This routine should be seen in the context of having been written according to code conventions that mandate a common form for error handling.
It's true that goto
should be considered dangerous but for a language like C which has no exception handling it can be the least bad option for error handling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With