Skip to content

Commit

Permalink
osdep: rename MP_UNREACHABLE
Browse files Browse the repository at this point in the history
It was pointed out on IRC that the name is misleading, since the actual
semantics of the macro is to assert first.
  • Loading branch information
haasn committed Nov 3, 2021
1 parent 701bd78 commit 8bd0dee
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion demux/demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ static void find_backward_restart_pos(struct demux_stream *ds)
// Or if preroll is involved, the first preroll packet.
while (ds->reader_head != target) {
if (!advance_reader_head(ds))
MP_UNREACHABLE(); // target must be in list
MP_ASSERT_UNREACHABLE(); // target must be in list
}

double seek_pts;
Expand Down
2 changes: 1 addition & 1 deletion demux/demux_mkv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ static int read_next_block_into_queue(demuxer_t *demuxer)
if (mkv_d->cluster_end != EBML_UINT_INVALID)
mkv_d->cluster_end += stream_tell(s);
}
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();

add_block:
index_block(demuxer, &block);
Expand Down
4 changes: 2 additions & 2 deletions filters/f_lavfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ static bool init_pads(struct lavfi *c)
} else if (pad->type == MP_FRAME_VIDEO) {
dst_filter = avfilter_get_by_name("buffersink");
} else {
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

if (!dst_filter)
Expand Down Expand Up @@ -484,7 +484,7 @@ static bool init_pads(struct lavfi *c)
params->frame_rate = av_d2q(fmt->nominal_fps, 1000000);
filter_name = "buffer";
} else {
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

params->time_base = pad->timebase;
Expand Down
2 changes: 1 addition & 1 deletion filters/f_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static void fixed_aframe_size_process(struct mp_filter *f)
int in_samples = mp_aframe_get_size(p->in);
int copy = MPMIN(in_samples, p->samples - p->out_written);
if (!mp_aframe_copy_samples(p->out, p->out_written, p->in, 0, copy))
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
mp_aframe_skip_samples(p->in, copy);
p->out_written += copy;
}
Expand Down
2 changes: 1 addition & 1 deletion filters/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static struct mp_pin *find_connected_end(struct mp_pin *p)
return other;
p = other->user_conn;
}
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

// With p being part of a connection, create the pin_connection and set all
Expand Down
2 changes: 1 addition & 1 deletion misc/thread_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static void *worker_thread(void *arg)
return NULL;
}
}
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

pthread_mutex_unlock(&pool->lock);
Expand Down
2 changes: 1 addition & 1 deletion options/m_config_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ void mp_read_option_raw(struct mpv_global *global, const char *name,
}
}

MP_UNREACHABLE(); // not found
MP_ASSERT_UNREACHABLE(); // not found
}

static const struct m_config_group *find_group(struct mpv_global *global,
Expand Down
2 changes: 1 addition & 1 deletion options/parse_configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static bstr read_file(struct mp_log *log, const char *filename)
}
size += s;
}
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

// Load options and profiles from from a config file.
Expand Down
4 changes: 2 additions & 2 deletions osdep/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#endif

#ifdef __GNUC__
#define MP_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable())
#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable())
#else
#define MP_UNREACHABLE() (assert(!"unreachable"), abort())
#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
#endif

#endif
2 changes: 1 addition & 1 deletion player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void hook_remove(struct MPContext *mpctx, struct hook_handler *h)
return;
}
}
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

bool mp_hook_test_completion(struct MPContext *mpctx, char *type)
Expand Down
2 changes: 1 addition & 1 deletion video/mp_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static bool endian_swap_bytes(void *d, size_t bytes, size_t word_size)
AV_WL32(ud + x * 2, AV_RB32(ud + x * 2));
break;
default:
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion video/out/gpu/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -4237,7 +4237,7 @@ static void gl_video_dr_free_buffer(void *opaque, uint8_t *data)
}
}
// not found - must not happen
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

struct mp_image *gl_video_get_image(struct gl_video *p, int imgfmt, int w, int h,
Expand Down
14 changes: 7 additions & 7 deletions video/out/placebo/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim)
case MP_CSP_PRIM_COUNT: return PL_COLOR_PRIM_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc)
Expand All @@ -104,7 +104,7 @@ enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc)
case MP_CSP_TRC_COUNT: return PL_COLOR_TRC_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_color_light mp_light_to_pl(enum mp_csp_light light)
Expand All @@ -118,7 +118,7 @@ enum pl_color_light mp_light_to_pl(enum mp_csp_light light)
case MP_CSP_LIGHT_COUNT: return PL_COLOR_LIGHT_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_color_system mp_csp_to_pl(enum mp_csp csp)
Expand All @@ -136,7 +136,7 @@ enum pl_color_system mp_csp_to_pl(enum mp_csp csp)
case MP_CSP_COUNT: return PL_COLOR_SYSTEM_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels)
Expand All @@ -148,7 +148,7 @@ enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels)
case MP_CSP_LEVELS_COUNT: return PL_COLOR_LEVELS_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha)
Expand All @@ -161,7 +161,7 @@ enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha)
case MP_ALPHA_PREMUL: return PL_ALPHA_PREMULTIPLIED;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}

enum pl_chroma_location mp_chroma_to_pl(enum mp_chroma_location chroma)
Expand All @@ -174,5 +174,5 @@ enum pl_chroma_location mp_chroma_to_pl(enum mp_chroma_location chroma)
case MP_CHROMA_COUNT: return PL_CHROMA_COUNT;
}

MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}
2 changes: 1 addition & 1 deletion video/repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void swap_endian(struct mp_image *dst, int dst_x, int dst_y,
((uint32_t *)d)[x] = av_bswap32(((uint32_t *)s)[x]);
break;
default:
MP_UNREACHABLE();
MP_ASSERT_UNREACHABLE();
}
}
}
Expand Down

0 comments on commit 8bd0dee

Please sign in to comment.