summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battstat/apmlib/apmlib.c34
-rw-r--r--geyes/themes.c8
2 files changed, 32 insertions, 10 deletions
diff --git a/battstat/apmlib/apmlib.c b/battstat/apmlib/apmlib.c
index 41c8fdf7..0e9946cd 100644
--- a/battstat/apmlib/apmlib.c
+++ b/battstat/apmlib/apmlib.c
@@ -59,7 +59,10 @@ int apm_read(apm_info * i)
if (!(str = fopen(APM_PROC, "r")))
return 1;
- fgets(buffer, sizeof(buffer) - 1, str);
+
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
buffer[sizeof(buffer) - 1] = '\0';
/* Should check for other driver versions; driver 1.9 (and some
@@ -95,12 +98,19 @@ int apm_read(apm_info * i)
sscanf(buffer, "BIOS version: %d.%d",
&i->apm_version_major, &i->apm_version_minor);
- fgets(buffer, sizeof(buffer) - 1, str);
+
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
sscanf(buffer, "Flags: 0x%02x", &i->apm_flags);
if (i->apm_flags & APM_32_BIT_SUPPORT)
{
- fgets(buffer, sizeof(buffer) - 1, str);
- fgets(buffer, sizeof(buffer) - 1, str);
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
if (buffer[0] != 'P')
{
if (!strncmp(buffer + 4, "off line", 8))
@@ -110,7 +120,9 @@ int apm_read(apm_info * i)
else if (!strncmp(buffer + 4, "on back", 7))
i->ac_line_status = 2;
- fgets(buffer, sizeof(buffer) - 1, str);
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
if (!strncmp(buffer + 16, "high", 4))
i->battery_status = 0;
else if (!strncmp(buffer + 16, "low", 3))
@@ -120,15 +132,21 @@ int apm_read(apm_info * i)
else if (!strncmp(buffer + 16, "charg", 5))
i->battery_status = 3;
- fgets(buffer, sizeof(buffer) - 1, str);
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
if (strncmp(buffer + 14, "unknown", 7))
i->battery_percentage = atoi(buffer + 14);
if (i->apm_version_major >= 1 && i->apm_version_minor >= 1)
{
- fgets(buffer, sizeof(buffer) - 1, str);
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
sscanf(buffer, "Battery flag: 0x%02x", &i->battery_flags);
- fgets(buffer, sizeof(buffer) - 1, str);
+ if (fgets(buffer, sizeof(buffer) - 1, str) == NULL)
+ printf("fgets error\n");
+
if (strncmp(buffer + 14, "unknown", 7))
i->battery_time = atoi(buffer + 14);
}
diff --git a/geyes/themes.c b/geyes/themes.c
index 01924ea8..687c4694 100644
--- a/geyes/themes.c
+++ b/geyes/themes.c
@@ -56,7 +56,10 @@ parse_theme_file (EyesApplet *eyes_applet, FILE *theme_file)
{
gchar line_buf [512]; /* prolly overkill */
gchar *token;
- fgets (line_buf, 512, theme_file);
+
+ if (fgets (line_buf, 512, theme_file) == NULL)
+ printf("fgets error\n");
+
while (!feof (theme_file)) {
token = strtok (line_buf, "=");
if (strncmp (token, "wall-thickness",
@@ -92,7 +95,8 @@ parse_theme_file (EyesApplet *eyes_applet, FILE *theme_file)
eyes_applet->theme_dir,
token);
}
- fgets (line_buf, 512, theme_file);
+ if (fgets (line_buf, 512, theme_file) == NULL)
+ printf("fgets error\n");
}
}