[linux-dvb] [patch 3/3] fix strict aliasing warning.

Ludwig Nussel ludwig.nussel at suse.de
Thu Sep 29 11:52:43 CEST 2005


An int* must not be used to change some enum. As workaround a char* can be
used.

Index: dvb-apps/util/szap/azap.c
===================================================================
--- dvb-apps.orig/util/szap/azap.c
+++ dvb-apps/util/szap/azap.c
@@ -149,13 +149,14 @@ int try_parse_int(int fd, int *val, cons
 }
 
 
+/** param is a four byte memory location */
 static
-int try_parse_param(int fd, const Param * plist, int list_size, int *param,
+int try_parse_param(int fd, const Param * plist, int list_size, char *param,
 		    const char *pname)
 {
 	int err;
 
-	err = parse_param(fd, plist, list_size, param);
+	err = parse_param(fd, plist, list_size, (int*)param);
 
 	if (err)
 		ERROR("error while parsing %s (%s)", pname,
@@ -189,7 +190,7 @@ int parse(const char *fname, const char 
 
 	if ((err = try_parse_param(fd,
 				   modulation_list, LIST_SIZE(modulation_list),
-				   (int *) &frontend->u.vsb.modulation,
+				   (char *) &frontend->u.vsb.modulation,
 				   "modulation")))
 		return -4;
 
Index: dvb-apps/util/szap/tzap.c
===================================================================
--- dvb-apps.orig/util/szap/tzap.c
+++ dvb-apps/util/szap/tzap.c
@@ -226,13 +226,14 @@ int try_parse_int(int fd, int *val, cons
 }
 
 
+/** param is a four byte memory location */
 static
-int try_parse_param(int fd, const Param * plist, int list_size, int *param,
+int try_parse_param(int fd, const Param * plist, int list_size, char *param,
 		    const char *pname)
 {
 	int err;
 
-	err = parse_param(fd, plist, list_size, param);
+	err = parse_param(fd, plist, list_size, (int*)param);
 
 	if (err)
 		ERROR("error while parsing %s (%s)", pname,
@@ -285,24 +286,24 @@ int parse(const char *fname, const char 
 
 	if ((err = try_parse_param(fd,
 				   inversion_list, LIST_SIZE(inversion_list),
-				   (int *) &frontend->inversion,
+				   (char *) &frontend->inversion,
 				   "inversion")))
 		return -4;
 
 	if ((err = try_parse_param(fd, bw_list, LIST_SIZE(bw_list),
-				   (int *) &frontend->u.ofdm.bandwidth,
+				   (char *) &frontend->u.ofdm.bandwidth,
 				   "bandwidth")))
 		return -5;
 
 	if ((err = try_parse_param(fd, fec_list, LIST_SIZE(fec_list),
-				   (int *) &frontend->u.ofdm.code_rate_HP,
+				   (char *) &frontend->u.ofdm.code_rate_HP,
 				   "code_rate_HP")))
 		return -6;
 	if (check_fec(&frontend->u.ofdm.code_rate_HP))
 		return -6;
 
 	if ((err = try_parse_param(fd, fec_list, LIST_SIZE(fec_list),
-				   (int *) &frontend->u.ofdm.code_rate_LP,
+				   (char *) &frontend->u.ofdm.code_rate_LP,
 				   "code_rate_LP")))
 		return -7;
 	if (check_fec(&frontend->u.ofdm.code_rate_LP))
@@ -310,25 +311,25 @@ int parse(const char *fname, const char 
 
 	if ((err = try_parse_param(fd, constellation_list,
 				   LIST_SIZE(constellation_list),
-				   (int *) &frontend->u.ofdm.constellation,
+				   (char *) &frontend->u.ofdm.constellation,
 				   "constellation")))
 		return -8;
 
 	if ((err = try_parse_param(fd, transmissionmode_list,
 				   LIST_SIZE(transmissionmode_list),
-				   (int *) &frontend->u.ofdm.
+				   (char *) &frontend->u.ofdm.
 				   transmission_mode,
 				   "transmission_mode")))
 		return -9;
 
 	if ((err = try_parse_param(fd, guard_list, LIST_SIZE(guard_list),
-				   (int *) &frontend->u.ofdm.
+				   (char *) &frontend->u.ofdm.
 				   guard_interval, "guard_interval")))
 		return -10;
 
 	if ((err = try_parse_param(fd, hierarchy_list,
 				   LIST_SIZE(hierarchy_list),
-				   (int *) &frontend->u.ofdm.
+				   (char *) &frontend->u.ofdm.
 				   hierarchy_information,
 				   "hierarchy_information")))
 		return -11;

--
 (o_   Ludwig Nussel
 //\   SUSE LINUX Products GmbH, Development
 V_/_  http://www.suse.de/



More information about the linux-dvb mailing list