Skip to content

Commit

Permalink
Cleaned up compiler warnings about unchecked return values.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 7, 2011
1 parent 724c22e commit 05fe5d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
27 changes: 18 additions & 9 deletions src/video/fbcon/SDL_fbevents.c
Expand Up @@ -359,9 +359,10 @@ static int find_pid(DIR *proc, const char *wanted_name)
SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name);
status=fopen(path, "r");
if ( status ) {
int matches = 0;
name[0] = '\0';
fscanf(status, "Name: %s", name);
if ( SDL_strcmp(name, wanted_name) == 0 ) {
matches = fscanf(status, "Name: %s", name);
if ( (matches == 1) && (SDL_strcmp(name, wanted_name) == 0) ) {
pid = SDL_atoi(entry->d_name);
}
fclose(status);
Expand Down Expand Up @@ -479,7 +480,9 @@ static int set_imps2_mode(int fd)
tv.tv_usec = 0;
while ( select(fd+1, &fdset, 0, 0, &tv) > 0 ) {
char temp[32];
read(fd, temp, sizeof(temp));
if (read(fd, temp, sizeof(temp)) <= 0) {
break;
}
}

return retval;
Expand Down Expand Up @@ -508,7 +511,9 @@ static int detect_imps2(int fd)
tv.tv_usec = 0;
while ( select(fd+1, &fdset, 0, 0, &tv) > 0 ) {
char temp[32];
read(fd, temp, sizeof(temp));
if (read(fd, temp, sizeof(temp)) <= 0) {
break;
}
}

/* Query for the type of mouse protocol */
Expand Down Expand Up @@ -770,9 +775,7 @@ static void handle_mouse(_THIS)
/* Figure out the mouse packet size */
switch (mouse_drv) {
case MOUSE_NONE:
/* Ack! */
read(mouse_fd, mousebuf, BUFSIZ);
return;
break; /* carry on to read from device and discard it. */
case MOUSE_MSC:
packetsize = 5;
break;
Expand Down Expand Up @@ -812,14 +815,20 @@ static void handle_mouse(_THIS)
if ( nread < 0 ) {
return;
}

if (mouse_drv == MOUSE_NONE) {
return; /* we're done; just draining the input queue. */
}

nread += start;
#ifdef DEBUG_MOUSE
fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
#endif

for ( i=0; i<(nread-(packetsize-1)); i += packetsize ) {
switch (mouse_drv) {
case MOUSE_NONE:
break;
case MOUSE_NONE: /* shouldn't actually hit this. */
break; /* just throw everything away. */
case MOUSE_MSC:
/* MSC protocol has 0x80 in high byte */
if ( (mousebuf[i] & 0xF8) != 0x80 ) {
Expand Down
7 changes: 5 additions & 2 deletions src/video/x11/SDL_x11modes.c
Expand Up @@ -465,10 +465,13 @@ static int CheckVidMode(_THIS, int *major, int *minor)

metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
if ( metro_fp != NULL ) {
int major, minor, patch, version;
int major, minor, patch, version, scannum;
major = 0; minor = 0; patch = 0;
fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
scannum = fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
fclose(metro_fp);
if ( (scannum < 0) || (scannum > 3) ) {
return 0; /* we need _something_ useful from fscanf(). */
}
version = major*100+minor*10+patch;
if ( version < 431 ) {
return 0;
Expand Down

0 comments on commit 05fe5d4

Please sign in to comment.