diff --git a/src/api/l_headset.c b/src/api/l_headset.c index f0b41a4e..0daea2f4 100644 --- a/src/api/l_headset.c +++ b/src/api/l_headset.c @@ -628,7 +628,7 @@ static int l_lovrHeadsetGetHands(lua_State* L) { int count = 0; float position[4], orientation[4]; Device hands[] = { DEVICE_HAND_LEFT, DEVICE_HAND_RIGHT }; - for (size_t i = 0; i < sizeof(hands) / sizeof(hands[0]); i++) { + for (size_t i = 0; i < COUNTOF(hands); i++) { FOREACH_TRACKING_DRIVER(driver) { if (driver->getPose(hands[i], position, orientation)) { luax_pushenum(L, Device, hands[i]); @@ -706,7 +706,7 @@ int luaopen_lovr_headset(lua_State* L) { for (int i = 0; i < n; i++) { lua_rawgeti(L, -1, i + 1); drivers[driverCount++] = luax_checkenum(L, -1, HeadsetDriver, NULL); - lovrAssert(driverCount < sizeof(drivers) / sizeof(drivers[0]), "Too many headset drivers specified in conf.lua"); + lovrAssert(driverCount < COUNTOF(drivers), "Too many headset drivers specified in conf.lua"); lua_pop(L, 1); } lua_pop(L, 1); diff --git a/src/api/l_math.c b/src/api/l_math.c index c9957f26..c2de7d22 100644 --- a/src/api/l_math.c +++ b/src/api/l_math.c @@ -380,7 +380,7 @@ int luaopen_lovr_math(lua_State* L) { lua_pushcfunction(L, l_lovrLightUserdata__index); lua_setfield(L, -2, "__index"); const char* ops[] = { "__add", "__sub", "__mul", "__div", "__unm", "__len", "__tostring", "__newindex" }; - for (size_t i = 0; i < sizeof(ops) / sizeof(ops[0]); i++) { + for (size_t i = 0; i < COUNTOF(ops); i++) { lua_pushstring(L, ops[i]); lua_pushcclosure(L, l_lovrLightUserdataOp, 1); lua_setfield(L, -2, ops[i]); diff --git a/src/api/l_physics_joints.c b/src/api/l_physics_joints.c index e201db9c..58e6c7b0 100644 --- a/src/api/l_physics_joints.c +++ b/src/api/l_physics_joints.c @@ -25,7 +25,7 @@ Joint* luax_checkjoint(lua_State* L, int index) { hash64("SliderJoint", strlen("SliderJoint")) }; - for (size_t i = 0; i < sizeof(hashes) / sizeof(hashes[0]); i++) { + for (size_t i = 0; i < COUNTOF(hashes); i++) { if (p->hash == hashes[i]) { return p->object; } diff --git a/src/api/l_physics_shapes.c b/src/api/l_physics_shapes.c index 8cc1f89a..01493e6a 100644 --- a/src/api/l_physics_shapes.c +++ b/src/api/l_physics_shapes.c @@ -27,7 +27,7 @@ Shape* luax_checkshape(lua_State* L, int index) { hash64("MeshShape", strlen("MeshShape")), }; - for (size_t i = 0; i < sizeof(hashes) / sizeof(hashes[0]); i++) { + for (size_t i = 0; i < COUNTOF(hashes); i++) { if (p->hash == hashes[i]) { return p->object; } diff --git a/src/modules/audio/audio.c b/src/modules/audio/audio.c index aec0d88f..8fff160b 100644 --- a/src/modules/audio/audio.c +++ b/src/modules/audio/audio.c @@ -238,7 +238,7 @@ bool lovrAudioInit(const char* spatializer, uint32_t sampleRate) { result = ma_mutex_init(&state.lock); lovrAssert(result == MA_SUCCESS, "Failed to create audio mutex"); - for (size_t i = 0; i < sizeof(spatializers) / sizeof(spatializers[0]); i++) { + for (size_t i = 0; i < COUNTOF(spatializers); i++) { if (spatializer && strcmp(spatializer, spatializers[i]->name)) { continue; }