refactor: Initialize data
This commit is contained in:
parent
f9062d031c
commit
a0d485f79d
@ -83,7 +83,7 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, sig_ev::proc
|
||||
stateflag m_reload{false};
|
||||
stateflag m_waiting{false};
|
||||
|
||||
sigset_t m_waitmask;
|
||||
sigset_t m_waitmask{};
|
||||
vector<thread> m_threads;
|
||||
|
||||
watch_t m_confwatch;
|
||||
|
@ -105,7 +105,7 @@ class eventloop : public signal_receiver<SIGN_PRIORITY_EVENTLOOP, process_quit,
|
||||
/**
|
||||
* @brief Flag to indicate current run state
|
||||
*/
|
||||
stateflag m_running;
|
||||
stateflag m_running{};
|
||||
|
||||
/**
|
||||
* @brief Time to wait for subsequent events
|
||||
@ -130,7 +130,7 @@ class eventloop : public signal_receiver<SIGN_PRIORITY_EVENTLOOP, process_quit,
|
||||
/**
|
||||
* @brief Mutex used to guard input data
|
||||
*/
|
||||
std::mutex m_inputlock;
|
||||
std::mutex m_inputlock{};
|
||||
|
||||
/**
|
||||
* @brief Input data
|
||||
|
@ -48,7 +48,7 @@ namespace modules {
|
||||
|
||||
connection& m_connection;
|
||||
monitor_t m_output;
|
||||
xcb_window_t m_proxy;
|
||||
xcb_window_t m_proxy{};
|
||||
|
||||
ramp_t m_ramp;
|
||||
label_t m_label;
|
||||
|
@ -66,11 +66,11 @@ namespace command_util {
|
||||
|
||||
string m_cmd;
|
||||
|
||||
int m_stdout[2];
|
||||
int m_stdin[2];
|
||||
int m_stdout[2]{};
|
||||
int m_stdin[2]{};
|
||||
|
||||
pid_t m_forkpid;
|
||||
int m_forkstatus;
|
||||
pid_t m_forkpid{};
|
||||
int m_forkstatus{};
|
||||
|
||||
concurrency_util::spin_lock m_pipelock;
|
||||
};
|
||||
|
@ -135,11 +135,11 @@ class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify
|
||||
const logger& m_log;
|
||||
vector<shared_ptr<tray_client>> m_clients;
|
||||
|
||||
tray_settings m_opts;
|
||||
tray_settings m_opts{};
|
||||
|
||||
xcb_gcontext_t m_gc{0};
|
||||
xcb_pixmap_t m_pixmap{0};
|
||||
graphics_util::root_pixmap m_rootpixmap;
|
||||
graphics_util::root_pixmap m_rootpixmap{};
|
||||
uint16_t m_prevwidth{0};
|
||||
uint16_t m_prevheight{0};
|
||||
|
||||
@ -156,7 +156,7 @@ class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify
|
||||
|
||||
bool m_restacked{false};
|
||||
|
||||
std::mutex m_mtx;
|
||||
std::mutex m_mtx{};
|
||||
|
||||
chrono::time_point<chrono::system_clock, chrono::milliseconds> m_drawtime;
|
||||
|
||||
|
@ -154,8 +154,8 @@ namespace net {
|
||||
* interface is a TUN/TAP device
|
||||
*/
|
||||
void network::check_tuntap() {
|
||||
struct ethtool_drvinfo driver;
|
||||
struct ifreq request;
|
||||
struct ethtool_drvinfo driver {};
|
||||
struct ifreq request {};
|
||||
|
||||
driver.cmd = ETHTOOL_GDRVINFO;
|
||||
|
||||
@ -219,8 +219,8 @@ namespace net {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ifreq request;
|
||||
struct ethtool_cmd data;
|
||||
struct ifreq request {};
|
||||
struct ethtool_cmd data {};
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
strncpy(request.ifr_name, m_interface.c_str(), IFNAMSIZ - 1);
|
||||
@ -244,8 +244,8 @@ namespace net {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ethtool_value data;
|
||||
struct ifreq request;
|
||||
struct ethtool_value data {};
|
||||
struct ifreq request {};
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
strncpy(request.ifr_name, m_interface.c_str(), IFNAMSIZ - 1);
|
||||
@ -285,7 +285,7 @@ namespace net {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct iwreq req;
|
||||
struct iwreq req {};
|
||||
|
||||
if (iw_get_ext(socket_fd, m_interface.c_str(), SIOCGIWMODE, &req) == -1) {
|
||||
return false;
|
||||
@ -341,7 +341,7 @@ namespace net {
|
||||
void wireless_network::query_essid(const int& socket_fd) {
|
||||
char essid[IW_ESSID_MAX_SIZE + 1];
|
||||
|
||||
struct iwreq req;
|
||||
struct iwreq req {};
|
||||
req.u.essid.pointer = &essid;
|
||||
req.u.essid.length = sizeof(essid);
|
||||
req.u.essid.flags = 0;
|
||||
@ -357,8 +357,8 @@ namespace net {
|
||||
* Query for device driver quality values
|
||||
*/
|
||||
void wireless_network::query_quality(const int& socket_fd) {
|
||||
iwrange range;
|
||||
iwstats stats;
|
||||
iwrange range{};
|
||||
iwstats stats{};
|
||||
|
||||
// Fill range
|
||||
if (iw_get_range_info(socket_fd, m_interface.c_str(), &range) == -1) {
|
||||
|
@ -59,7 +59,7 @@ void eventloop::start() {
|
||||
dispatch_modules();
|
||||
|
||||
while (m_running) {
|
||||
event evt, next;
|
||||
event evt{}, next{};
|
||||
|
||||
m_queue.wait_dequeue(evt);
|
||||
|
||||
|
@ -94,7 +94,7 @@ renderer::renderer(connection& conn, signal_emitter& emitter, const logger& logg
|
||||
uint32_t mask{0};
|
||||
uint32_t value_list[32]{0};
|
||||
|
||||
xcb_params_gc_t params;
|
||||
xcb_params_gc_t params{};
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, foreground, colors[i]);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, graphics_exposures, 0);
|
||||
xutils::pack_values(mask, ¶ms, value_list);
|
||||
|
@ -128,7 +128,8 @@ namespace drawtypes {
|
||||
|
||||
string text;
|
||||
|
||||
struct side_values padding, margin;
|
||||
struct side_values padding {
|
||||
}, margin{};
|
||||
|
||||
if (required) {
|
||||
text = conf.get<string>(section, name);
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char** argv) {
|
||||
//==================================================
|
||||
// Block all signals by default
|
||||
//==================================================
|
||||
sigset_t blockmask;
|
||||
sigset_t blockmask{};
|
||||
sigfillset(&blockmask);
|
||||
|
||||
if (pthread_sigmask(SIG_BLOCK, &blockmask, nullptr) == -1) {
|
||||
|
@ -57,7 +57,7 @@ namespace modules {
|
||||
bool fs_module::update() {
|
||||
m_mounts.clear();
|
||||
|
||||
struct statvfs buffer;
|
||||
struct statvfs buffer {};
|
||||
struct mntent* mnt = nullptr;
|
||||
|
||||
for (auto&& mountpoint : m_mountpoints) {
|
||||
|
@ -122,7 +122,7 @@ namespace modules {
|
||||
auto names = ewmh_util::get_desktop_names(m_ewmh.get());
|
||||
vector<position> viewports;
|
||||
size_t num{0};
|
||||
position pos;
|
||||
position pos{};
|
||||
|
||||
if (m_monitorsupport) {
|
||||
viewports = ewmh_util::get_desktop_viewports(m_ewmh.get());
|
||||
|
@ -16,7 +16,7 @@ namespace bspwm_util {
|
||||
auto children = conn.query_tree(conn.screen()->root).children();
|
||||
|
||||
for (auto it = children.begin(); it != children.end(); it++) {
|
||||
xcb_icccm_get_wm_class_reply_t reply;
|
||||
xcb_icccm_get_wm_class_reply_t reply{};
|
||||
reply.class_name = reply.instance_name = nullptr;
|
||||
|
||||
if (xcb_icccm_get_wm_class_reply(conn, xcb_icccm_get_wm_class(conn, *it), &reply, nullptr)) {
|
||||
@ -76,7 +76,7 @@ namespace bspwm_util {
|
||||
return env_path;
|
||||
}
|
||||
|
||||
struct sockaddr_un sa;
|
||||
struct sockaddr_un sa {};
|
||||
char* host = nullptr;
|
||||
int dsp = 0;
|
||||
int scr = 0;
|
||||
|
@ -38,7 +38,7 @@ namespace file_util {
|
||||
* Checks if the given file exist
|
||||
*/
|
||||
bool exists(const string& filename) {
|
||||
struct stat buffer;
|
||||
struct stat buffer {};
|
||||
return stat(filename.c_str(), &buffer) == 0;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ namespace file_util {
|
||||
bool is_fifo(string filename) {
|
||||
auto fileptr = factory_util::unique<file_ptr>(filename);
|
||||
int fd = fileno((*fileptr)());
|
||||
struct stat statbuf;
|
||||
struct stat statbuf {};
|
||||
fstat(fd, &statbuf);
|
||||
return S_ISFIFO(statbuf.st_mode);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ namespace process_util {
|
||||
}
|
||||
|
||||
void unblock_signal(int sig) {
|
||||
sigset_t sigmask;
|
||||
sigset_t sigmask{};
|
||||
sigemptyset(&sigmask);
|
||||
sigaddset(&sigmask, sig);
|
||||
if (pthread_sigmask(SIG_UNBLOCK, &sigmask, nullptr) == -1) {
|
||||
|
@ -18,7 +18,7 @@ namespace socket_util {
|
||||
* Constructor: establishing socket connection
|
||||
*/
|
||||
unix_connection::unix_connection(string&& path) : m_socketpath(path) {
|
||||
struct sockaddr_un socket_addr;
|
||||
struct sockaddr_un socket_addr {};
|
||||
socket_addr.sun_family = AF_UNIX;
|
||||
|
||||
if ((m_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
||||
|
@ -246,7 +246,7 @@ namespace string_util {
|
||||
* @endcode
|
||||
*/
|
||||
string from_stream(const std::basic_ostream<char>& os) {
|
||||
return static_cast<const stringstream&>(os).str();
|
||||
return dynamic_cast<const stringstream&>(os).str();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ string color::source() const {
|
||||
}
|
||||
|
||||
color::operator XRenderColor() const {
|
||||
XRenderColor x;
|
||||
XRenderColor x{};
|
||||
x.red = color_util::red_channel<uint16_t>(m_color);
|
||||
x.green = color_util::green_channel<uint16_t>(m_color);
|
||||
x.blue = color_util::blue_channel<uint16_t>(m_color);
|
||||
|
@ -37,8 +37,8 @@ namespace draw_util {
|
||||
};
|
||||
struct iovec xcb_parts[7];
|
||||
uint8_t xcb_lendelta[2];
|
||||
xcb_void_cookie_t xcb_ret;
|
||||
xcb_poly_text_8_request_t xcb_out;
|
||||
xcb_void_cookie_t xcb_ret{};
|
||||
xcb_poly_text_8_request_t xcb_out{};
|
||||
xcb_out.pad0 = 0;
|
||||
xcb_out.drawable = d;
|
||||
xcb_out.gc = gc;
|
||||
|
@ -22,7 +22,7 @@ namespace ewmh_util {
|
||||
bool supports(xcb_ewmh_connection_t* ewmh, xcb_atom_t atom, int screen) {
|
||||
bool supports{false};
|
||||
|
||||
xcb_ewmh_get_atoms_reply_t reply;
|
||||
xcb_ewmh_get_atoms_reply_t reply{};
|
||||
reply.atoms = nullptr;
|
||||
|
||||
if (!xcb_ewmh_get_supported_reply(ewmh, xcb_ewmh_get_supported(ewmh, screen), &reply, nullptr)) {
|
||||
@ -44,7 +44,7 @@ namespace ewmh_util {
|
||||
}
|
||||
|
||||
string get_wm_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply{};
|
||||
if (xcb_ewmh_get_wm_name_reply(conn, xcb_ewmh_get_wm_name(conn, win), &utf8_reply, nullptr)) {
|
||||
return get_reply_string(&utf8_reply);
|
||||
}
|
||||
@ -52,7 +52,7 @@ namespace ewmh_util {
|
||||
}
|
||||
|
||||
string get_visible_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply{};
|
||||
if (xcb_ewmh_get_wm_visible_name_reply(conn, xcb_ewmh_get_wm_visible_name(conn, win), &utf8_reply, nullptr)) {
|
||||
return get_reply_string(&utf8_reply);
|
||||
}
|
||||
@ -60,7 +60,7 @@ namespace ewmh_util {
|
||||
}
|
||||
|
||||
string get_icon_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply{};
|
||||
if (xcb_ewmh_get_wm_icon_name_reply(conn, xcb_ewmh_get_wm_icon_name(conn, win), &utf8_reply, nullptr)) {
|
||||
return get_reply_string(&utf8_reply);
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace ewmh_util {
|
||||
|
||||
vector<position> get_desktop_viewports(xcb_ewmh_connection_t* conn, int screen) {
|
||||
vector<position> viewports;
|
||||
xcb_ewmh_get_desktop_viewport_reply_t reply;
|
||||
xcb_ewmh_get_desktop_viewport_reply_t reply{};
|
||||
|
||||
if (!xcb_ewmh_get_desktop_viewport_reply(conn, xcb_ewmh_get_desktop_viewport(conn, screen), &reply, nullptr)) {
|
||||
return viewports;
|
||||
@ -102,7 +102,7 @@ namespace ewmh_util {
|
||||
|
||||
vector<string> get_desktop_names(xcb_ewmh_connection_t* conn, int screen) {
|
||||
vector<string> names;
|
||||
xcb_ewmh_get_utf8_strings_reply_t reply;
|
||||
xcb_ewmh_get_utf8_strings_reply_t reply{};
|
||||
|
||||
if (!xcb_ewmh_get_desktop_names_reply(conn, xcb_ewmh_get_desktop_names(conn, screen), &reply, nullptr)) {
|
||||
return names;
|
||||
|
@ -60,7 +60,7 @@ namespace graphics_util {
|
||||
*/
|
||||
bool create_gc(connection& conn, xcb_drawable_t drawable, xcb_gcontext_t* gc) {
|
||||
try {
|
||||
xcb_params_gc_t params;
|
||||
xcb_params_gc_t params{};
|
||||
|
||||
uint32_t mask = 0;
|
||||
uint32_t values[32];
|
||||
|
@ -4,7 +4,7 @@ POLYBAR_NS
|
||||
|
||||
namespace icccm_util {
|
||||
string get_wm_name(xcb_connection_t* conn, xcb_window_t win) {
|
||||
xcb_icccm_get_text_property_reply_t reply;
|
||||
xcb_icccm_get_text_property_reply_t reply{};
|
||||
if (xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, win), &reply, nullptr)) {
|
||||
return get_reply_string(&reply);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void tray_client::ensure_state() const {
|
||||
void tray_client::reconfigure(int16_t x, int16_t y) const {
|
||||
uint32_t configure_mask = 0;
|
||||
uint32_t configure_values[7];
|
||||
xcb_params_configure_window_t configure_params;
|
||||
xcb_params_configure_window_t configure_params{};
|
||||
|
||||
XCB_AUX_ADD_PARAM(&configure_mask, &configure_params, width, m_width);
|
||||
XCB_AUX_ADD_PARAM(&configure_mask, &configure_params, height, m_height);
|
||||
|
@ -360,7 +360,7 @@ void tray_manager::reconfigure_window() {
|
||||
|
||||
uint32_t mask = 0;
|
||||
uint32_t values[7];
|
||||
xcb_params_configure_window_t params;
|
||||
xcb_params_configure_window_t params{};
|
||||
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, width, width);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, x, x);
|
||||
@ -610,7 +610,7 @@ void tray_manager::restack_window() {
|
||||
|
||||
uint32_t mask = 0;
|
||||
uint32_t values[7];
|
||||
xcb_params_configure_window_t params;
|
||||
xcb_params_configure_window_t params{};
|
||||
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, sibling, m_opts.sibling);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, stack_mode, XCB_STACK_MODE_ABOVE);
|
||||
|
@ -50,7 +50,7 @@ window window::reconfigure_geom(uint16_t w, uint16_t h, int16_t x, int16_t y) {
|
||||
uint32_t mask{0};
|
||||
uint32_t values[7]{0};
|
||||
|
||||
xcb_params_configure_window_t params;
|
||||
xcb_params_configure_window_t params{};
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, width, w);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, height, h);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, x, x);
|
||||
@ -69,7 +69,7 @@ window window::reconfigure_pos(int16_t x, int16_t y) {
|
||||
uint32_t mask{0};
|
||||
uint32_t values[2]{0};
|
||||
|
||||
xcb_params_configure_window_t params;
|
||||
xcb_params_configure_window_t params{};
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, x, x);
|
||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, y, y);
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace xkb_util {
|
||||
return results;
|
||||
}
|
||||
|
||||
xcb_xkb_get_names_value_list_t values;
|
||||
xcb_xkb_get_names_value_list_t values{};
|
||||
void* buffer = xcb_xkb_get_names_value_list(reply);
|
||||
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators, reply->virtualMods, reply->groupNames,
|
||||
reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which, &values);
|
||||
@ -140,7 +140,7 @@ namespace xkb_util {
|
||||
return results;
|
||||
}
|
||||
|
||||
xcb_xkb_get_names_value_list_t values;
|
||||
xcb_xkb_get_names_value_list_t values{};
|
||||
void* buffer = xcb_xkb_get_names_value_list(reply);
|
||||
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators, reply->virtualMods, reply->groupNames,
|
||||
reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which, &values);
|
||||
|
@ -17,7 +17,7 @@ namespace xlib {
|
||||
|
||||
shared_ptr<Visual> get_visual(int screen) {
|
||||
if (!g_visual_ptr) {
|
||||
XVisualInfo info;
|
||||
XVisualInfo info{};
|
||||
if (XMatchVisualInfo(get_display().get(), screen, 32, TrueColor, &info)) {
|
||||
g_visual_ptr = shared_ptr<Visual>(info.visual, [=](Visual* v) { XFree(v); });
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ string xresource_manager::load_value(const string& key, const string& res_type,
|
||||
return "";
|
||||
}
|
||||
char* type = nullptr;
|
||||
XrmValue ret;
|
||||
XrmValue ret{};
|
||||
XrmGetResource(m_db, key.c_str(), res_type.c_str(), &type, &ret);
|
||||
|
||||
if (ret.addr != nullptr && !std::strncmp(res_type.c_str(), type, n)) {
|
||||
|
Loading…
Reference in New Issue
Block a user