Cleaned up compiler warnings about unchecked return values. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jul 2011 11:49:46 -0700
branchSDL-1.2
changeset 55599f181779cfdd
parent 5550 80ae1ac3bdc9
child 5560 98ae43d3d2f4
Cleaned up compiler warnings about unchecked return values.
src/video/fbcon/SDL_fbevents.c
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/fbcon/SDL_fbevents.c	Sat Jun 04 15:34:32 2011 -0400
     1.2 +++ b/src/video/fbcon/SDL_fbevents.c	Thu Jul 07 11:49:46 2011 -0700
     1.3 @@ -359,9 +359,10 @@
     1.4  			SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name);
     1.5  			status=fopen(path, "r");
     1.6  			if ( status ) {
     1.7 +				int matches = 0;
     1.8  				name[0] = '\0';
     1.9 -				fscanf(status, "Name: %s", name);
    1.10 -				if ( SDL_strcmp(name, wanted_name) == 0 ) {
    1.11 +				matches = fscanf(status, "Name: %s", name);
    1.12 +				if ( (matches == 1) && (SDL_strcmp(name, wanted_name) == 0) ) {
    1.13  					pid = SDL_atoi(entry->d_name);
    1.14  				}
    1.15  				fclose(status);
    1.16 @@ -479,7 +480,9 @@
    1.17  	tv.tv_usec = 0;
    1.18  	while ( select(fd+1, &fdset, 0, 0, &tv) > 0 ) {
    1.19  		char temp[32];
    1.20 -		read(fd, temp, sizeof(temp));
    1.21 +		if (read(fd, temp, sizeof(temp)) <= 0) {
    1.22 +			break;
    1.23 +		}
    1.24  	}
    1.25  
    1.26  	return retval;
    1.27 @@ -508,7 +511,9 @@
    1.28  		tv.tv_usec = 0;
    1.29  		while ( select(fd+1, &fdset, 0, 0, &tv) > 0 ) {
    1.30  			char temp[32];
    1.31 -			read(fd, temp, sizeof(temp));
    1.32 +			if (read(fd, temp, sizeof(temp)) <= 0) {
    1.33 +				break;
    1.34 +			}
    1.35  		}
    1.36  
    1.37     		/* Query for the type of mouse protocol */
    1.38 @@ -770,9 +775,7 @@
    1.39  	/* Figure out the mouse packet size */
    1.40  	switch (mouse_drv) {
    1.41  		case MOUSE_NONE:
    1.42 -			/* Ack! */
    1.43 -			read(mouse_fd, mousebuf, BUFSIZ);
    1.44 -			return;
    1.45 +			break;  /* carry on to read from device and discard it. */
    1.46  		case MOUSE_MSC:
    1.47  			packetsize = 5;
    1.48  			break;
    1.49 @@ -812,14 +815,20 @@
    1.50  	if ( nread < 0 ) {
    1.51  		return;
    1.52  	}
    1.53 +
    1.54 +	if (mouse_drv == MOUSE_NONE) {
    1.55 +		return;  /* we're done; just draining the input queue. */
    1.56 +	}
    1.57 +
    1.58  	nread += start;
    1.59  #ifdef DEBUG_MOUSE
    1.60  	fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
    1.61  #endif
    1.62 +
    1.63  	for ( i=0; i<(nread-(packetsize-1)); i += packetsize ) {
    1.64  		switch (mouse_drv) {
    1.65 -			case MOUSE_NONE:
    1.66 -				break;
    1.67 +			case MOUSE_NONE: /* shouldn't actually hit this. */
    1.68 +				break;  /* just throw everything away. */
    1.69  			case MOUSE_MSC:
    1.70  				/* MSC protocol has 0x80 in high byte */
    1.71  				if ( (mousebuf[i] & 0xF8) != 0x80 ) {
     2.1 --- a/src/video/x11/SDL_x11modes.c	Sat Jun 04 15:34:32 2011 -0400
     2.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Jul 07 11:49:46 2011 -0700
     2.3 @@ -465,10 +465,13 @@
     2.4  
     2.5          metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
     2.6          if ( metro_fp != NULL ) {
     2.7 -            int major, minor, patch, version;
     2.8 +            int major, minor, patch, version, scannum;
     2.9              major = 0; minor = 0; patch = 0;
    2.10 -            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
    2.11 +            scannum = fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
    2.12              fclose(metro_fp);
    2.13 +            if ( (scannum < 0) || (scannum > 3) ) {
    2.14 +                return 0;  /* we need _something_ useful from fscanf(). */
    2.15 +            }
    2.16              version = major*100+minor*10+patch;
    2.17              if ( version < 431 ) {
    2.18                  return 0;