mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-08 10:06:28 -05:00
Use wl_container_of() instead of casts
This slightly improves type safety.
The culprits were found with:
git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
This commit is contained in:
parent
c2c536de03
commit
fe06e5f49a
29 changed files with 85 additions and 55 deletions
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
static const struct wlr_buffer_impl client_buffer_impl;
|
||||
|
||||
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer) {
|
||||
if (buffer->impl != &client_buffer_impl) {
|
||||
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *wlr_buffer) {
|
||||
if (wlr_buffer->impl != &client_buffer_impl) {
|
||||
return NULL;
|
||||
}
|
||||
return (struct wlr_client_buffer *)buffer;
|
||||
struct wlr_client_buffer *buffer = wl_container_of(wlr_buffer, buffer, base);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static struct wlr_client_buffer *client_buffer_from_buffer(
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@
|
|||
static const struct wlr_buffer_impl dmabuf_buffer_impl;
|
||||
|
||||
static struct wlr_dmabuf_buffer *dmabuf_buffer_from_buffer(
|
||||
struct wlr_buffer *buffer) {
|
||||
assert(buffer->impl == &dmabuf_buffer_impl);
|
||||
return (struct wlr_dmabuf_buffer *)buffer;
|
||||
struct wlr_buffer *wlr_buffer) {
|
||||
assert(wlr_buffer->impl == &dmabuf_buffer_impl);
|
||||
struct wlr_dmabuf_buffer *buffer = wl_container_of(wlr_buffer, buffer, base);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void dmabuf_buffer_destroy(struct wlr_buffer *wlr_buffer) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@
|
|||
static const struct wlr_buffer_impl readonly_data_buffer_impl;
|
||||
|
||||
static struct wlr_readonly_data_buffer *readonly_data_buffer_from_buffer(
|
||||
struct wlr_buffer *buffer) {
|
||||
assert(buffer->impl == &readonly_data_buffer_impl);
|
||||
return (struct wlr_readonly_data_buffer *)buffer;
|
||||
struct wlr_buffer *wlr_buffer) {
|
||||
assert(wlr_buffer->impl == &readonly_data_buffer_impl);
|
||||
struct wlr_readonly_data_buffer *buffer = wl_container_of(wlr_buffer, buffer, base);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void readonly_data_buffer_destroy(struct wlr_buffer *wlr_buffer) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue