Commit 31e82355 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

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: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 3be80379
Loading
Loading
Loading
Loading
+41 −34
Original line number Diff line number Diff line
@@ -951,8 +951,12 @@ vidtv_psi_pat_program_assign(struct vidtv_psi_table_pat *pat,
{
	/* This function transfers ownership of p to the table */

	u16 program_count = 0;
	struct vidtv_psi_table_pat_program *program = p;
	u16 program_count;
	struct vidtv_psi_table_pat_program *program;

	do {
		program_count = 0;
		program = p;

		if (p == pat->program)
			return;
@@ -968,8 +972,8 @@ vidtv_psi_pat_program_assign(struct vidtv_psi_table_pat *pat,
		/* Recompute section length */
		vidtv_psi_pat_table_update_sec_len(pat);

	if (vidtv_psi_get_sec_len(&pat->header) > MAX_SECTION_LEN)
		vidtv_psi_pat_program_assign(pat, NULL);
		p = NULL;
	} while (vidtv_psi_get_sec_len(&pat->header) > MAX_SECTION_LEN);

	vidtv_psi_update_version_num(&pat->header);
}
@@ -1124,6 +1128,7 @@ 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,
				 struct vidtv_psi_table_pmt_stream *s)
{
	do {
		/* This function transfers ownership of s to the table */
		if (s == pmt->stream)
			return;
@@ -1131,8 +1136,8 @@ void vidtv_psi_pmt_stream_assign(struct vidtv_psi_table_pmt *pmt,
		pmt->stream = s;
		vidtv_psi_pmt_table_update_sec_len(pmt);

	if (vidtv_psi_get_sec_len(&pmt->header) > MAX_SECTION_LEN)
		vidtv_psi_pmt_stream_assign(pmt, NULL);
		s = NULL;
	} while (vidtv_psi_get_sec_len(&pmt->header) > MAX_SECTION_LEN);

	vidtv_psi_update_version_num(&pmt->header);
}
@@ -1500,6 +1505,7 @@ void
vidtv_psi_sdt_service_assign(struct vidtv_psi_table_sdt *sdt,
			     struct vidtv_psi_table_sdt_service *service)
{
	do {
		if (service == sdt->service)
			return;

@@ -1508,8 +1514,8 @@ vidtv_psi_sdt_service_assign(struct vidtv_psi_table_sdt *sdt,
		/* recompute section length */
		vidtv_psi_sdt_table_update_sec_len(sdt);

	if (vidtv_psi_get_sec_len(&sdt->header) > MAX_SECTION_LEN)
		vidtv_psi_sdt_service_assign(sdt, NULL);
		service = NULL;
	} while (vidtv_psi_get_sec_len(&sdt->header) > MAX_SECTION_LEN);

	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,
				struct vidtv_psi_table_eit_event *e)
{
	do {
		if (e == eit->event)
			return;

		eit->event = e;
		vidtv_psi_eit_table_update_sec_len(eit);

	if (vidtv_psi_get_sec_len(&eit->header) > EIT_MAX_SECTION_LEN)
		vidtv_psi_eit_event_assign(eit, NULL);
		e = NULL;
	} while (vidtv_psi_get_sec_len(&eit->header) > EIT_MAX_SECTION_LEN);

	vidtv_psi_update_version_num(&eit->header);
}