Here's a patch that fixes a number of warnings triggered by uncommon GCC switches such as -Wshadow and -Wwrite-strings.

Lionel.
>From 6b5321f87a917e89be040ec13d897d1bea352814 Mon Sep 17 00:00:00 2001
From: Lionel Debroux <[EMAIL PROTECTED]>
Date: Fri, 11 Apr 2008 19:59:04 +0200
Subject: Fix a number of warnings triggered by e.g. -Wshadow and -Wwrite-strings.

---
 trunk/include/video_out.h   |    2 +-
 trunk/libmpeg2/alloc.c      |    8 ++++----
 trunk/libmpeg2/header.c     |   22 +++++++++++-----------
 trunk/libvo/video_out_sdl.c |    4 ++--
 trunk/src/corrupt_mpeg2.c   |   30 +++++++++++++++---------------
 trunk/src/dump_state.c      |   16 ++++++++--------
 trunk/src/mpeg2dec.c        |    4 ++--
 7 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/trunk/include/video_out.h b/trunk/include/video_out.h
index 1cfd2aa..0910247 100644
--- a/trunk/include/video_out.h
+++ b/trunk/include/video_out.h
@@ -51,7 +51,7 @@ struct vo_instance_s {
 typedef vo_instance_t * vo_open_t (void);
 
 typedef struct {
-    char * name;
+    const char * name;
     vo_open_t * open;
 } vo_driver_t;
 
diff --git a/trunk/libmpeg2/alloc.c b/trunk/libmpeg2/alloc.c
index 0698937..6d9e468 100644
--- a/trunk/libmpeg2/alloc.c
+++ b/trunk/libmpeg2/alloc.c
@@ -62,9 +62,9 @@ void mpeg2_free (void * buf)
 	free (*(((void **)buf) - 1));
 }
 
-void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
-			 int free (void *))
+void mpeg2_malloc_hooks (void * _malloc (unsigned, mpeg2_alloc_t),
+			 int _free (void *))
 {
-    malloc_hook = malloc;
-    free_hook = free;
+    malloc_hook = _malloc;
+    free_hook = _free;
 }
diff --git a/trunk/libmpeg2/header.c b/trunk/libmpeg2/header.c
index 90a4190..faa08f0 100644
--- a/trunk/libmpeg2/header.c
+++ b/trunk/libmpeg2/header.c
@@ -408,13 +408,13 @@ int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
     return (height == 576) ? 1 : 2;
 }
 
-static void copy_matrix (mpeg2dec_t * mpeg2dec, int index)
+static void copy_matrix (mpeg2dec_t * mpeg2dec, int idx)
 {
-    if (memcmp (mpeg2dec->quantizer_matrix[index],
-		mpeg2dec->new_quantizer_matrix[index], 64)) {
-	memcpy (mpeg2dec->quantizer_matrix[index],
-		mpeg2dec->new_quantizer_matrix[index], 64);
-	mpeg2dec->scaled[index] = -1;
+    if (memcmp (mpeg2dec->quantizer_matrix[idx],
+		mpeg2dec->new_quantizer_matrix[idx], 64)) {
+	memcpy (mpeg2dec->quantizer_matrix[idx],
+		mpeg2dec->new_quantizer_matrix[idx], 64);
+	mpeg2dec->scaled[idx] = -1;
     }
 }
 
@@ -857,7 +857,7 @@ int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec)
     return 0;
 }
 
