Skip to content

Commit

Permalink
GFX: eliminate use of goto
Browse files Browse the repository at this point in the history
  • Loading branch information
metalefty committed Aug 23, 2024
1 parent 50281fa commit 1841d15
Showing 1 changed file with 30 additions and 39 deletions.
69 changes: 30 additions & 39 deletions xrdp/xrdp_tconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static int tconfig_load_gfx_order(toml_table_t *tfile, struct xrdp_tconfig_gfx *
* H264/RFX support. Just loads configurations as-is.
*/

TCLOG(LOG_LEVEL_DEBUG, "tconfig_load_gfx_order:");
TCLOG(LOG_LEVEL_TRACE, "[codec]");

int h264_found = 0;
int rfx_found = 0;
Expand All @@ -215,61 +215,52 @@ static int tconfig_load_gfx_order(toml_table_t *tfile, struct xrdp_tconfig_gfx *
config->codec.rfx_idx = -1;

toml_table_t *codec = toml_table_in(tfile, "codec");
if (!codec)
{
goto return_default_codec_order;
}

toml_array_t *order = toml_array_in(codec, "order");
if (!order)
{
goto return_default_codec_order;
}

for (int i = 0; ; i++)
if (codec && order)
{
toml_datum_t datum = toml_string_at(order, i);

if (datum.ok)
for (int i = 0; ; i++)
{
if (g_strcasecmp(datum.u.s, "h264") == 0 ||
g_strcasecmp(datum.u.s, "h.264") == 0)
toml_datum_t datum = toml_string_at(order, i);

if (datum.ok)
{
h264_found = 1;
config->codec.h264_idx = i;
if (g_strcasecmp(datum.u.s, "h264") == 0 ||
g_strcasecmp(datum.u.s, "h.264") == 0)
{
h264_found = 1;
config->codec.h264_idx = i;
}
if (g_strcasecmp(datum.u.s, "rfx") == 0)
{
rfx_found = 1;
config->codec.rfx_idx = i;
}
free(datum.u.s);
}
if (g_strcasecmp(datum.u.s, "rfx") == 0)
else
{
rfx_found = 1;
config->codec.rfx_idx = i;
break;
}
free(datum.u.s);
}
else
{
break;
}
}

if (h264_found == 0 && rfx_found == 0)
{
goto return_default_codec_order;
}
/* prefer H264 if no priority found */
config->codec.h264_idx = 0;
config->codec.rfx_idx = 1;

TCLOG(LOG_LEVEL_DEBUG, "codec_order: h264_idx=%d, rfx_idx=%d",
config->codec.h264_idx, config->codec.rfx_idx);
return 0;
TCLOG(LOG_LEVEL_WARNING, "[codec] could not get GFX codec order, using default order"
" h264_idx [%d], rfx_idx [%d]",
config->codec.h264_idx, config->codec.rfx_idx);

return_default_codec_order:
/* prefer H264 if no priority found */
config->codec.h264_idx = 0;
config->codec.rfx_idx = 1;
return 1;
}

TCLOG(LOG_LEVEL_ERROR, "coder_order: could not get codec order, using default order"
"h264_idx=%d, rfx_idx=%d",
TCLOG(LOG_LEVEL_DEBUG, "[codec] h264_idx [%d], rfx_idx [%d]",
config->codec.h264_idx, config->codec.rfx_idx);

return 1;
return 0;
}

int
Expand Down

0 comments on commit 1841d15

Please sign in to comment.