diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 582d4c2b..1dd96232 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -83,7 +83,7 @@ class controller : public signal_receiver m_threads; watch_t m_confwatch; diff --git a/include/components/eventloop.hpp b/include/components/eventloop.hpp index 08aa4342..d2751583 100644 --- a/include/components/eventloop.hpp +++ b/include/components/eventloop.hpp @@ -105,7 +105,7 @@ class eventloop : public signal_receiver> 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 m_drawtime; diff --git a/src/adapters/net.cpp b/src/adapters/net.cpp index ef1fce6b..087fc644 100644 --- a/src/adapters/net.cpp +++ b/src/adapters/net.cpp @@ -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) { diff --git a/src/components/eventloop.cpp b/src/components/eventloop.cpp index e460f2d0..079b7c89 100644 --- a/src/components/eventloop.cpp +++ b/src/components/eventloop.cpp @@ -59,7 +59,7 @@ void eventloop::start() { dispatch_modules(); while (m_running) { - event evt, next; + event evt{}, next{}; m_queue.wait_dequeue(evt); diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index 2f1cedd5..16f59ddc 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -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); diff --git a/src/drawtypes/label.cpp b/src/drawtypes/label.cpp index 1ba559e1..1a6cf66d 100644 --- a/src/drawtypes/label.cpp +++ b/src/drawtypes/label.cpp @@ -128,7 +128,8 @@ namespace drawtypes { string text; - struct side_values padding, margin; + struct side_values padding { + }, margin{}; if (required) { text = conf.get(section, name); diff --git a/src/main.cpp b/src/main.cpp index 1f0bcd75..f5bc0ccf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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) { diff --git a/src/modules/fs.cpp b/src/modules/fs.cpp index c4aff3cb..b94a0eed 100644 --- a/src/modules/fs.cpp +++ b/src/modules/fs.cpp @@ -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) { diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index f9e70224..263acfb2 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -122,7 +122,7 @@ namespace modules { auto names = ewmh_util::get_desktop_names(m_ewmh.get()); vector viewports; size_t num{0}; - position pos; + position pos{}; if (m_monitorsupport) { viewports = ewmh_util::get_desktop_viewports(m_ewmh.get()); diff --git a/src/utils/bspwm.cpp b/src/utils/bspwm.cpp index cc20e9a2..2ab8045c 100644 --- a/src/utils/bspwm.cpp +++ b/src/utils/bspwm.cpp @@ -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; diff --git a/src/utils/file.cpp b/src/utils/file.cpp index 3fe57684..8a7ad002 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -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(filename); int fd = fileno((*fileptr)()); - struct stat statbuf; + struct stat statbuf {}; fstat(fd, &statbuf); return S_ISFIFO(statbuf.st_mode); } diff --git a/src/utils/process.cpp b/src/utils/process.cpp index 8cc4ed29..47b0d5da 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -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) { diff --git a/src/utils/socket.cpp b/src/utils/socket.cpp index 9539ed63..05754a56 100644 --- a/src/utils/socket.cpp +++ b/src/utils/socket.cpp @@ -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) { diff --git a/src/utils/string.cpp b/src/utils/string.cpp index 2b51108e..835d6d75 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -246,7 +246,7 @@ namespace string_util { * @endcode */ string from_stream(const std::basic_ostream& os) { - return static_cast(os).str(); + return dynamic_cast(os).str(); } /** diff --git a/src/x11/color.cpp b/src/x11/color.cpp index 9f852f3a..c4fd5e0b 100644 --- a/src/x11/color.cpp +++ b/src/x11/color.cpp @@ -35,7 +35,7 @@ string color::source() const { } color::operator XRenderColor() const { - XRenderColor x; + XRenderColor x{}; x.red = color_util::red_channel(m_color); x.green = color_util::green_channel(m_color); x.blue = color_util::blue_channel(m_color); diff --git a/src/x11/draw.cpp b/src/x11/draw.cpp index 25e1a120..2864858f 100644 --- a/src/x11/draw.cpp +++ b/src/x11/draw.cpp @@ -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; diff --git a/src/x11/ewmh.cpp b/src/x11/ewmh.cpp index 8a9097c9..9abcf6d0 100644 --- a/src/x11/ewmh.cpp +++ b/src/x11/ewmh.cpp @@ -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 get_desktop_viewports(xcb_ewmh_connection_t* conn, int screen) { vector 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 get_desktop_names(xcb_ewmh_connection_t* conn, int screen) { vector 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; diff --git a/src/x11/graphics.cpp b/src/x11/graphics.cpp index 50b1752d..ab5fd08b 100644 --- a/src/x11/graphics.cpp +++ b/src/x11/graphics.cpp @@ -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]; diff --git a/src/x11/icccm.cpp b/src/x11/icccm.cpp index 4b156831..1f1b1b99 100644 --- a/src/x11/icccm.cpp +++ b/src/x11/icccm.cpp @@ -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); } diff --git a/src/x11/tray_client.cpp b/src/x11/tray_client.cpp index 2f467b0a..026759d3 100644 --- a/src/x11/tray_client.cpp +++ b/src/x11/tray_client.cpp @@ -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); diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp index 540c1791..e2a568b6 100644 --- a/src/x11/tray_manager.cpp +++ b/src/x11/tray_manager.cpp @@ -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); diff --git a/src/x11/window.cpp b/src/x11/window.cpp index a62b5556..79ca9ced 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -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); diff --git a/src/x11/xkb.cpp b/src/x11/xkb.cpp index 83029946..ada69e49 100644 --- a/src/x11/xkb.cpp +++ b/src/x11/xkb.cpp @@ -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); diff --git a/src/x11/xlib.cpp b/src/x11/xlib.cpp index 2884ff45..046d40cc 100644 --- a/src/x11/xlib.cpp +++ b/src/x11/xlib.cpp @@ -17,7 +17,7 @@ namespace xlib { shared_ptr 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(info.visual, [=](Visual* v) { XFree(v); }); } diff --git a/src/x11/xresources.cpp b/src/x11/xresources.cpp index 0660e2e1..d6d96c98 100644 --- a/src/x11/xresources.cpp +++ b/src/x11/xresources.cpp @@ -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)) {