[libdvbpsi-devel] Use of -Werror (Was: Re: Nasty typecasting / alignment issues in libdvbpsi)

Martin Jackson mjackson220.list at gmail.com
Wed Oct 17 22:43:55 CEST 2012


Dear Jean-Paul,

On Tue, Oct 16, 2012 at 11:03 AM, Jean-Paul Saman <jpsaman at videolan.org> wrote:
> On Mon, Oct 15, 2012 at 12:30 PM, Martin Jackson
> <mjackson220.list at gmail.com> wrote:
>
>> the libdvbpsi library appears not to compile without -Werror either
>> for my mips toolchain or the regular centOS x86_64 toolchain, though I
>> didn't have time to investigate.
>
> -Werror is forced in configure.ac
>

It seems that there was a bug introduced in renaming message ->
dvbpsi_message in dvbpsi_private.h. This is masked (in my environment
at least) by the configure script concluding that variadic macros are
not supported (i.e. ac_cv_cpp_variadic_macros=no) if -Werror is
included in the C flags, as the fragment in configure.ac used to
determine this generates a warning and thus failure. I'm not sure how
configure.ac should be fixed, as it's a combination of autoconf and
the C flags used in libdvbpsi. However, the following patch should be
applied to dvbpsi_private.h:

diff --git a/src/dvbpsi_private.h b/src/dvbpsi_private.h
index 800f712..b7d7bfd 100644
--- a/src/dvbpsi_private.h
+++ b/src/dvbpsi_private.h
@@ -45,11 +45,11 @@ extern uint32_t dvbpsi_crc32_table[];
 void dvbpsi_message(dvbpsi_t *dvbpsi, const int level, const char *fmt, ...);

 #  define dvbpsi_error(hnd, src, str, x...)                             \
-        message(hnd, DVBPSI_MSG_ERROR, "libdvbpsi error ("src"): " str, ##x)
+        dvbpsi_message(hnd, DVBPSI_MSG_ERROR, "libdvbpsi error (%s):
" str, src, ##x)
 #  define dvbpsi_warning(hnd, src, str, x...)                                \
-        message(hnd, DVBPSI_MSG_WARNING, "libdvbpsi warning ("src"):
" str, ##x)
+        dvbpsi_message(hnd, DVBPSI_MSG_WARNING, "libdvbpsi warning
(%s): " str, src, ##x)
 #  define dvbpsi_debug(hnd, src, str, x...)                                  \
-        message(hnd, DVBPSI_MSG_DEBUG, "libdvbpsi debug ("src"): " str, ##x)
+        dvbpsi_message(hnd, DVBPSI_MSG_DEBUG, "libdvbpsi debug (%s):
" str, src, ##x)
 #else
 void dvbpsi_error(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...);
 void dvbpsi_warning(dvbpsi_t *dvbpsi, const char *src, const char *fmt, ...);



In addition, my compiler complains about some non-sensical byte
overflow checks, which break my build (with -Werror enabled):


diff --git a/src/descriptors/dr_40.c b/src/descriptors/dr_40.c
index 7648339..d6cb9d1 100644
--- a/src/descriptors/dr_40.c
+++ b/src/descriptors/dr_40.c
@@ -61,8 +61,7 @@ dvbpsi_network_name_dr_t* dvbpsi_DecodeNetworkNameDr(
         return NULL;

     /* Decode data */
-    p_decoded->i_name_length = p_descriptor->i_length <= 255 ?
-                               p_descriptor->i_length : 255;
+    p_decoded->i_name_length = p_descriptor->i_length;
     if (p_decoded->i_name_length)
         memcpy(p_decoded->i_name_byte,
                p_descriptor->p_data,
diff --git a/src/descriptors/dr_73.c b/src/descriptors/dr_73.c
index 1e2299f..38bdd28 100644
--- a/src/descriptors/dr_73.c
+++ b/src/descriptors/dr_73.c
@@ -58,9 +58,6 @@ dvbpsi_default_authority_dr_t
*dvbpsi_DecodeDefaultAuthorityDr(dvbpsi_descriptor
     if (!p_decoded)
         return NULL;

-    if (p_descriptor->i_length > 255)
-        p_descriptor->i_length = 255;
-
     memcpy(&p_decoded->authority, p_descriptor->p_data,
p_descriptor->i_length);
     p_decoded->authority[p_descriptor->i_length] = 0;

diff --git a/src/dvbpsi.c b/src/dvbpsi.c
index f4fd5d8..ffbfaca 100644
--- a/src/dvbpsi.c
+++ b/src/dvbpsi.c
@@ -216,7 +216,6 @@ void dvbpsi_decoder_reset(dvbpsi_decoder_t*
p_decoder, const bool b_force)
 bool dvbpsi_decoder_psi_sections_completed(dvbpsi_decoder_t* p_decoder)
 {
     assert(p_decoder);
-    assert(p_decoder->i_last_section_number <= 255);

     bool b_complete = false;



Best regards,

Martin Jackson


More information about the libdvbpsi-devel mailing list