static int
check(void)
{
- FILE *f;
+ FILE *f = NULL;
int ret = 0;
int temp = 0;
char buf[4096];
char dummy[4096];
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
+ fclose(f);
+ f = NULL;
buf[sizeof(buf) - 1] = 0;
if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3)
ret = 1;
else
goto error;
- fclose(f);
}
else
goto error;
if (f)
{
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
fclose(f);
+ f = NULL;
buf[sizeof(buf) - 1] = 0;
if (sscanf(buf, "%i", &temp) == 1)
ret = 1;
if (f)
{
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
+ fclose(f);
+ f = NULL;
buf[sizeof(buf) - 1] = 0;
-
/* actually read the temp */
if (sscanf(buf, "%i", &temp) == 1)
ret = 1;
goto error;
/* Hack for temp */
temp = temp / 1000;
- fclose(f);
}
else
goto error;
if (f)
{
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
+ fclose(f);
+ f = NULL;
buf[sizeof(buf) - 1] = 0;
-
/* actually read the temp */
if (sscanf(buf, "%i", &temp) == 1)
ret = 1;
goto error;
/* Hack for temp */
temp = temp / 1000;
- fclose(f);
}
else
goto error;
char *p, *q;
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
- buf[sizeof(buf) - 1] = 0;
fclose(f);
+ f = NULL;
+ buf[sizeof(buf) - 1] = 0;
p = strchr(buf, ':');
if (p)
{
if (f)
{
if (fgets(buf, sizeof(buf), f) == NULL) goto error;
-
- buf[sizeof(buf) - 1] = 0;
fclose(f);
+ f = NULL;
+ buf[sizeof(buf) - 1] = 0;
temp = atoi(buf);
temp /= 1000;
ret = 1;
return -999;
error:
+ if (f) fclose(f);
+ f = NULL;
sensor_type = SENSOR_TYPE_NONE;
if (sensor_name) free(sensor_name);
sensor_name = NULL;