various: use static assertions where appropriate

This commit is contained in:
sfan5 2024-03-17 18:21:09 +01:00
parent 23c988b3e1
commit ead9f892b3
5 changed files with 5 additions and 5 deletions

View File

@ -114,7 +114,7 @@ static OSStatus enable_property_listener(struct ao *ao, bool enabled)
kAudioHardwarePropertyDevices};
AudioDeviceID devs[] = {p->device,
kAudioObjectSystemObject};
assert(MP_ARRAY_SIZE(selectors) == MP_ARRAY_SIZE(devs));
static_assert(MP_ARRAY_SIZE(selectors) == MP_ARRAY_SIZE(devs), "");
OSStatus status = noErr;
for (int n = 0; n < MP_ARRAY_SIZE(devs); n++) {

View File

@ -3792,7 +3792,7 @@ static void dup_node(void *ta_parent, struct mpv_node *node)
static void copy_node(const m_option_t *opt, void *dst, const void *src)
{
assert(sizeof(struct mpv_node) <= sizeof(union m_option_value));
static_assert(sizeof(struct mpv_node) <= sizeof(union m_option_value), "");
if (!(dst && src))
return;

View File

@ -189,7 +189,7 @@ static bool get_file_ids_win8(HANDLE h, dev_t *dev, ino_t *ino)
// SDK, but we can ignore that by just memcpying it. This will also
// truncate the file ID on 32-bit Windows, which doesn't support __int128.
// 128-bit file IDs are only used for ReFS, so that should be okay.
assert(sizeof(*ino) <= sizeof(ii.FileId));
static_assert(sizeof(*ino) <= sizeof(ii.FileId), "");
memcpy(ino, &ii.FileId, sizeof(*ino));
return true;
}

View File

@ -497,7 +497,7 @@ static int control(stream_t *stream, int cmd, void *arg)
struct stream_dvd_info_req *req = arg;
memset(req, 0, sizeof(*req));
req->num_subs = mp_dvdnav_number_of_subs(stream);
assert(sizeof(uint32_t) == sizeof(unsigned int));
static_assert(sizeof(uint32_t) == sizeof(unsigned int), "");
memcpy(req->palette, priv->spu_clut, sizeof(req->palette));
return STREAM_OK;
}

View File

@ -119,7 +119,7 @@ bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
struct osd_state *osd_create(struct mpv_global *global)
{
assert(MAX_OSD_PARTS >= OSDTYPE_COUNT);
static_assert(MAX_OSD_PARTS >= OSDTYPE_COUNT, "");
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
*osd = (struct osd_state) {