Skip to content

Commit 3b36b8c

Browse files
authored
Global: use ARRAY_SIZE (#1718)
1 parent 05f1476 commit 3b36b8c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/modules/cpu/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
220220
yyjson_mut_obj_add_uint(doc, frequency, "max", cpu.frequencyMax);
221221

222222
yyjson_mut_val* coreTypes = yyjson_mut_obj_add_arr(doc, obj, "coreTypes");
223-
for (uint32_t i = 0; i < sizeof (cpu.coreTypes) / sizeof (cpu.coreTypes[0]) && cpu.coreTypes[i].count > 0; i++)
223+
for (uint32_t i = 0; i < ARRAY_SIZE(cpu.coreTypes) && cpu.coreTypes[i].count > 0; i++)
224224
{
225225
yyjson_mut_val* core = yyjson_mut_arr_add_obj(doc, coreTypes);
226226
yyjson_mut_obj_add_uint(doc, core, "count", cpu.coreTypes[i].count);

src/modules/cpucache/cpucache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
1212
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
1313

1414
char levelStr[4] = "L";
15-
for (uint32_t i = 0; i < sizeof (result->caches) / sizeof (result->caches[0]) && result->caches[i].length > 0; i++)
15+
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++)
1616
{
1717
ffStrbufClear(&key);
1818
levelStr[1] = (char) ('1' + i);
@@ -72,7 +72,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio
7272
{
7373
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
7474
uint64_t sum = 0;
75-
for (uint32_t i = 0; i < sizeof (result->caches) / sizeof (result->caches[0]) && result->caches[i].length > 0; i++)
75+
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++)
7676
{
7777
if (buffer.length)
7878
ffStrbufAppendS(&buffer, ", ");
@@ -199,7 +199,7 @@ void ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yy
199199

200200
yyjson_mut_val* caches = yyjson_mut_obj_add_obj(doc, module, "result");
201201

202-
for (uint32_t i = 0; i < sizeof (result.caches) / sizeof (result.caches[0]) && result.caches[i].length > 0; i++)
202+
for (uint32_t i = 0; i < ARRAY_SIZE(result.caches) && result.caches[i].length > 0; i++)
203203
{
204204
yyjson_mut_val* level = yyjson_mut_obj_add_arr(doc, caches, &"l1\0l2\0l3\0l4\0"[i * 3]);
205205
FF_LIST_FOR_EACH(FFCPUCache, src, result.caches[i])

0 commit comments

Comments
 (0)