media: vidtv: don't use recursive functions
The Linux stack is too short. So, using recursive functions is a very bad idea. Convert those into non-recursive ones. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
3be8037960
commit
31e82355a1
@ -951,25 +951,29 @@ vidtv_psi_pat_program_assign(struct vidtv_psi_table_pat *pat,
|
|||||||
{
|
{
|
||||||
/* This function transfers ownership of p to the table */
|
/* This function transfers ownership of p to the table */
|
||||||
|
|
||||||
u16 program_count = 0;
|
u16 program_count;
|
||||||
struct vidtv_psi_table_pat_program *program = p;
|
struct vidtv_psi_table_pat_program *program;
|
||||||
|
|
||||||
if (p == pat->program)
|
do {
|
||||||
return;
|
program_count = 0;
|
||||||
|
program = p;
|
||||||
|
|
||||||
while (program) {
|
if (p == pat->program)
|
||||||
++program_count;
|
return;
|
||||||
program = program->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
pat->programs = program_count;
|
while (program) {
|
||||||
pat->program = p;
|
++program_count;
|
||||||
|
program = program->next;
|
||||||
|
}
|
||||||
|
|
||||||
/* Recompute section length */
|
pat->programs = program_count;
|
||||||
vidtv_psi_pat_table_update_sec_len(pat);
|
pat->program = p;
|
||||||
|
|
||||||
if (vidtv_psi_get_sec_len(&pat->header) > MAX_SECTION_LEN)
|
/* Recompute section length */
|
||||||
vidtv_psi_pat_program_assign(pat, NULL);
|
vidtv_psi_pat_table_update_sec_len(pat);
|
||||||
|
|
||||||
|
p = NULL;
|
||||||
|
} while (vidtv_psi_get_sec_len(&pat->header) > MAX_SECTION_LEN);
|
||||||
|
|
||||||
vidtv_psi_update_version_num(&pat->header);
|
vidtv_psi_update_version_num(&pat->header);
|
||||||
}
|
}
|
||||||
@ -1124,15 +1128,16 @@ void vidtv_psi_pmt_stream_destroy(struct vidtv_psi_table_pmt_stream *s)
|
|||||||
void vidtv_psi_pmt_stream_assign(struct vidtv_psi_table_pmt *pmt,
|
void vidtv_psi_pmt_stream_assign(struct vidtv_psi_table_pmt *pmt,
|
||||||
struct vidtv_psi_table_pmt_stream *s)
|
struct vidtv_psi_table_pmt_stream *s)
|
||||||
{
|
{
|
||||||
/* This function transfers ownership of s to the table */
|
do {
|
||||||
if (s == pmt->stream)
|
/* This function transfers ownership of s to the table */
|
||||||
return;
|
if (s == pmt->stream)
|
||||||
|
return;
|
||||||
|
|
||||||
pmt->stream = s;
|
pmt->stream = s;
|
||||||
vidtv_psi_pmt_table_update_sec_len(pmt);
|
vidtv_psi_pmt_table_update_sec_len(pmt);
|
||||||
|
|
||||||
if (vidtv_psi_get_sec_len(&pmt->header) > MAX_SECTION_LEN)
|
s = NULL;
|
||||||
vidtv_psi_pmt_stream_assign(pmt, NULL);
|
} while (vidtv_psi_get_sec_len(&pmt->header) > MAX_SECTION_LEN);
|
||||||
|
|
||||||
vidtv_psi_update_version_num(&pmt->header);
|
vidtv_psi_update_version_num(&pmt->header);
|
||||||
}
|
}
|
||||||
@ -1500,16 +1505,17 @@ void
|
|||||||
vidtv_psi_sdt_service_assign(struct vidtv_psi_table_sdt *sdt,
|
vidtv_psi_sdt_service_assign(struct vidtv_psi_table_sdt *sdt,
|
||||||
struct vidtv_psi_table_sdt_service *service)
|
struct vidtv_psi_table_sdt_service *service)
|
||||||
{
|
{
|
||||||
if (service == sdt->service)
|
do {
|
||||||
return;
|
if (service == sdt->service)
|
||||||
|
return;
|
||||||
|
|
||||||
sdt->service = service;
|
sdt->service = service;
|
||||||
|
|
||||||
/* recompute section length */
|
/* recompute section length */
|
||||||
vidtv_psi_sdt_table_update_sec_len(sdt);
|
vidtv_psi_sdt_table_update_sec_len(sdt);
|
||||||
|
|
||||||
if (vidtv_psi_get_sec_len(&sdt->header) > MAX_SECTION_LEN)
|
service = NULL;
|
||||||
vidtv_psi_sdt_service_assign(sdt, NULL);
|
} while (vidtv_psi_get_sec_len(&sdt->header) > MAX_SECTION_LEN);
|
||||||
|
|
||||||
vidtv_psi_update_version_num(&sdt->header);
|
vidtv_psi_update_version_num(&sdt->header);
|
||||||
}
|
}
|
||||||
@ -1832,14 +1838,15 @@ void vidtv_psi_eit_table_update_sec_len(struct vidtv_psi_table_eit *eit)
|
|||||||
void vidtv_psi_eit_event_assign(struct vidtv_psi_table_eit *eit,
|
void vidtv_psi_eit_event_assign(struct vidtv_psi_table_eit *eit,
|
||||||
struct vidtv_psi_table_eit_event *e)
|
struct vidtv_psi_table_eit_event *e)
|
||||||
{
|
{
|
||||||
if (e == eit->event)
|
do {
|
||||||
return;
|
if (e == eit->event)
|
||||||
|
return;
|
||||||
|
|
||||||
eit->event = e;
|
eit->event = e;
|
||||||
vidtv_psi_eit_table_update_sec_len(eit);
|
vidtv_psi_eit_table_update_sec_len(eit);
|
||||||
|
|
||||||
if (vidtv_psi_get_sec_len(&eit->header) > EIT_MAX_SECTION_LEN)
|
e = NULL;
|
||||||
vidtv_psi_eit_event_assign(eit, NULL);
|
} while (vidtv_psi_get_sec_len(&eit->header) > EIT_MAX_SECTION_LEN);
|
||||||
|
|
||||||
vidtv_psi_update_version_num(&eit->header);
|
vidtv_psi_update_version_num(&eit->header);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user