Add pointless sanity checks. http://bugs.gentoo.org/91977 --- eject.c +++ eject.c @@ -69,6 +69,16 @@ #include #include +#define CLOSE(fd) if (close(fd)==-1) { \ + perror(programName); \ + exit(1); \ +} + +#define FCLOSE(fd) if (fclose(fd)==-1) { \ + perror(programName); \ + exit(1); \ +} + /* Global Variables */ const char *version = VERSION; /* program version */ int a_option = 0; /* command flags and arguments */ @@ -627,7 +637,7 @@ GetMajorMinor(s1, &mtabmaj, &mtabmin); if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { - fclose(fp); + FCLOSE(fp); *deviceName = strdup(s1); *mountName = strdup(s2); return 1; @@ -636,7 +646,7 @@ } *deviceName = 0; *mountName = 0; - fclose(fp); + FCLOSE(fp); return 0; } @@ -663,13 +673,13 @@ while (fgets(line, sizeof(line), fp) != 0) { rc = sscanf(line, "%1023s %1023s", s1, s2); if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { - fclose(fp); + FCLOSE(fp); *deviceName = strdup(s1); *mountName = strdup(s2); return 1; } } - fclose(fp); + FCLOSE(fp); return 0; } @@ -708,7 +718,7 @@ } } } - fclose(fp); + FCLOSE(fp); } @@ -1018,7 +1028,7 @@ } /* cleanup */ - close(fd); + CLOSE(fd); free(device); free(deviceName); free(fullName);