Compare commits

...

2 Commits

Author SHA1 Message Date
Ben Buhse
84c3e0baf1
Remove noop()
Sending a handler with incompatible pointer types is undefined
behavior, so this removes noop() and implements empty handlers for all
of its previous uses.

This used to work until C23.
2024-12-03 13:21:33 +01:00
Ben Buhse
3ef08977b3
Remove ctype.h include 2024-12-03 13:20:03 +01:00

52
wlopm.c
View File

@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <stdbool.h> #include <stdbool.h>
@ -93,8 +92,6 @@ struct zwlr_output_power_manager_v1 *wlr_output_power_manager = NULL;
int ret = EXIT_SUCCESS; int ret = EXIT_SUCCESS;
bool loop = true; bool loop = true;
static void noop () {}
static void wlr_output_power_handle_mode (void *data, struct zwlr_output_power_v1 *wlr_output_power, static void wlr_output_power_handle_mode (void *data, struct zwlr_output_power_v1 *wlr_output_power,
enum zwlr_output_power_v1_mode mode) enum zwlr_output_power_v1_mode mode)
{ {
@ -122,13 +119,43 @@ static void wl_output_handle_name (void *data, struct wl_output *wl_output,
output->name = strdup(name); output->name = strdup(name);
} }
static void wl_output_handle_geometry (void *data, struct wl_output *wl_output,
int32_t x, int32_t y, int32_t physical_width, int32_t physical_height,
int32_t subpixel, const char* make, const char* model, int32_t transform)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_mode (void *data, struct wl_output *wl_output,
uint32_t flags, int32_t width, int32_t height, int32_t refresh)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_scale (void *data, struct wl_output *wl_output,
int32_t scale)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_description (void *data, struct wl_output *wl_output,
const char *description)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_done (void *data, struct wl_output *wl_output)
{
/* This function is deliberately left empty. */
}
static const struct wl_output_listener wl_output_listener = { static const struct wl_output_listener wl_output_listener = {
.name = wl_output_handle_name, .name = wl_output_handle_name,
.geometry = noop, .geometry = wl_output_handle_geometry,
.mode = noop, .mode = wl_output_handle_mode,
.scale = noop, .scale = wl_output_handle_scale,
.description = noop, .description = wl_output_handle_description,
.done = noop, .done = wl_output_handle_done,
}; };
static void registry_handle_global (void *data, struct wl_registry *registry, static void registry_handle_global (void *data, struct wl_registry *registry,
@ -165,9 +192,15 @@ static void registry_handle_global (void *data, struct wl_registry *registry,
&zwlr_output_power_manager_v1_interface, version); &zwlr_output_power_manager_v1_interface, version);
} }
static void registry_handle_global_remove (void *data, struct wl_registry *registry,
uint32_t name)
{
/* We don't run long enough to care. */
}
static const struct wl_registry_listener registry_listener = { static const struct wl_registry_listener registry_listener = {
.global = registry_handle_global, .global = registry_handle_global,
.global_remove = noop, /* We don't run long enough to care. */ .global_remove = registry_handle_global_remove,
}; };
static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint32_t other_data); static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint32_t other_data);
@ -570,4 +603,3 @@ int main(int argc, char *argv[])
return ret; return ret;
} }