-static void prescale (mpeg2dec_t * mpeg2dec, int index)
+static void prescale (mpeg2dec_t * mpeg2dec, int idx)
 {
     static int non_linear_scale [] = {
 	 0,  1,  2,  3,  4,  5,   6,   7,
@@ -868,13 +868,13 @@ static void prescale (mpeg2dec_t * mpeg2dec, int index)
     int i, j, k;
     mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
 
-    if (mpeg2dec->scaled[index] != decoder->q_scale_type) {
-	mpeg2dec->scaled[index] = decoder->q_scale_type;
+    if (mpeg2dec->scaled[idx] != decoder->q_scale_type) {
+	mpeg2dec->scaled[idx] = decoder->q_scale_type;
 	for (i = 0; i < 32; i++) {
 	    k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
 	    for (j = 0; j < 64; j++)
-		decoder->quantizer_prescale[index][i][j] =
-		    k * mpeg2dec->quantizer_matrix[index][j];
+		decoder->quantizer_prescale[idx][i][j] =
+		    k * mpeg2dec->quantizer_matrix[idx][j];
 	}
     }
 }
diff --git a/trunk/libvo/video_out_sdl.c b/trunk/libvo/video_out_sdl.c
index 3a212ac..9011225 100644
--- a/trunk/libvo/video_out_sdl.c
+++ b/trunk/libvo/video_out_sdl.c
@@ -142,8 +142,8 @@ vo_instance_t * vo_sdl_open (void)
     instance->vo.close = NULL; /* sdl_close; */
     instance->sdlflags = SDL_HWSURFACE | SDL_RESIZABLE;
 
-    putenv("SDL_VIDEO_YUV_HWACCEL=1");
-    putenv("SDL_VIDEO_X11_NODIRECTCOLOR=1");
+    putenv((char *)"SDL_VIDEO_YUV_HWACCEL=1");
+    putenv((char *)"SDL_VIDEO_X11_NODIRECTCOLOR=1");
 
     if (SDL_Init (SDL_INIT_VIDEO)) {
 	fprintf (stderr, "sdl video initialization failed.\n");
diff --git a/trunk/src/corrupt_mpeg2.c b/trunk/src/corrupt_mpeg2.c
index 950813d..8397bb5 100644
--- a/trunk/src/corrupt_mpeg2.c
+++ b/trunk/src/corrupt_mpeg2.c
@@ -77,31 +77,31 @@ static uint32_t clip (double p)
     return (p < 0) ? 0 : ((p >= 1) ? 0xffffffff : (uint32_t)(p*4294967296.0));
 }
 
-static void randbyte_init (double p, randbyte_t * rand)
+static void randbyte_init (double p, randbyte_t * rnd)
 {
     double q, r;
     int i;
 
-    rand->p = clip (p);
+    rnd->p = clip (p);
     r = 1;
     for (i = 0; i < 8; i++) {
 	r *= 1 - p;
 	q = p / (1 - r);
-	rand->q[i] = clip (q);
+	rnd->q[i] = clip (q);
     }
-    rand->r = clip (1 - r);
+    rnd->r = clip (1 - r);
 }
 
-static inline uint8_t randbyte (const randbyte_t * const rand)
+static inline uint8_t randbyte (const randbyte_t * const rnd)
 {
     int i, j;
 
-    if (fastrand () > rand->r || rand->r == 0)
+    if (fastrand () > rnd->r || rnd->r == 0)
 	return 0;
 
     i = 7; j = 0;
     do
-	if (fastrand () <= (j ? rand->p : rand->q[i]))
+	if (fastrand () <= (j ? rnd->p : rnd->q[i]))
 	    j |= 1 << i;
     while (i--);
     return j;
@@ -125,7 +125,7 @@ static void corrupt_arg (corrupt_t * corrupt, int type, char * s, char ** argv)
 {
     corrupt->type = type;
     if (! *s)
-	s = ",0-0xff,0-";
+	s = (char *)",0-0xff,0-";
     else if (*s != ',' || !isdigit (s[1]))
 	print_usage (argv);
     corrupt->chunk_start = strtol (s + 1, &s, 0);
@@ -136,7 +136,7 @@ static void corrupt_arg (corrupt_t * corrupt, int type, char * s, char ** argv)
     else
 	print_usage (argv);
     if (! *s)
-	s = ",32-";
+	s = (char *)",32-";
     else if (*s != ',' || !isdigit (s[1]))
 	print_usage (argv);
     corrupt->bit_start = strtol (s + 1, &s, 0);
@@ -258,7 +258,7 @@ static void update_corrupt_list (void)
 
 static void corrupt (uint8_t * ptr)
 {
-    corrupt_t * corrupt;
+    corrupt_t * pCorrupt;
 
     if (ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 1) {
 	current_chunk = (ptr[3] << 4) | (ptr[4] >> 4);
@@ -269,14 +269,14 @@ static void corrupt (uint8_t * ptr)
 
     current_bit += 8;
 
-    for (corrupt = corrupt_head; corrupt; corrupt = corrupt->next)
-	switch (corrupt->type) {
+    for (pCorrupt = corrupt_head; pCorrupt; pCorrupt = pCorrupt->next)
+	switch (pCorrupt->type) {
 	case CORRUPT_RANDOM:
-	    *ptr ^= randbyte (&corrupt->u.prob) & corrupt->mask;
+	    *ptr ^= randbyte (&pCorrupt->u.prob) & pCorrupt->mask;
 	    break;
 	case CORRUPT_VALUE:
-	    *ptr = ((*ptr & ~corrupt->mask) |
-		    (randbyte (&corrupt->u.prob) & corrupt->mask));
+	    *ptr = ((*ptr & ~pCorrupt->mask) |
+		    (randbyte (&pCorrupt->u.prob) & pCorrupt->mask));
 	    break;
 	}
 }
diff --git a/trunk/src/dump_state.c b/trunk/src/dump_state.c
index d4c1b33..b915025 100644
--- a/trunk/src/dump_state.c
+++ b/trunk/src/dump_state.c
@@ -209,22 +209,22 @@ static void pic_code_del (const mpeg2_picture_t * pic)
 void dump_state (FILE * f, mpeg2_state_t state, const mpeg2_info_t * info,
 		 int offset, int verbose)
 {
-    static char * state_name[] = {
+    static const char * state_name[] = {
 	"BUFFER", "SEQUENCE", "SEQUENCE_REPEATED", "SEQUENCE_MODIFIED", "GOP",
 	"PICTURE", "SLICE_1ST", "PICTURE_2ND", "SLICE", "END",
 	"INVALID", "INVALID_END"
     };
-    static char * profile[] = { "HP", "Spatial", "SNR", "MP", "SP" };
-    static char * level[] = { "HL", "H-14", "ML", "LL" };
-    static char * profile2[] = { "[EMAIL PROTECTED]", NULL, NULL, "[EMAIL PROTECTED]",
+    static const char * profile[] = { "HP", "Spatial", "SNR", "MP", "SP" };
+    static const char * level[] = { "HL", "H-14", "ML", "LL" };
+    static const char * profile2[] = { "[EMAIL PROTECTED]", NULL, NULL, "[EMAIL PROTECTED]",
 				 NULL, NULL, NULL, NULL, "[EMAIL PROTECTED]",
 				 "[EMAIL PROTECTED]", NULL, "[EMAIL PROTECTED]", "[EMAIL PROTECTED]" };
-    static char * video_fmt[] = { "COMPONENT", "PAL", "NTSC", "SECAM", "MAC"};
-    static char coding_type[] = { '0', 'I', 'P', 'B', 'D', '5', '6', '7'};
-    static char * colour[] = { NULL, "BT.709", "UNSPECIFIED", NULL,
+    static const char * video_fmt[] = { "COMPONENT", "PAL", "NTSC", "SECAM", "MAC"};
+    static const char coding_type[] = { '0', 'I', 'P', 'B', 'D', '5', '6', '7'};
+    static const char * colour[] = { NULL, "BT.709", "UNSPECIFIED", NULL,
 			       "BT.470-2/M", "BT.470-2/B,G",
 			       "SMPTE170M", "SMPTE240M", "LINEAR" };
-    static char * colour3[] = { NULL, "BT.709", "UNSPEC_COLORS", NULL, NULL,
+    static const char * colour3[] = { NULL, "BT.709", "UNSPEC_COLORS", NULL, NULL,
 				"BT.470-2/B,G", "SMPTE170M", "SMPTE240M" };
     const mpeg2_sequence_t * seq = info->sequence;
     const mpeg2_gop_t * gop = info->gop;
diff --git a/trunk/src/mpeg2dec.c b/trunk/src/mpeg2dec.c
index 66be762..59b36d7 100644
--- a/trunk/src/mpeg2dec.c
+++ b/trunk/src/mpeg2dec.c
@@ -517,7 +517,7 @@ static int demux (uint8_t * buf, uint8_t * end, int flags)
 			       (header[10] << 22) | ((header[11] >> 1) << 15) |
 			       (header[12] << 7) | (header[13] >> 1));
 			dts = (!(header[7] & 0x40) ? pts :
-			       (((header[14] >> 1) << 30) |
+			       (uint32_t)(((header[14] >> 1) << 30) |
 				(header[15] << 22) |
 				((header[16] >> 1) << 15) |
 				(header[17] << 7) | (header[18] >> 1)));
@@ -552,7 +552,7 @@ static int demux (uint8_t * buf, uint8_t * end, int flags)
 			       (ptsbuf[0] << 22) | ((ptsbuf[1] >> 1) << 15) |
 			       (ptsbuf[2] << 7) | (ptsbuf[3] >> 1));
 			dts = (((ptsbuf[-1] & 0xf0) != 0x30) ? pts :
-			       (((ptsbuf[4] >> 1) << 30) |
+			       (uint32_t)(((ptsbuf[4] >> 1) << 30) |
 				(ptsbuf[5] << 22) | ((ptsbuf[6] >> 1) << 15) |
 				(ptsbuf[7] << 7) | (ptsbuf[18] >> 1)));
 			mpeg2_tag_picture (mpeg2dec, pts, dts);
-- 
1.5.4.2

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Libmpeg2-devel mailing list
Libmpeg2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel

Reply via email to