Some more locations for ARRAYSIZE

This commit is contained in:
Benny Baumann 2020-10-03 22:00:27 +02:00 committed by cgzones
parent 2970cae543
commit 4a78f4bb92
9 changed files with 18 additions and 9 deletions

View File

@ -7,6 +7,7 @@ in the source distribution for its full text.
*/ */
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
#include "SwapMeter.h" #include "SwapMeter.h"
@ -63,7 +64,7 @@ const SignalItem Platform_signals[] = {
{ .name = "31 SIGUSR2", .number = 31 }, { .name = "31 SIGUSR2", .number = 31 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
ProcessFieldData Process_fields[] = { ProcessFieldData Process_fields[] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },

View File

@ -9,6 +9,7 @@ in the source distribution for its full text.
#include "ProcessList.h" #include "ProcessList.h"
#include "DragonFlyBSDProcessList.h" #include "DragonFlyBSDProcessList.h"
#include "DragonFlyBSDProcess.h" #include "DragonFlyBSDProcess.h"
#include "Macros.h"
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -253,7 +254,7 @@ static inline void DragonFlyBSDProcessList_scanMemoryInfo(ProcessList* pl) {
//pl->freeMem *= pageSizeKb; //pl->freeMem *= pageSizeKb;
struct kvm_swap swap[16]; struct kvm_swap swap[16];
int nswap = kvm_getswapinfo(dfpl->kd, swap, sizeof(swap)/sizeof(swap[0]), 0); int nswap = kvm_getswapinfo(dfpl->kd, swap, ARRAYSIZE(swap), 0);
pl->totalSwap = 0; pl->totalSwap = 0;
pl->usedSwap = 0; pl->usedSwap = 0;
for (int i = 0; i < nswap; i++) { for (int i = 0; i < nswap; i++) {

View File

@ -7,6 +7,7 @@ in the source distribution for its full text.
*/ */
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "Meter.h" #include "Meter.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
@ -71,7 +72,7 @@ const SignalItem Platform_signals[] = {
{ .name = "33 SIGLIBRT", .number = 33 }, { .name = "33 SIGLIBRT", .number = 33 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;

View File

@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "FreeBSDProcess.h" #include "FreeBSDProcess.h"
#include "zfs/ZfsArcStats.h" #include "zfs/ZfsArcStats.h"
#include "zfs/openzfs_sysctl.h" #include "zfs/openzfs_sysctl.h"
#include "Macros.h"
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -293,7 +294,7 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) {
//pl->freeMem *= pageSizeKb; //pl->freeMem *= pageSizeKb;
struct kvm_swap swap[16]; struct kvm_swap swap[16];
int nswap = kvm_getswapinfo(fpl->kd, swap, sizeof(swap)/sizeof(swap[0]), 0); int nswap = kvm_getswapinfo(fpl->kd, swap, ARRAYSIZE(swap), 0);
pl->totalSwap = 0; pl->totalSwap = 0;
pl->usedSwap = 0; pl->usedSwap = 0;
for (int i = 0; i < nswap; i++) { for (int i = 0; i < nswap; i++) {

View File

@ -6,6 +6,7 @@ in the source distribution for its full text.
*/ */
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "Meter.h" #include "Meter.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
@ -72,7 +73,7 @@ const SignalItem Platform_signals[] = {
{ .name = "33 SIGLIBRT", .number = 33 }, { .name = "33 SIGLIBRT", .number = 33 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;

View File

@ -10,6 +10,7 @@ in the source distribution for its full text.
#include "ProcessList.h" #include "ProcessList.h"
#include "OpenBSDProcessList.h" #include "OpenBSDProcessList.h"
#include "OpenBSDProcess.h" #include "OpenBSDProcess.h"
#include "Macros.h"
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
@ -118,7 +119,7 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
pl->cachedMem *= PAGE_SIZE_KB; pl->cachedMem *= PAGE_SIZE_KB;
struct kvm_swap swap[16]; struct kvm_swap swap[16];
int nswap = kvm_getswapinfo(opl->kd, swap, sizeof(swap)/sizeof(swap[0]), 0); int nswap = kvm_getswapinfo(opl->kd, swap, ARRAYSIZE(swap), 0);
pl->totalSwap = 0; pl->totalSwap = 0;
pl->usedSwap = 0; pl->usedSwap = 0;
for (int i = 0; i < nswap; i++) { for (int i = 0; i < nswap; i++) {

View File

@ -7,6 +7,7 @@ in the source distribution for its full text.
*/ */
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "Meter.h" #include "Meter.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
@ -84,7 +85,7 @@ const SignalItem Platform_signals[] = {
{ .name = "32 SIGTHR", .number = 32 }, { .name = "32 SIGTHR", .number = 32 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;

View File

@ -8,6 +8,7 @@ in the source distribution for its full text.
*/ */
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "Meter.h" #include "Meter.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
@ -83,7 +84,7 @@ const SignalItem Platform_signals[] = {
{ .name = "41 SIGINFO", .number = 41 }, { .name = "41 SIGINFO", .number = 41 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
ProcessField Platform_defaultFields[] = { PID, LWPID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; ProcessField Platform_defaultFields[] = { PID, LWPID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };

View File

@ -9,6 +9,7 @@ in the source distribution for its full text.
#include <math.h> #include <math.h>
#include "Platform.h" #include "Platform.h"
#include "Macros.h"
#include "CPUMeter.h" #include "CPUMeter.h"
#include "MemoryMeter.h" #include "MemoryMeter.h"
#include "SwapMeter.h" #include "SwapMeter.h"
@ -25,7 +26,7 @@ const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
}; };
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };