mirror of
https://github.com/yshui/picom.git
synced 2025-04-14 17:53:25 -04:00
misc: fix/silence a bunch of linter warnings
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
3deb3f2689
commit
a813091fb4
22 changed files with 64 additions and 103 deletions
|
@ -11,7 +11,6 @@
|
|||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "region.h"
|
||||
#include "renderer/layout.h"
|
||||
#include "wm/win.h"
|
||||
#include "x.h"
|
||||
|
||||
|
|
2
src/c2.h
2
src/c2.h
|
@ -72,6 +72,7 @@ c2_condition *c2_condition_list_entry(struct list_node *list);
|
|||
/// Create a new condition list with a single condition that is always true.
|
||||
c2_condition *c2_new_true(struct list_node *list);
|
||||
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define c2_condition_list_foreach(list, i) \
|
||||
for (c2_condition *i = \
|
||||
list_is_empty((list)) ? NULL : c2_condition_list_entry((list)->next); \
|
||||
|
@ -86,6 +87,7 @@ c2_condition *c2_new_true(struct list_node *list);
|
|||
list_is_empty((list)) ? NULL : c2_condition_list_entry((list)->next), \
|
||||
*n = c2_condition_list_next(list, i); \
|
||||
i; i = n, n = c2_condition_list_next(list, i))
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
/**
|
||||
* Destroy a condition list.
|
||||
|
|
|
@ -62,12 +62,6 @@
|
|||
struct atom;
|
||||
struct conv;
|
||||
|
||||
/// Linked list type of atoms.
|
||||
typedef struct _latom {
|
||||
xcb_atom_t atom;
|
||||
struct _latom *next;
|
||||
} latom_t;
|
||||
|
||||
struct shader_info {
|
||||
char *key;
|
||||
char *source;
|
||||
|
|
13
src/config.c
13
src/config.c
|
@ -211,12 +211,14 @@ static conv *parse_blur_kern(const char *src, const char **endptr) {
|
|||
|
||||
// Get matrix width and height
|
||||
double val = 0.0;
|
||||
if (src == (pc = parse_readnum(src, &val))) {
|
||||
pc = parse_readnum(src, &val);
|
||||
if (src == pc) {
|
||||
goto err1;
|
||||
}
|
||||
src = pc;
|
||||
width = (int)val;
|
||||
if (src == (pc = parse_readnum(src, &val))) {
|
||||
pc = parse_readnum(src, &val);
|
||||
if (src == pc) {
|
||||
goto err1;
|
||||
}
|
||||
src = pc;
|
||||
|
@ -247,7 +249,8 @@ static conv *parse_blur_kern(const char *src, const char **endptr) {
|
|||
matrix->data[i] = 1;
|
||||
continue;
|
||||
}
|
||||
if (src == (pc = parse_readnum(src, &val))) {
|
||||
pc = parse_readnum(src, &val);
|
||||
if (src == pc) {
|
||||
goto err2;
|
||||
}
|
||||
src = pc;
|
||||
|
@ -356,7 +359,7 @@ struct conv **parse_blur_kern_lst(const char *src, int *count) {
|
|||
*count = 0;
|
||||
for (unsigned int i = 0;
|
||||
i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i) {
|
||||
if (!strcmp(CONV_KERN_PREDEF[i].name, src)) {
|
||||
if (strcmp(CONV_KERN_PREDEF[i].name, src) == 0) {
|
||||
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, count);
|
||||
}
|
||||
}
|
||||
|
@ -622,7 +625,7 @@ void *parse_window_shader_prefix(const char *src, const char **end, void *user_d
|
|||
*end = endptr + 1;
|
||||
return shader_source;
|
||||
}
|
||||
void *parse_window_shader_prefix_with_cwd(const char *src, const char **end, void *) {
|
||||
void *parse_window_shader_prefix_with_cwd(const char *src, const char **end, void * /*data*/) {
|
||||
scoped_charp cwd = getcwd(NULL, 0);
|
||||
return parse_window_shader_prefix(src, end, cwd);
|
||||
}
|
||||
|
|
11
src/config.h
11
src/config.h
|
@ -462,14 +462,9 @@ void parse_debug_options(struct debug_options *);
|
|||
const char *xdg_config_home(void);
|
||||
char **xdg_config_dirs(void);
|
||||
|
||||
/// Parse a configuration file
|
||||
/// Returns the actually config_file name used, allocated on heap
|
||||
/// Outputs:
|
||||
/// shadow_enable = whether shadow is enabled globally
|
||||
/// fading_enable = whether fading is enabled globally
|
||||
/// win_option_mask = whether option overrides for specific window type is set for given
|
||||
/// options
|
||||
/// hasneg = whether the convolution kernel has negative values
|
||||
/// Parse a configuration file from default location.
|
||||
///
|
||||
/// @return if config is successfully parsed.
|
||||
bool parse_config_libconfig(options_t *, const char *config_file);
|
||||
|
||||
/// Parse a configuration file is that is enabled, also initialize the winopt_mask with
|
||||
|
|
|
@ -666,13 +666,7 @@ resolve_include(config_t *cfg, const char *include_dir, const char *path, const
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a configuration file from default location.
|
||||
*
|
||||
* Returns if config is successfully parsed.
|
||||
*/
|
||||
bool parse_config_libconfig(options_t *opt, const char *config_file) {
|
||||
|
||||
bool parse_config_libconfig(options_t *opt, const char *config_file) { /*NOLINT(readability-function-cognitive-complexity)*/
|
||||
const char *deprecation_message =
|
||||
"option has been deprecated. Please remove it from your configuration file. "
|
||||
"If you encounter any problems without this feature, please feel free to "
|
||||
|
|
|
@ -75,7 +75,7 @@ typedef uint32_t cdbus_enum_t;
|
|||
#define PICOM_WINDOW_INTERFACE "picom.Window"
|
||||
#define PICOM_COMPOSITOR_INTERFACE "picom.Compositor"
|
||||
|
||||
static DBusHandlerResult cdbus_process(DBusConnection *conn, DBusMessage *m, void *);
|
||||
static DBusHandlerResult cdbus_process(DBusConnection *conn, DBusMessage *m, void *ud);
|
||||
static DBusHandlerResult cdbus_process_windows(DBusConnection *c, DBusMessage *msg, void *ud);
|
||||
|
||||
static dbus_bool_t cdbus_callback_add_timeout(DBusTimeout *timeout, void *data);
|
||||
|
@ -307,8 +307,8 @@ void cdbus_io_callback(EV_P attr_unused, ev_io *w, int revents) {
|
|||
flags |= DBUS_WATCH_WRITABLE;
|
||||
}
|
||||
dbus_watch_handle(dw->dw, flags);
|
||||
while (dbus_connection_dispatch(dw->cd->dbus_conn) != DBUS_DISPATCH_COMPLETE)
|
||||
;
|
||||
while (dbus_connection_dispatch(dw->cd->dbus_conn) != DBUS_DISPATCH_COMPLETE) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
37
src/err.h
37
src/err.h
|
@ -1,37 +0,0 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
// Copyright (c) 2019 Yuxuan Shui <yshuiv7@gmail.com>
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "compiler.h"
|
||||
|
||||
// Functions for error reporting, adopted from Linux
|
||||
|
||||
// INFO in user space we can probably be more liberal about what pointer we consider
|
||||
// error. e.g. In x86_64 Linux, all addresses with the highest bit set is invalid in user
|
||||
// space.
|
||||
#define MAX_ERRNO 4095
|
||||
|
||||
static inline void *must_use ERR_PTR(intptr_t err) {
|
||||
return (void *)err;
|
||||
}
|
||||
|
||||
static inline intptr_t must_use PTR_ERR(void *ptr) {
|
||||
return (intptr_t)ptr;
|
||||
}
|
||||
|
||||
static inline bool must_use IS_ERR(void *ptr) {
|
||||
return unlikely((uintptr_t)ptr > (uintptr_t)-MAX_ERRNO);
|
||||
}
|
||||
|
||||
static inline bool must_use IS_ERR_OR_NULL(void *ptr) {
|
||||
return unlikely(!ptr) || IS_ERR(ptr);
|
||||
}
|
||||
|
||||
static inline intptr_t must_use PTR_ERR_OR_ZERO(void *ptr) {
|
||||
if (IS_ERR(ptr)) {
|
||||
return PTR_ERR(ptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#include "log.h"
|
||||
#include "picom.h"
|
||||
#include "region.h"
|
||||
#include "utils/dynarr.h"
|
||||
#include "wm/defs.h"
|
||||
#include "wm/wm.h"
|
||||
#include "x.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "backend/backend.h"
|
||||
#include "c2.h"
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "options.h"
|
||||
|
|
25
src/picom.c
25
src/picom.c
|
@ -57,9 +57,7 @@
|
|||
#include "renderer/command_builder.h"
|
||||
#include "renderer/layout.h"
|
||||
#include "renderer/renderer.h"
|
||||
#include "utils/dynarr.h"
|
||||
#include "utils/file_watch.h"
|
||||
#include "utils/kernel.h"
|
||||
#include "utils/list.h"
|
||||
#include "utils/misc.h"
|
||||
#include "utils/statistics.h"
|
||||
|
@ -1902,16 +1900,17 @@ static struct window_options win_options_from_config(const struct options *opts)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a session.
|
||||
*
|
||||
* @param argc number of command line arguments
|
||||
* @param argv command line arguments
|
||||
* @param dpy the X Display
|
||||
* @param config_file the path to the config file
|
||||
* @param all_xerrors whether we should report all X errors
|
||||
* @param fork whether we will fork after initialization
|
||||
*/
|
||||
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
||||
|
||||
/// Initialize a session.
|
||||
///
|
||||
/// @param argc number of command line arguments
|
||||
/// @param argv command line arguments
|
||||
/// @param dpy the X Display
|
||||
/// @param config_file the path to the config file
|
||||
/// @param all_xerrors whether we should report all X errors
|
||||
/// @param fork whether we will fork after initialization
|
||||
///
|
||||
static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||
const char *config_file, bool all_xerrors, bool fork) {
|
||||
static const session_t s_def = {
|
||||
|
@ -2403,6 +2402,8 @@ err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// NOLINTEND(readability-function-cognitive-complexity)
|
||||
|
||||
/**
|
||||
* Destroy a session.
|
||||
*
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "log.h" // XXX clean up
|
||||
#include "region.h"
|
||||
#include "wm/win.h"
|
||||
#include "x.h"
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ static inline rect_t *from_x_rects(int nrects, const xcb_rectangle_t *rects) {
|
|||
/**
|
||||
* Resize a region.
|
||||
*/
|
||||
static inline void _resize_region(const region_t *region, region_t *output, int dx, int dy) {
|
||||
static inline void
|
||||
resize_region_inner(const region_t *region, region_t *output, int dx, int dy) {
|
||||
if (!region || !output) {
|
||||
return;
|
||||
}
|
||||
|
@ -122,12 +123,12 @@ static inline void _resize_region(const region_t *region, region_t *output, int
|
|||
static inline region_t resize_region(const region_t *region, int dx, int dy) {
|
||||
region_t ret;
|
||||
pixman_region32_init(&ret);
|
||||
_resize_region(region, &ret, dx, dy);
|
||||
resize_region_inner(region, &ret, dx, dy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void resize_region_in_place(region_t *region, int dx, int dy) {
|
||||
return _resize_region(region, region, dx, dy);
|
||||
return resize_region_inner(region, region, dx, dy);
|
||||
}
|
||||
|
||||
static inline rect_t region_translate_rect(rect_t rect, ivec2 origin) {
|
||||
|
|
|
@ -85,7 +85,7 @@ struct layout_manager;
|
|||
/// layouts, with its size chosen at creation time. Calling this will push at new layout
|
||||
/// at the end of the ring buffer, and remove the oldest layout if the buffer is full.
|
||||
void layout_manager_append_layout(struct layout_manager *lm, struct wm *wm,
|
||||
uint64_t root_image_generation, ivec2 size);
|
||||
uint64_t root_pixmap_generation, ivec2 size);
|
||||
/// Get the layout `age` frames into the past. Age `0` is the most recently appended
|
||||
/// layout.
|
||||
struct layout *layout_manager_layout(struct layout_manager *lm, unsigned age);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifdef CONFIG_DBUS
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
|
|
@ -1068,7 +1068,7 @@ script_compile(config_setting_t *setting, struct script_parse_config cfg, char *
|
|||
}
|
||||
|
||||
char *script_to_c(const struct script *script, const struct script_output_info *outputs) {
|
||||
char **buf = dynarr_new(char *, script->len * 40);
|
||||
char **buf = dynarr_new(char *, (size_t)script->len * 40);
|
||||
char *tmp = NULL;
|
||||
casprintf(&tmp, "{\n"
|
||||
" static const struct instruction instrs[] = {\n");
|
||||
|
@ -1135,15 +1135,16 @@ char *script_to_c(const struct script *script, const struct script_output_info *
|
|||
}
|
||||
|
||||
void script_specialize(struct script *script,
|
||||
const struct script_specialization_context *spec, unsigned n_context) {
|
||||
const struct script_specialization_context *context,
|
||||
unsigned n_context) {
|
||||
for (unsigned i = 0; i < script->len; i++) {
|
||||
if (script->instrs[i].type != INST_LOAD_CTX) {
|
||||
continue;
|
||||
}
|
||||
for (unsigned j = 0; j < n_context; j++) {
|
||||
if (script->instrs[i].ctx == spec[j].offset) {
|
||||
if (script->instrs[i].ctx == context[j].offset) {
|
||||
script->instrs[i].type = INST_IMM;
|
||||
script->instrs[i].imm = spec[j].value;
|
||||
script->instrs[i].imm = context[j].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ unsigned script_elapsed_slot(const struct script *script);
|
|||
/// Specialize a script instance with a context. During evaluation of the resulting
|
||||
/// script, what would have been read from the context will be replaced with the hardcoded
|
||||
/// value in the specialization context.
|
||||
void script_specialize(struct script *instance,
|
||||
void script_specialize(struct script *script,
|
||||
const struct script_specialization_context *context,
|
||||
unsigned n_context);
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static inline void dynarr_remove_swap_impl(size_t size, void *arr, size_t idx) {
|
|||
}
|
||||
|
||||
/// Create a new dynamic array with capacity `cap` for type `type`.
|
||||
#define dynarr_new(type, cap) ((type *)dynarr_new_impl(sizeof(type), cap))
|
||||
#define dynarr_new(type, cap) ((type *)dynarr_new_impl(sizeof(type), (cap)))
|
||||
/// Free a dynamic array, destructing each element with `dtor`.
|
||||
#define dynarr_free(arr, dtor) \
|
||||
do { \
|
||||
|
|
|
@ -83,8 +83,8 @@ safe_isinf(double a) {
|
|||
auto __assert_in_range_tmp attr_unused = (var); \
|
||||
_Pragma("GCC diagnostic push"); \
|
||||
_Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
|
||||
assert(__assert_in_range_tmp >= lower); \
|
||||
assert(__assert_in_range_tmp <= upper); \
|
||||
assert(__assert_in_range_tmp >= (lower)); \
|
||||
assert(__assert_in_range_tmp <= (upper)); \
|
||||
_Pragma("GCC diagnostic pop"); \
|
||||
} while (0)
|
||||
|
||||
|
@ -95,7 +95,7 @@ safe_isinf(double a) {
|
|||
auto __tmp attr_unused = (var); \
|
||||
_Pragma("GCC diagnostic push"); \
|
||||
_Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
|
||||
assert(__tmp >= lower); \
|
||||
assert(__tmp >= (lower)); \
|
||||
_Pragma("GCC diagnostic pop"); \
|
||||
} while (0)
|
||||
|
||||
|
|
19
src/wm/win.c
19
src/wm/win.c
|
@ -1604,7 +1604,7 @@ void win_destroy_start(struct win *w) {
|
|||
|
||||
// Update state flags of a managed window
|
||||
w->state = WSTATE_DESTROYED;
|
||||
w->opacity = 0.0f;
|
||||
w->opacity = 0.0F;
|
||||
w->a.map_state = XCB_MAP_STATE_UNMAPPED;
|
||||
w->in_openclose = true;
|
||||
}
|
||||
|
@ -1630,7 +1630,7 @@ void unmap_win_start(struct win *w) {
|
|||
|
||||
w->a.map_state = XCB_MAP_STATE_UNMAPPED;
|
||||
w->state = WSTATE_UNMAPPED;
|
||||
w->opacity = 0.0f;
|
||||
w->opacity = 0.0F;
|
||||
}
|
||||
|
||||
struct win_script_context win_script_context_prepare(struct session *ps, struct win *w) {
|
||||
|
@ -1812,13 +1812,17 @@ bool win_process_animation_and_state_change(struct session *ps, struct win *w, d
|
|||
if (trigger == ANIMATION_TRIGGER_INVALID) {
|
||||
// No state changes, if there's a animation running, we just continue it.
|
||||
return win_advance_animation(w, delta_t, &win_ctx);
|
||||
} else if (w->running_animation_instance &&
|
||||
(w->running_animation.suppressions & (1 << trigger)) != 0) {
|
||||
}
|
||||
|
||||
if (w->running_animation_instance &&
|
||||
(w->running_animation.suppressions & (1 << trigger)) != 0) {
|
||||
log_debug("Not starting animation %s for window %#010x (%s) because it "
|
||||
"is being suppressed.",
|
||||
animation_trigger_names[trigger], win_id(w), w->name);
|
||||
return win_advance_animation(w, delta_t, &win_ctx);
|
||||
} else if (w->animation_block[trigger] > 0) {
|
||||
}
|
||||
|
||||
if (w->animation_block[trigger] > 0) {
|
||||
log_debug("Not starting animation %s for window %#010x (%s) because it "
|
||||
"is blocked.",
|
||||
animation_trigger_names[trigger], win_id(w), w->name);
|
||||
|
@ -1847,6 +1851,9 @@ bool win_process_animation_and_state_change(struct session *ps, struct win *w, d
|
|||
w->saved_win_image = NULL;
|
||||
}
|
||||
if (ps->drivers & DRIVER_NVIDIA) {
|
||||
// NVIDIA doesn't like us grabbing the new pixmap before releasing
|
||||
// the old one. So we copy the content of the old pixmap so we can
|
||||
// release it.
|
||||
if (w->win_image != NULL) {
|
||||
w->saved_win_image = ps->backend_data->ops.new_image(
|
||||
ps->backend_data, BACKEND_IMAGE_FORMAT_PIXMAP,
|
||||
|
@ -2117,7 +2124,7 @@ void win_set_properties_stale(struct win *w, const xcb_atom_t *props, int nprops
|
|||
// Reallocate if necessary
|
||||
if (new_capacity > w->stale_props_capacity) {
|
||||
w->stale_props =
|
||||
realloc(w->stale_props, new_capacity * sizeof(*w->stale_props));
|
||||
crealloc(w->stale_props, new_capacity * sizeof(*w->stale_props));
|
||||
|
||||
// Clear the content of the newly allocated bytes
|
||||
memset(w->stale_props + w->stale_props_capacity, 0,
|
||||
|
|
|
@ -237,6 +237,7 @@ struct win_script_context {
|
|||
double monitor_x, monitor_y;
|
||||
double monitor_width, monitor_height;
|
||||
};
|
||||
// NOLINTNEXTLINE(bugprone-sizeof-expression)
|
||||
static_assert(SCRIPT_CTX_PLACEHOLDER_BASE > sizeof(struct win_script_context),
|
||||
"win_script_context too large");
|
||||
|
||||
|
|
5
src/x.h
5
src/x.h
|
@ -122,6 +122,7 @@ struct x_monitors {
|
|||
};
|
||||
|
||||
#define XCB_AWAIT_VOID(func, c, ...) \
|
||||
/* NOLINTBEGIN(bugprone-assignment-in-if-condition) */ \
|
||||
({ \
|
||||
bool __success = true; \
|
||||
__auto_type __e = xcb_request_check(c, func##_checked(c, __VA_ARGS__)); \
|
||||
|
@ -132,7 +133,7 @@ struct x_monitors {
|
|||
__success = false; \
|
||||
} \
|
||||
__success; \
|
||||
})
|
||||
}) /* NOLINTEND(bugprone-assignment-in-if-condition) */
|
||||
|
||||
#define XCB_AWAIT(func, c, ...) \
|
||||
({ \
|
||||
|
@ -460,7 +461,7 @@ void x_update_monitors_async(struct x_connection *, struct x_monitors *);
|
|||
/// Free memory allocated for a `struct x_monitors`.
|
||||
void x_free_monitor_info(struct x_monitors *);
|
||||
|
||||
uint32_t attr_deprecated xcb_generate_id(xcb_connection_t *c);
|
||||
uint32_t attr_deprecated xcb_generate_id(xcb_connection_t *c); // NOLINT(readability-redundant-declaration)
|
||||
|
||||
/// Ask X server to send us a notification for the next end of vblank.
|
||||
void x_request_vblank_event(struct x_connection *c, xcb_window_t window, uint64_t msc);
|
||||
|
|
Loading…
Add table
Reference in a new issue