mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Settings_write: fix return value on error
Return a negative errno on fprintf() or flcose() failure, not a return value of ferror() or flcose().
This commit is contained in:
parent
23797e730e
commit
1275139795
12
Settings.c
12
Settings.c
@ -333,9 +333,15 @@ int Settings_write(const Settings* this) {
|
||||
fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
|
||||
#endif
|
||||
|
||||
int r1 = ferror(fd);
|
||||
int r2 = fclose(fd);
|
||||
return r1 ? r1 : r2;
|
||||
int r = 0;
|
||||
|
||||
if (ferror(fd) != 0)
|
||||
r = (errno != 0) ? -errno : -EBADF;
|
||||
|
||||
if (fclose(fd) != 0)
|
||||
r = r ? r : -errno;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Settings* Settings_new(int initialCpuCount) {
|
||||
|
Loading…
Reference in New Issue
Block a user