@@ -59,7 +59,7 @@ void check_requirements()
5959
6060 /**
6161 * Check for root
62- */
62+ */
6363
6464 uid_t uid = getuid (), euid = geteuid ();
6565
@@ -71,42 +71,28 @@ void check_requirements()
7171
7272 /**
7373 * Check for coretemp and applesmc modules
74- * Credits: -http://stackoverflow.com/questions/12978794
7574 */
76- FILE * fd = popen ("lsmod | grep coretemp" , "r" );
77- char buf [16 ];
78-
79- if (!(fread (buf , 1 , sizeof (buf ), fd ) > 0 )) {
80- DIR * dir = opendir (CORETEMP_PATH );
81-
82- if (ENOENT == errno ) {
83- syslog (LOG_ERR , "%s needs coretemp support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
84- printf ("%s needs coretemp module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
85- exit (EXIT_FAILURE );
86- }
87-
88- closedir (dir );
75+ DIR * dir = opendir (CORETEMP_PATH );
8976
77+ if (ENOENT == errno ) {
78+ syslog (LOG_ERR , "%s needs coretemp support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
79+ printf ("%s needs coretemp module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
80+ exit (EXIT_FAILURE );
9081 }
9182
92- pclose ( fd );
83+ closedir ( dir );
9384
94- fd = popen ("lsmod | grep applesmc" , "r" );
9585
96- if (!(fread (buf , 1 , sizeof (buf ), fd ) > 0 )) {
97- DIR * dir = opendir (APPLESMC_PATH );
98-
99- if (ENOENT == errno ) {
100- syslog (LOG_ERR , "%s needs applesmc support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
101- printf ("%s needs applesmc module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
102- exit (EXIT_FAILURE );
103- }
104-
105- closedir (dir );
86+ dir = opendir (APPLESMC_PATH );
10687
88+ if (ENOENT == errno ) {
89+ syslog (LOG_ERR , "%s needs applesmc support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
90+ printf ("%s needs applesmc module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
91+ exit (EXIT_FAILURE );
10792 }
10893
109- pclose (fd );
94+ closedir (dir );
95+
11096
11197}
11298
0 commit comments