Browse Source

* dvb/sim.h: Fix compilation warnings. * examples/dvb_ecmg.c: Fix segfault.

master
Christophe Massiot 14 years ago
parent
commit
612e3dea81
2 changed files with 9 additions and 7 deletions
  1. +4
    -4
      dvb/sim.h
  2. +5
    -3
      examples/dvb_ecmg.c

+ 4
- 4
dvb/sim.h View File

@ -48,7 +48,7 @@ static inline void tlvh_set_version(uint8_t *p_tlv, uint8_t i_version)
p_tlv[0] = i_version; p_tlv[0] = i_version;
} }
static inline uint8_t tlvh_get_version(uint8_t *p_tlv)
static inline uint8_t tlvh_get_version(const uint8_t *p_tlv)
{ {
return p_tlv[0]; return p_tlv[0];
} }
@ -64,7 +64,7 @@ static inline void tlv_set_type(uint8_t *p_tlv, uint16_t i_type)
p_tlv[1] = i_type & 0xff; p_tlv[1] = i_type & 0xff;
} }
static inline uint16_t tlv_get_type(uint8_t *p_tlv)
static inline uint16_t tlv_get_type(const uint8_t *p_tlv)
{ {
return (p_tlv[0] << 8) | p_tlv[1]; return (p_tlv[0] << 8) | p_tlv[1];
} }
@ -75,7 +75,7 @@ static inline void tlv_set_length(uint8_t *p_tlv, uint16_t i_length)
p_tlv[3] = i_length & 0xff; p_tlv[3] = i_length & 0xff;
} }
static inline uint16_t tlv_get_length(uint8_t *p_tlv)
static inline uint16_t tlv_get_length(const uint8_t *p_tlv)
{ {
return (p_tlv[2] << 8) | p_tlv[3]; return (p_tlv[2] << 8) | p_tlv[3];
} }
@ -161,7 +161,7 @@ static inline uint16_t tlv_count_param(uint8_t *p_tlv, uint16_t i_type)
} }
static inline bool tlv_validate_count_param(uint8_t *p_tlv, static inline bool tlv_validate_count_param(uint8_t *p_tlv,
tlv_param_count_t *p_count)
const tlv_param_count_t *p_count)
{ {
uint16_t i_count = tlv_count_param(p_tlv, p_count->i_type); uint16_t i_count = tlv_count_param(p_tlv, p_count->i_type);
return (i_count >= p_count->i_min) && (i_count <= p_count->i_max); return (i_count >= p_count->i_min) && (i_count <= p_count->i_max);

+ 5
- 3
examples/dvb_ecmg.c View File

@ -450,14 +450,16 @@ static void handle_stream_setup(uint8_t *p_tlv)
return; return;
} }
p_stream = malloc(sizeof(stream_t));
for (i = 0; i < i_nb_streams; i++) { for (i = 0; i < i_nb_streams; i++) {
p_stream = pp_streams[i];
if (p_stream == NULL)
if (pp_streams[i] == NULL) {
pp_streams[i] = p_stream;
break; break;
}
} }
if (i == i_nb_streams) { if (i == i_nb_streams) {
p_stream = malloc(sizeof(stream_t));
pp_streams = realloc(pp_streams, ++i_nb_streams * sizeof(stream_t *)); pp_streams = realloc(pp_streams, ++i_nb_streams * sizeof(stream_t *));
pp_streams[i_nb_streams - 1] = p_stream; pp_streams[i_nb_streams - 1] = p_stream;
} }

Loading…
Cancel
Save