aboutsummaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
committerDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
commit31b71b67011fa52f091df6fe536a11d6d0bfb256 (patch)
tree31cb222871017376af8b7435d24cf4961863fa93 /Settings.c
parent8c82a38002ce09db2a0b83dab8b598cf1ab0596c (diff)
downloaddebian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.gz
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.bz2
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.zip
Imported Upstream version 2.0.2upstream/2.0.2
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/Settings.c b/Settings.c
index a6bb355..0e296c1 100644
--- a/Settings.c
+++ b/Settings.c
@@ -159,7 +159,7 @@ static void readFields(ProcessField* fields, int* flags, const char* line) {
j++;
}
}
- fields[j] = (ProcessField) NULL;
+ fields[j] = NULL_PROCESSFIELD;
String_freeArray(ids);
}
@@ -167,18 +167,21 @@ static bool Settings_read(Settings* this, const char* fileName) {
FILE* fd;
uid_t euid = geteuid();
- seteuid(getuid());
+ (void) seteuid(getuid());
fd = fopen(fileName, "r");
- seteuid(euid);
+ (void) seteuid(euid);
if (!fd)
return false;
- const int maxLine = 2048;
- char buffer[maxLine];
bool readMeters = false;
- while (fgets(buffer, maxLine, fd)) {
+ for (;;) {
+ char* line = String_readLine(fd);
+ if (!line) {
+ break;
+ }
int nOptions;
- char** option = String_split(buffer, '=', &nOptions);
+ char** option = String_split(line, '=', &nOptions);
+ free (line);
if (nOptions < 2) {
String_freeArray(option);
continue;
@@ -277,9 +280,9 @@ bool Settings_write(Settings* this) {
FILE* fd;
uid_t euid = geteuid();
- seteuid(getuid());
+ (void) seteuid(getuid());
fd = fopen(this->filename, "w");
- seteuid(euid);
+ (void) seteuid(euid);
if (fd == NULL) {
return false;
}
@@ -366,7 +369,7 @@ Settings* Settings_new(int cpuCount) {
}
legacyDotfile = String_cat(home, "/.htoprc");
uid_t euid = geteuid();
- seteuid(getuid());
+ (void) seteuid(getuid());
(void) mkdir(configDir, 0700);
(void) mkdir(htopDir, 0700);
free(htopDir);
@@ -379,7 +382,7 @@ Settings* Settings_new(int cpuCount) {
free(legacyDotfile);
legacyDotfile = NULL;
}
- seteuid(euid);
+ (void) seteuid(euid);
}
this->colorScheme = 0;
this->changed = false;

© 2014-2024 Faster IT GmbH | imprint | privacy policy