From f7fe4b4722129a8444b2f07d2ef1ce9d2500e613 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 8 Sep 2011 02:48:53 +0000 Subject: [PATCH] Fix off-by-one error in PROCESSOR display --- AffinityPanel.c | 2 +- CPUMeter.c | 2 +- ProcessList.c | 2 +- ProcessList.h | 2 +- htop.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AffinityPanel.c b/AffinityPanel.c index dcbc5d2f..b3ea4123 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -33,7 +33,7 @@ Panel* AffinityPanel_new(ProcessList* pl, unsigned long mask) { Panel_setHeader(this, "Use CPUs:"); for (int i = 0; i < pl->cpuCount; i++) { char number[10]; - snprintf(number, 9, "%d", ProcessList_cpuId(pl, i) + 1); + snprintf(number, 9, "%d", ProcessList_cpuId(pl, i)); Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mask & (1 << i))); } return this; diff --git a/CPUMeter.c b/CPUMeter.c index 8e6f9001..2c4c4dbc 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -33,7 +33,7 @@ static void CPUMeter_init(Meter* this) { int cpu = this->param; if (this->pl->cpuCount > 1) { char caption[10]; - sprintf(caption, "%-3d", ProcessList_cpuId(this->pl, cpu)); + sprintf(caption, "%-3d", ProcessList_cpuId(this->pl, cpu - 1)); Meter_setCaption(this, caption); } if (this->param == 0) diff --git a/ProcessList.c b/ProcessList.c index 2a01d8e1..c200eb91 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -55,7 +55,7 @@ in the source distribution for its full text. #endif #ifndef ProcessList_cpuId -#define ProcessList_cpuId(pl, cpu) ((pl)->countCPUsFromZero ? (cpu)-1 : (cpu)) +#define ProcessList_cpuId(pl, cpu) ((pl)->countCPUsFromZero ? (cpu) : (cpu)+1) #endif }*/ diff --git a/ProcessList.h b/ProcessList.h index ea8f71d0..c7bc5aca 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -57,7 +57,7 @@ in the source distribution for its full text. #endif #ifndef ProcessList_cpuId -#define ProcessList_cpuId(pl, cpu) ((pl)->countCPUsFromZero ? (cpu)-1 : (cpu)) +#define ProcessList_cpuId(pl, cpu) ((pl)->countCPUsFromZero ? (cpu) : (cpu)+1) #endif diff --git a/htop.c b/htop.c index 2818b2e0..fd47a1e9 100644 --- a/htop.c +++ b/htop.c @@ -778,7 +778,7 @@ int main(int argc, char** argv) { if (!ok) beep(); } - ((Object*)affinityPanel)->delete((Object*)affinityPanel); + Panel_delete((Object*)affinityPanel); ProcessList_printHeader(pl, Panel_getHeader(panel)); refreshTimeout = 0; break;