[MPlayer-dev-eng] some funny stuff in asf_mmst_streaming.c

Dominik Mierzejewski dominik at rangers.eu.org
Mon Oct 28 17:26:45 CET 2002


On Monday, 28 October 2002, Jindrich Makovicka wrote:
> Hello,
> 
> trying to squish additional warnings from the -Wall output, I came over 
> this:
> 
> int asf_mmst_streaming_start(stream_t *stream)
> {
>  char                 str[1024];
>  char                 data[1024];
>  uint8_t              asf_header[8192];
>  int                  asf_header_len;
>  int                  len, i, packet_length;
>  char                *path;
>  URL_t *url1 = stream->streaming_ctrl->url;
>  int s;
> 
>  if( s>0 ) {  // <--------------
>          close( stream->fd );
>          stream->fd = -1;
>  }

That looks bad. 's' must be initialized before checking its value.

On a related note, here's a patch that fixes some warnings in this file. I
changed int to int32_t for packet_len type, because it's assumed that it
contains 4 bytes of data, which is not always the case with int. Also some
typecasting to avoid incompatible type warnings. I hope it's good to commit.
 
-- 
MPlayer RPMs maintainer: http://www.piorunek.pl/~dominik/linux/pkgs/mplayer/
"The Universe doesn't give you any points for doing things that are easy."
        -- Sheridan to Garibaldi in Babylon 5:"The Geometry of Shadows"
-------------- next part --------------
--- MPlayer-20021024/libmpdemux/asf_mmst_streaming.c.warn	Thu Oct 24 00:56:30 2002
+++ MPlayer-20021024/libmpdemux/asf_mmst_streaming.c	Thu Oct 24 01:18:16 2002
@@ -200,16 +200,16 @@
 
     } else {
 
-      int packet_len;
+      int32_t packet_len;
       int command;
       char data[BUF_SIZE];
 
-      if (!get_data (s, &packet_len, 4)) {
+      if (!get_data (s, (char *)&packet_len, 4)) {
 	printf ("packet_len read failed\n");
 	return 0;
       }
       
-      packet_len = get_32 (&packet_len, 0) + 4;
+      packet_len = get_32 ((unsigned char *)&packet_len, 0) + 4;
       
 //      printf ("command packet detected, len=%d\n", packet_len);
       
@@ -333,14 +333,15 @@
 
   } else {
 
-    int packet_len, command;
+    int32_t packet_len;
+    int command;
 
-    if (!get_data (s, &packet_len, 4)) {
+    if (!get_data (s, (char *)&packet_len, 4)) {
       printf ("packet_len read failed\n");
       return 0;
     }
 
-    packet_len = get_32 (&packet_len, 0) + 4;
+    packet_len = get_32 ((unsigned char *)&packet_len, 0) + 4;
 
     if (!get_data (s, data, packet_len)) {
       printf ("command data read failed\n");


More information about the MPlayer-dev-eng mailing list