mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-30 13:00:30 +00:00
sensors: Handle option -c more efficiently.
We don't need to strdup() the file names, we can use them directly. As a side effect, this fixes a memory leak which was happening if option -c was specified more than once on the command line. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4205 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
6b5640b660
commit
7891d63259
2 files changed
+3
-8
No files matched your search
@@ -9,6 +9,7 @@ SVN HEAD
|
||||
Program sensord: Add pc87247 support (fans only)
|
||||
Program sensors: Add pc87247 support (fans only)
|
||||
Hide error on missing f71805f fan
|
||||
Handle option -c more efficiently
|
||||
Program sensors-detect: Add SMSC DME1737 detection
|
||||
Add EPoX EP1308 detection (Hans Edgington)
|
||||
|
||||
|
||||
+2
-8
@@ -149,7 +149,7 @@ static void set_degstr(void)
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int c,res,i,error;
|
||||
char *config_file_name = NULL;
|
||||
const char *config_file_name = ETCDIR "/" DEFAULT_CONFIG_FILE_NAME;
|
||||
|
||||
struct option long_opts[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
@@ -187,7 +187,7 @@ int main (int argc, char *argv[])
|
||||
print_version();
|
||||
exit(0);
|
||||
case 'c':
|
||||
config_file_name = strdup(optarg);
|
||||
config_file_name = optarg;
|
||||
break;
|
||||
case 's':
|
||||
do_sets = 1;
|
||||
@@ -229,11 +229,7 @@ int main (int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (config_file_name == NULL)
|
||||
config_file_name = strdup(ETCDIR "/" DEFAULT_CONFIG_FILE_NAME);
|
||||
open_config_file(config_file_name);
|
||||
|
||||
if ((res = sensors_init(config_file))) {
|
||||
fprintf(stderr,"%s\n",sensors_strerror(res));
|
||||
if (res == -SENSORS_ERR_PROC)
|
||||
@@ -243,9 +239,7 @@ int main (int argc, char *argv[])
|
||||
"was compiled with sysfs support!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
close_config_file(config_file_name);
|
||||
free(config_file_name);
|
||||
|
||||
/* build the degrees string */
|
||||
set_degstr();
|
||||
|
||||
Reference in new issue
Block a user