mirror of https://github.com/xzeldon/htop.git
minor style cleanups
This commit is contained in:
parent
ff8d54c221
commit
58676d7001
|
@ -50,17 +50,11 @@ static unsigned long int parseUevent(FILE * file, const char *key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long int parseBatInfo(const char *fileName, const unsigned short int lineNum, const unsigned short int wordNum) {
|
static unsigned long int parseBatInfo(const char *fileName, const unsigned short int lineNum, const unsigned short int wordNum) {
|
||||||
DIR* batteryDir;
|
|
||||||
const struct dirent *dirEntries;
|
|
||||||
|
|
||||||
const char batteryPath[] = PROCDIR "/acpi/battery/";
|
const char batteryPath[] = PROCDIR "/acpi/battery/";
|
||||||
batteryDir = opendir(batteryPath);
|
DIR* batteryDir = opendir(batteryPath);
|
||||||
|
if (!batteryDir)
|
||||||
if (batteryDir == NULL) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
char *entryName;
|
|
||||||
typedef struct listLbl {
|
typedef struct listLbl {
|
||||||
char *content;
|
char *content;
|
||||||
struct listLbl *next;
|
struct listLbl *next;
|
||||||
|
@ -73,8 +67,8 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
|
||||||
Some of this is based off of code found in kismet (they claim it came from gkrellm).
|
Some of this is based off of code found in kismet (they claim it came from gkrellm).
|
||||||
Written for multi battery use...
|
Written for multi battery use...
|
||||||
*/
|
*/
|
||||||
for (dirEntries = readdir((DIR *) batteryDir); dirEntries; dirEntries = readdir((DIR *) batteryDir)) {
|
for (const struct dirent* dirEntries = readdir((DIR *) batteryDir); dirEntries; dirEntries = readdir((DIR *) batteryDir)) {
|
||||||
entryName = (char *) dirEntries->d_name;
|
char* entryName = (char *) dirEntries->d_name;
|
||||||
|
|
||||||
if (strncmp(entryName, "BAT", 3))
|
if (strncmp(entryName, "BAT", 3))
|
||||||
continue;
|
continue;
|
||||||
|
@ -122,22 +116,16 @@ static ACPresence chkIsOnline() {
|
||||||
ACPresence isOn = AC_ERROR;
|
ACPresence isOn = AC_ERROR;
|
||||||
|
|
||||||
if (access(PROCDIR "/acpi/ac_adapter", F_OK) == 0) {
|
if (access(PROCDIR "/acpi/ac_adapter", F_OK) == 0) {
|
||||||
const struct dirent *dirEntries;
|
|
||||||
const char *power_supplyPath = PROCDIR "/acpi/ac_adapter";
|
const char *power_supplyPath = PROCDIR "/acpi/ac_adapter";
|
||||||
DIR *power_supplyDir = opendir(power_supplyPath);
|
DIR *power_supplyDir = opendir(power_supplyPath);
|
||||||
char *entryName;
|
if (!power_supplyDir)
|
||||||
|
|
||||||
if (!power_supplyDir) {
|
|
||||||
return AC_ERROR;
|
return AC_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
for (dirEntries = readdir((DIR *) power_supplyDir); dirEntries; dirEntries = readdir((DIR *) power_supplyDir)) {
|
for (const struct dirent *dirEntries = readdir((DIR *) power_supplyDir); dirEntries; dirEntries = readdir((DIR *) power_supplyDir)) {
|
||||||
entryName = (char *) dirEntries->d_name;
|
char* entryName = (char *) dirEntries->d_name;
|
||||||
|
|
||||||
if (strncmp(entryName, "A", 1)) {
|
if (entryName[0] != 'A')
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char statePath[50];
|
char statePath[50];
|
||||||
snprintf((char *) statePath, sizeof statePath, "%s/%s/state", power_supplyPath, entryName);
|
snprintf((char *) statePath, sizeof statePath, "%s/%s/state", power_supplyPath, entryName);
|
||||||
|
@ -247,11 +235,8 @@ static double getSysBatData() {
|
||||||
const struct dirent *dirEntries;
|
const struct dirent *dirEntries;
|
||||||
const char *power_supplyPath = "/sys/class/power_supply/";
|
const char *power_supplyPath = "/sys/class/power_supply/";
|
||||||
DIR *power_supplyDir = opendir(power_supplyPath);
|
DIR *power_supplyDir = opendir(power_supplyPath);
|
||||||
|
if (!power_supplyDir)
|
||||||
|
|
||||||
if (!power_supplyDir) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
char *entryName;
|
char *entryName;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue