diff --git a/prog/sensord/chips.c b/prog/sensord/chips.c index e16b458c..e1106c4b 100644 --- a/prog/sensord/chips.c +++ b/prog/sensord/chips.c @@ -89,7 +89,7 @@ fmtMHz_2 /** LM75 **/ -static char *lm75_names[] = { +static const char *lm75_names[] = { SENSORS_LM75_PREFIX, NULL }; @@ -101,7 +101,7 @@ static FeatureDescriptor lm75_features[] = { /** ADM1021 **/ -static char *adm1021_names[] = { +static const char *adm1021_names[] = { SENSORS_ADM1021_PREFIX, NULL }; @@ -117,7 +117,7 @@ static FeatureDescriptor adm1021_features[] = { /** MAX1617 **/ -static char *max1617_names[] = { +static const char *max1617_names[] = { SENSORS_MAX1617_PREFIX, SENSORS_MAX1617A_PREFIX, SENSORS_THMC10_PREFIX, SENSORS_LM84_PREFIX, SENSORS_GL523_PREFIX, NULL }; @@ -131,7 +131,7 @@ static FeatureDescriptor max1617_features[] = { /** ADM9240 **/ -static char *adm9240_names[] = { +static const char *adm9240_names[] = { SENSORS_ADM9240_PREFIX, SENSORS_DS1780_PREFIX, SENSORS_LM81_PREFIX, NULL }; @@ -161,7 +161,7 @@ static FeatureDescriptor adm9240_features[] = { /** SIS5595 **/ -static char *sis5595_names[] = { +static const char *sis5595_names[] = { SENSORS_SIS5595_PREFIX, NULL }; @@ -185,7 +185,7 @@ static FeatureDescriptor sis5595_features[] = { /** LM78 **/ -static char *lm78_names[] = { +static const char *lm78_names[] = { SENSORS_LM78_PREFIX, SENSORS_LM78J_PREFIX, SENSORS_LM79_PREFIX, /*"sis5595",*/ NULL }; @@ -219,7 +219,7 @@ static FeatureDescriptor lm78_features[] = { /** GL518 **/ -static char *gl518_names[] = { +static const char *gl518_names[] = { SENSORS_GL518_PREFIX, NULL }; @@ -250,7 +250,7 @@ fmtTemps_LM80 return buff; } -static char *lm80_names[] = { +static const char *lm80_names[] = { SENSORS_LM80_PREFIX, NULL }; @@ -280,7 +280,7 @@ static FeatureDescriptor lm80_features[] = { /** W83781D **/ -static char *w83781d_names[] = { +static const char *w83781d_names[] = { SENSORS_W83781D_PREFIX, NULL }; @@ -327,7 +327,7 @@ fmtTemps_W8378x return buff; } -static char *w83782d_names[] = { +static const char *w83782d_names[] = { SENSORS_W83782D_PREFIX, SENSORS_W83627HF_PREFIX, SENSORS_AS99127F_PREFIX, NULL }; @@ -367,7 +367,7 @@ static FeatureDescriptor w83782d_features[] = { /** W83783S **/ -static char *w83783s_names[] = { +static const char *w83783s_names[] = { SENSORS_W83783S_PREFIX, NULL }; @@ -412,7 +412,7 @@ fmtFans_Maxilife return buff; } -static char *maxilife_names[] = { +static const char *maxilife_names[] = { SENSORS_MAXI_CG_PREFIX, SENSORS_MAXI_CO_PREFIX, SENSORS_MAXI_AS_PREFIX, NULL }; diff --git a/prog/sensord/sensord.c b/prog/sensord/sensord.c index 16b4b2a3..17d4ec3b 100644 --- a/prog/sensord/sensord.c +++ b/prog/sensord/sensord.c @@ -39,13 +39,13 @@ #include "sensord.h" -static char *version = "0.2.0"; +static const char *version = "0.2.0"; -static char *sensorsCfgPaths[] = { +static const char *sensorsCfgPaths[] = { "/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib", "/usr/local/lib", NULL }; -static char *sensorsCfgFile = "sensors.conf"; -static char *sensorsLogFile = "/var/log/sensors"; +static const char *sensorsCfgFile = "sensors.conf"; +static const char *sensorsLogFile = "/var/log/sensors"; static int sleepTime = 5 * 60; static int cfgLoaded = 0; @@ -79,7 +79,7 @@ initSignals } static char * -now +nowf (void) { time_t now; char *str; @@ -128,11 +128,11 @@ static int readKnownChip (const sensors_chip_name *chip, ChipDescriptor *descriptor) { FeatureDescriptor *features = descriptor->features; - int index, subindex; + int index0, subindex; int ret = 0; - for (index = 0; !done && (ret == 0) && features[index].format; ++ index) { - FeatureDescriptor *feature = features + index; + for (index0 = 0; !done && (ret == 0) && features[index0].format; ++ index0) { + FeatureDescriptor *feature = features + index0; char *label = NULL; double values[MAX_DATA]; @@ -158,25 +158,25 @@ static int readChip (const sensors_chip_name *chip) { const char *adapter, *algorithm; - int index, subindex, chipindex = -1; + int index0, subindex, chipindex = -1; int ret = 0; if (chip->bus == SENSORS_CHIP_NAME_BUS_ISA) - fprintf (sensorsLog, "%s: Chip: %s-isa-%04x\n", now (), chip->prefix, chip->addr); + fprintf (sensorsLog, "%s: Chip: %s-isa-%04x\n", nowf(), chip->prefix, chip->addr); else - fprintf (sensorsLog, "%s: Chip: %s-i2c-%d-%02x\n", now (), chip->prefix, chip->bus, chip->addr); + fprintf (sensorsLog, "%s: Chip: %s-i2c-%d-%02x\n", nowf(), chip->prefix, chip->bus, chip->addr); adapter = sensors_get_adapter_name (chip->bus); if (adapter) - fprintf (sensorsLog, "%s: Adapter: %s\n", now (), adapter); + fprintf (sensorsLog, "%s: Adapter: %s\n", nowf(), adapter); algorithm = sensors_get_algorithm_name (chip->bus); if (algorithm) - fprintf (sensorsLog, "%s: Algorithm: %s\n", now (), algorithm); + fprintf (sensorsLog, "%s: Algorithm: %s\n", nowf(), algorithm); /* assert adapter || algorithm */ - for (index = 0; knownChips[index].names; ++ index) - for (subindex = 0; knownChips[index].names[subindex]; ++ subindex) - if (!strcmp (chip->prefix, knownChips[index].names[subindex])) - chipindex = index; + for (index0 = 0; knownChips[index0].names; ++ index0) + for (subindex = 0; knownChips[index0].names[subindex]; ++ subindex) + if (!strcmp (chip->prefix, knownChips[index0].names[subindex])) + chipindex = index0; if (chipindex >= 0) ret = readKnownChip (chip, knownChips + chipindex); @@ -190,17 +190,17 @@ static int readChips (void) { const sensors_chip_name *chip; - int index = 0; + int index0 = 0; int ret = 0; - fprintf (sensorsLog, "%s: Sense.\n", now ()); + fprintf (sensorsLog, "%s: Sense.\n", nowf()); fflush (sensorsLog); - while (!done && (ret == 0) && ((chip = sensors_get_detected_chips (&index)) != NULL)) { + while (!done && (ret == 0) && ((chip = sensors_get_detected_chips (&index0)) != NULL)) { ret = readChip (chip); } - fprintf (sensorsLog, "%s: Done.\n", now ()); + fprintf (sensorsLog, "%s: Done.\n", nowf()); fflush (sensorsLog); return ret; @@ -212,14 +212,14 @@ rotateLog int ret = 0; if (sensorsLog != NULL) { - fprintf (sensorsLog, "%s: Rotate.\n", now ()); + fprintf (sensorsLog, "%s: Rotate.\n", nowf()); fclose (sensorsLog); } if (!(sensorsLog = fopen (sensorsLogFile, "a"))) { syslog (LOG_ERR, "Error opening sensors log: %s", sensorsLogFile); ret = 1; } else { - fprintf (sensorsLog, "%s: Started.\n", now ()); + fprintf (sensorsLog, "%s: Started.\n", nowf()); fflush (sensorsLog); } rotate = 0; @@ -240,13 +240,13 @@ initSensors if (sensorsCfgFile[0] == '/') { strcpy (cfgPath, sensorsCfgFile); } else { - int index; - for (index = 0; sensorsCfgPaths[index]; ++ index) { - sprintf (cfgPath, "%s/%s", sensorsCfgPaths[index], sensorsCfgFile); + int index0; + for (index0 = 0; sensorsCfgPaths[index0]; ++ index0) { + sprintf (cfgPath, "%s/%s", sensorsCfgPaths[index0], sensorsCfgFile); if (stat (cfgPath, &stats) == 0) break; } - if (!sensorsCfgPaths[index]) { + if (!sensorsCfgPaths[index0]) { syslog (LOG_ERR, "Error locating sensors configuration: %s", sensorsCfgFile); return 9; } @@ -298,7 +298,7 @@ sensord sensors_cleanup (); if (sensorsLog) { - fprintf (sensorsLog, "%s: %s.\n", now (), ret ? "Failed" : "Stopped"); + fprintf (sensorsLog, "%s: %s.\n", nowf(), ret ? "Failed" : "Stopped"); fclose (sensorsLog); }