[dvblast-devel] [PATCH 04/17] Fix compiler warnings.

Georgi Chorbadzhiyski gf at unixsol.org
Fri Sep 9 23:28:26 CEST 2011


The fixed warnings are:
  bitstream/dvb/sim.h: In function "tlv_find_data":
  bitstream/dvb/sim.h:216:5: warning: return discards qualifiers from pointer target type

  bitstream/dvb/sim.h: In function "ecmg_validate":
  bitstream/dvb/sim.h:389:5: warning: excess elements in scalar initializer
  bitstream/dvb/sim.h:389:5: warning: (near initialization for ‘p_param’)
  bitstream/dvb/sim.h:389:5: warning: excess elements in scalar initializer
  bitstream/dvb/sim.h:389:5: warning: (near initialization for ‘p_param’)

  bitstream/dvb/si.h: In function ‘dvb_string_set’:
  bitstream/dvb/si.h:174:9: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
  /usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘const uint8_t *’

  bitstream/dvb/si.h:174:9: warning: pointer targets in passing argument 1 of ‘__strdup’ differ in signedness
  /usr/include/bits/string2.h:1303:14: note: expected ‘const char *’ but argument is of type ‘const uint8_t *’
  bitstream/dvb/si.h:174:9: warning: pointer targets in return differ in signedness

  bitstream/dvb/si.h: In function ‘dvb_string_get’:
  bitstream/dvb/si.h:219:25: warning: passing argument 3 of ‘pf_iconv’ discards qualifiers from pointer target type
  bitstream/dvb/si.h:219:25: note: expected ‘char *’ but argument is of type ‘const uint8_t *’

  bitstream/dvb/si.h: In function ‘desc48_get_service’:
  bitstream/dvb/si.h:742:5: warning: return discards qualifiers from pointer target type
---
 dvb/si.h  |    8 ++++----
 dvb/sim.h |    5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/dvb/si.h b/dvb/si.h
index 331c2a2..a983498 100644
--- a/dvb/si.h
+++ b/dvb/si.h
@@ -171,7 +171,7 @@ static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
 
     if (!strcmp(psz_encoding, "ISO_8859-9")) {
         *pi_out_length = i_length;
-        return strdup(p_string);
+        return (uint8_t *)strdup((const char *)p_string);
     }
 
     for (i = 0; ppsz_dvb_encodings[i] != NULL; i++) {
@@ -216,7 +216,7 @@ static inline char *dvb_string_get(const uint8_t *p_string, size_t i_length,
         }
 
         return pf_iconv(iconv_opaque, psz_encoding,
-                        p_string, i_length);
+                        (char *)p_string, i_length);
     }
 
     return strdup("");
@@ -737,9 +737,9 @@ static inline void desc48_set_service(uint8_t *p_desc,
 static inline uint8_t *desc48_get_service(const uint8_t *p_desc,
                                           uint8_t *pi_length)
 {
-    const uint8_t *p = p_desc + DESC48_HEADER_SIZE + 1 + p_desc[3];
+    const uint8_t *p = (uint8_t *)p_desc + DESC48_HEADER_SIZE + 1 + p_desc[3];
     *pi_length = p[0];
-    return p + 1;
+    return (uint8_t *)p + 1;
 }
 
 static inline bool desc48_validate(const uint8_t *p_desc)
diff --git a/dvb/sim.h b/dvb/sim.h
index e13e627..2877c4a 100644
--- a/dvb/sim.h
+++ b/dvb/sim.h
@@ -211,7 +211,7 @@ static inline bool tlv_append_data(uint8_t *p_tlv, uint16_t i_type,
 static inline uint8_t *tlv_find_data(uint8_t *p_tlv, uint16_t i_type,
                                      uint16_t n, uint16_t *pi_length)
 {
-    const uint8_t *p_tlv_n = tlv_find_param(p_tlv, i_type, n);
+    uint8_t *p_tlv_n = tlv_find_param(p_tlv, i_type, n);
     *pi_length = tlv_get_length(p_tlv_n);
     return p_tlv_n + 4;
 }
@@ -386,7 +386,8 @@ static inline bool ecmg_validate(uint8_t *p_tlv)
         {ECMG_PARAM_CPNUMBER, 1, 1}, {ECMG_PARAM_ECM, 1, 1}, {0, 0, 0}
     };
 
-    const tlv_param_count_t *p_param = {0, 0, 0};
+    const tlv_param_count_t null_param = {0, 0, 0};
+    const tlv_param_count_t *p_param = &null_param;
     uint8_t *p_tlv_n;
     int j = 0;
 
-- 
1.7.5.1



More information about the dvblast-devel mailing list