Commit 1f223e37 authored by Jean-Paul Saman's avatar Jean-Paul Saman

unify error, debug and warning messages

Libdvbpsi used printf and fprintf to return debug and error information to the caller.
This bypasses any logging mechanism the calling application uses and does not take
multi-threaded applications into account.
The unifying of messages (error, debug or warning) allows a calling application to
filter (message level: -1, 0, 1 or 2) and handle the messages in its own way.
parent d4a47c1f
......@@ -51,7 +51,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x02)
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_02 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,11 +61,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_vstream_dr_t*)malloc(sizeof(dvbpsi_vstream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_02 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? 1 : 0;
......@@ -73,7 +69,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
if( (!p_decoded->b_mpeg2 && (p_descriptor->i_length != 1))
|| (p_decoded->b_mpeg2 && (p_descriptor->i_length != 3)))
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_02 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
......
......@@ -51,7 +51,7 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x03)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_03 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_03 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_03 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x04)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Allocate memory */
p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_04 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_04 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x05)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_05 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
/* Allocate memory */
p_decoded = (dvbpsi_registration_dr_t*)
malloc(sizeof(dvbpsi_registration_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_05 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_05 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x06)
{
DVBPSI_ERROR_ARG("dr_06 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_06 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_ds_alignment_dr_t * dvbpsi_DecodeDSAlignmentDr(
/* Allocate memory */
p_decoded = (dvbpsi_ds_alignment_dr_t*)
malloc(sizeof(dvbpsi_ds_alignment_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_06 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_06 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_06 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x07)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_target_bg_grid_dr_t * dvbpsi_DecodeTargetBgGridDr(
/* Allocate memory */
p_decoded = (dvbpsi_target_bg_grid_dr_t*)
malloc(sizeof(dvbpsi_target_bg_grid_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_07 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x08)
{
DVBPSI_ERROR_ARG("dr_08 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_08 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_vwindow_dr_t * dvbpsi_DecodeVWindowDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_vwindow_dr_t*)malloc(sizeof(dvbpsi_vwindow_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_08 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_08 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_08 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x09)
{
DVBPSI_ERROR_ARG("dr_09 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_09 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -61,16 +61,12 @@ dvbpsi_ca_dr_t * dvbpsi_DecodeCADr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_ca_dr_t*)malloc(sizeof(dvbpsi_ca_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_09 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_09 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_09 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x0a)
{
DVBPSI_ERROR_ARG("dr_0a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0a decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0a decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if((p_descriptor->i_length < 1) || (p_descriptor->i_length % 4 != 0))
{
DVBPSI_ERROR_ARG("dr_0a decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0a decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0b)
{
DVBPSI_ERROR_ARG("dr_0b decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0b decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_system_clock_dr_t * dvbpsi_DecodeSystemClockDr(
/* Allocate memory */
p_decoded =
(dvbpsi_system_clock_dr_t*)malloc(sizeof(dvbpsi_system_clock_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0b decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 2)
{
DVBPSI_ERROR_ARG("dr_0b decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0b decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0c)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_mx_buff_utilization_dr_t * dvbpsi_DecodeMxBuffUtilizationDr(
/* Allocate memory */
p_decoded = (dvbpsi_mx_buff_utilization_dr_t*)
malloc(sizeof(dvbpsi_mx_buff_utilization_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0c decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0d)
{
DVBPSI_ERROR_ARG("dr_0d decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0d decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_copyright_dr_t * dvbpsi_DecodeCopyrightDr(
/* Allocate memory */
p_decoded = (dvbpsi_copyright_dr_t*)
malloc(sizeof(dvbpsi_copyright_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0d decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_0c decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0c decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0e)
{
DVBPSI_ERROR_ARG("dr_0e decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0e decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_max_bitrate_dr_t * dvbpsi_DecodeMaxBitrateDr(
/* Allocate memory */
p_decoded = (dvbpsi_max_bitrate_dr_t*)malloc(sizeof(dvbpsi_max_bitrate_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0e decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 3)
{
DVBPSI_ERROR_ARG("dr_0e decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0e decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -52,7 +52,7 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x0f)
{
DVBPSI_ERROR_ARG("dr_0f decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_0f decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,16 +63,12 @@ dvbpsi_private_data_dr_t * dvbpsi_DecodePrivateDataDr(
/* Allocate memory */
p_decoded =
(dvbpsi_private_data_dr_t*)malloc(sizeof(dvbpsi_private_data_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_0f decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_0f decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_0f decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x42)
{
DVBPSI_ERROR_ARG("dr_42 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_42 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,7 @@ dvbpsi_stuffing_dr_t * dvbpsi_DecodeStuffingDr(
/* Allocate memory */
p_decoded =
(dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_42 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_stuffing_length = p_descriptor->i_length;
......
......@@ -52,7 +52,7 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x43)
{
DVBPSI_ERROR_ARG("dr_43 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_43 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -63,11 +63,7 @@ dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr(
/* Allocate memory */
p_decoded =
(dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_43 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] << 24)
......
......@@ -51,7 +51,7 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Check the tag */
if( p_descriptor->i_tag != 0x45 )
{
DVBPSI_ERROR_ARG("dr_45 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,14 +62,14 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_45 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "bad length (%d)",
p_descriptor->i_length);
return NULL;
}
if(p_descriptor->i_length % 2)
{
DVBPSI_ERROR_ARG("dr_45 decoder", "length not multiple of 3(%d)",
dvbpsi_error(h_dvbpsi, "dr_45 decoder", "length not multiple of 3(%d)",
p_descriptor->i_length);
return NULL;
}
......@@ -79,11 +79,7 @@ dvbpsi_vbi_dr_t * dvbpsi_DecodeVBIDataDr(
/* Allocate memory */
p_decoded =
(dvbpsi_vbi_dr_t*)malloc(sizeof(dvbpsi_vbi_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_45 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
p_decoded->i_services_number = i_services_number;
......
......@@ -53,7 +53,7 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x47)
{
DVBPSI_ERROR_ARG("dr_47 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_47 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,7 @@ dvbpsi_bouquet_name_dr_t * dvbpsi_DecodeBouquetNameDr(
/* Allocate memory */
p_decoded =
(dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_47 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_name_length = p_descriptor->i_length;
......
......@@ -53,7 +53,7 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x48)
{
DVBPSI_ERROR_ARG("dr_48 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_48 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,16 +64,12 @@ dvbpsi_service_dr_t * dvbpsi_DecodeServiceDr(
/* Allocate memory */
p_decoded =
(dvbpsi_service_dr_t*)malloc(sizeof(dvbpsi_service_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_48 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_07 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_07 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
if(p_descriptor->i_tag != 0x4d ||
p_descriptor->i_length < 5 )
{
DVBPSI_ERROR_ARG("dr_4d decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_4d decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Check length */
......@@ -61,7 +61,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
i_len2 = p_descriptor->p_data[4+i_len1];
if( p_descriptor->i_length < 5 + i_len1 + i_len2 )
{
DVBPSI_ERROR_ARG("dr_4d decoder", "invalid length/content (tag=0x%x)", p_descriptor->i_tag );
dvbpsi_error(h_dvbpsi, "dr_4d decoder", "invalid length/content (tag=0x%x)", p_descriptor->i_tag );
return NULL;
}
......@@ -71,11 +71,7 @@ dvbpsi_short_event_dr_t * dvbpsi_DecodeShortEventDr(dvbpsi_descriptor_t * p_desc
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_short_event_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_4d decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
memcpy( p_decoded->i_iso_639_code, &p_descriptor->p_data[0], 3 );
......
......@@ -54,7 +54,7 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
if(p_descriptor->i_tag != 0x4e ||
p_descriptor->i_length < 6 )
{
DVBPSI_ERROR_ARG("dr_4e decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_4e decoder", "bad tag or corrupted(0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,11 +64,8 @@ dvbpsi_extended_event_dr_t * dvbpsi_DecodeExtendedEventDr(dvbpsi_descriptor_t *
/* Allocate memory */
p_decoded = malloc(sizeof(dvbpsi_extended_event_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_4e decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode */
p_decoded->i_descriptor_number = (p_descriptor->p_data[0] >> 4)&0xf;
......
......@@ -51,7 +51,7 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x52)
{
DVBPSI_ERROR_ARG("dr_52 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_52 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,16 +62,12 @@ dvbpsi_stream_identifier_dr_t * dvbpsi_DecodeStreamIdentifierDr(
/* Allocate memory */
p_decoded =
(dvbpsi_stream_identifier_dr_t*)malloc(sizeof(dvbpsi_stream_identifier_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_52 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length < 1)
{
DVBPSI_ERROR_ARG("dr_52 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_52 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -53,7 +53,7 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x55)
{
DVBPSI_ERROR_ARG("dr_55 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_55 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -64,16 +64,12 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
/* Allocate memory */
p_decoded =
(dvbpsi_parental_rating_dr_t*)malloc(sizeof(dvbpsi_parental_rating_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_55 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length % 4)
{
DVBPSI_ERROR_ARG("dr_55 decoder", "length not multiple of 4 (%d)",
dvbpsi_error(h_dvbpsi, "dr_55 decoder", "length not multiple of 4 (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
......
......@@ -51,7 +51,7 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Check the tag */
if( (p_descriptor->i_tag != 0x56) && (p_descriptor->i_tag != 0x46) )
{
DVBPSI_ERROR_ARG("dr_46/56 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_46/56 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -62,14 +62,14 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Decode data and check the length */
if(p_descriptor->i_length < 3)
{
DVBPSI_ERROR_ARG("dr_46/dr_56 decoder", "bad length (%d)",
dvbpsi_error(h_dvbpsi, "dr_46/dr_56 decoder", "bad length (%d)",
p_descriptor->i_length);
return NULL;
}
if(p_descriptor->i_length % 5)
{
DVBPSI_ERROR_ARG("dr_46/dr_56 decoder", "length not multiple of 5(%d)",
dvbpsi_error(h_dvbpsi, "dr_46/dr_56 decoder", "length not multiple of 5(%d)",
p_descriptor->i_length);
return NULL;
}
......@@ -79,11 +79,7 @@ dvbpsi_teletext_dr_t * dvbpsi_DecodeTeletextDr(
/* Allocate memory */
p_decoded =
(dvbpsi_teletext_dr_t*)malloc(sizeof(dvbpsi_teletext_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_46/dr_56 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
p_decoded->i_pages_number = i_pages_number;
......
......@@ -54,7 +54,7 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x58)
{
DVBPSI_ERROR_ARG("dr_58 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_58 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -65,11 +65,7 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
/* Allocate memory */
p_decoded =
(dvbpsi_local_time_offset_dr_t*)malloc(sizeof(dvbpsi_local_time_offset_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_58 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data */
p_decoded->i_local_time_offsets_number = 0;
......
......@@ -54,7 +54,7 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x59)
{
DVBPSI_ERROR_ARG("dr_59 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
dvbpsi_error(h_dvbpsi, "dr_59 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
......@@ -65,16 +65,12 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
/* Allocate memory */
p_decoded =
(dvbpsi_subtitling_dr_t*)malloc(sizeof(dvbpsi_subtitling_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_59 decoder", "out of memory");