fix various warnings

This commit is contained in:
Akos Horvath 2023-07-02 22:53:45 +02:00
parent 57ad7142bb
commit bee34c02c0
2 changed files with 24 additions and 21 deletions

43
wm.c
View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/Xutil.h>
#include <X11/extensions/Xinerama.h>
#include <asm-generic/errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -65,13 +66,13 @@ void wm_monitors_open_all(Wm *wm, Display *d)
wm->monitors[i].workspaces = calloc(wm->monitors[i].wscount, sizeof(Workspace));
wm->monitors[i].selws = 0;
for (int j = 0; j < wm->monitors[i].wscount; j++) {
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
Workspace *ws = &wm->monitors[i].workspaces[i];
ws->index = j;
ws->monitor = &wm->monitors[i];
// TODO config
snprintf(ws->name, WM_WS_NAME_LEN, "%d", j);
snprintf(ws->name, WM_WS_NAME_LEN, "%ld", j);
ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
}
@ -122,7 +123,7 @@ bool wm_window_is_dock(Wm *wm, Window w)
DEBUG_PRINT("actual number of items return: %ld\n", nitems_ret)
DEBUG_PRINT("bytes remaining: %ld\n", nitems_ret)
//DEBUG_PRINT("property return dec: %d\n", prop_ret)
for (int i = 0; i < nitems_ret; i++) {
for (size_t i = 0; i < nitems_ret; i++) {
printf("property return str: %s\n",
XGetAtomName(wm->display, ((Atom*)prop_ret)[i]));
if (strcmp(XGetAtomName(wm->display, ((Atom*)prop_ret)[i]),
@ -145,6 +146,10 @@ NodeType wm_split_to_nodetype(SplitMode mode)
return NODE_HORIZONTAL;
case SPLIT_TAB:
return NODE_TAB;
default:
fprintf(stderr, "wm: unhandled split mode %d in %s, exiting.\n",
mode, __func__);
abort();
}
}
@ -153,7 +158,7 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
DEBUG_PRINT("%s\n", __func__);
int dock_y = 0;
if (wm->dock != -1) {
if (wm->dock != ULONG_MAX) {
XWindowAttributes x;
XGetWindowAttributes(wm->display, wm->dock, &x);
@ -188,13 +193,12 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
wm_nodearray_push(&focused_node->children, child2);
}
void wm_switch_ws(Wm *wm, int ws)
void wm_switch_ws(Wm *wm, size_t ws)
{
if (ws > wm->smon->wscount || ws < 0)
if (ws > wm->smon->wscount)
return;
int wscc = 0;
int xasws;
Client *c;
PtrArray clients = wm_treenode_find_client_nodes_ptr(&wm->smon->workspaces[ws].tree);
@ -240,7 +244,6 @@ void wm_mstack(Wm *wm, Monitor *m)
int n = 0;
int sx = 0;
int sy = 0;
XTextProperty xt;
XEvent e;
unsigned int value_mask = CWX | CWY | CWWidth | CWHeight;
@ -249,7 +252,7 @@ void wm_mstack(Wm *wm, Monitor *m)
// FIXME: &root probably wrong
if (wm->dock != -1) {
if (wm->dock != ULONG_MAX) {
XWindowAttributes x;
XGetWindowAttributes(wm->display, wm->dock, &x);
@ -283,9 +286,9 @@ void wm_mstack(Wm *wm, Monitor *m)
c->w = wm->smon->info.width-wm->cfg_border_width*2;
c->h = (wm->smon->info.height-wm->cfg_border_width*2)-sy;
ch = wm_client_to_xwchanges(c);
DEBUG_PRINT("mstack client: 0x%x\n", c);
DEBUG_PRINT("mstack client: %p\n", c);
// XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack window id: %d\n", c->window);
DEBUG_PRINT("mstack window id: %ld\n", c->window);
// DEBUG_PRINT("mstack wm_name: %s\n", xt.value)
// DEBUG_PRINT("mstack client width: %d\n", ch.width)
// DEBUG_PRINT("mstack client height: %d\n", ch.height)
@ -317,8 +320,8 @@ void wm_mstack(Wm *wm, Monitor *m)
// FIXME vv RUNTIME MALLOC ABORT vv
//XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack client: 0x%x\n", c);
DEBUG_PRINT("mstack window id: %d\n", c->window);
DEBUG_PRINT("mstack client: %p\n", c);
DEBUG_PRINT("mstack window id: %ld\n", c->window);
// DEBUG_PRINT("mstack wm_name: %s\n", xt.value)
// DEBUG_PRINT("mstack client x: %d ", ch.x)
// DEBUG_PRINT("y: %d\n", ch.y)
@ -328,7 +331,7 @@ void wm_mstack(Wm *wm, Monitor *m)
XConfigureWindow(wm->display, c->window, value_mask, &ch);
wm_client_show(wm, c);
DEBUG_PRINT("%s %d. client next: 0x%x\n", __func__, n, c->next)
DEBUG_PRINT("%s %d. client next: %p\n", __func__, n, c->next)
if (c->next == NULL)
{
@ -413,9 +416,9 @@ void wm_mainloop(Wm *wm)
struct sockaddr s;
socklen_t t = 108;
getsockname(wm->socket_fd, &s, &t);
int accepted_socket;
char *buffer;
int len;
// int accepted_socket;
// char *buffer;
// accepted_socket = accept(wm->socket_fd, &s, &t);
@ -565,7 +568,7 @@ void wm_init(Wm *wm)
//XSetErrorHandler(&wm_xerror_handler);
wm->dock = -1;
wm->dock = ULONG_MAX;
wm->running = true;
wm_mainloop(wm);
@ -610,7 +613,7 @@ void wm_grab_keys(Wm *wm)
// from dwm
{
unsigned int i, j;
int i, j;
XModifierKeymap *modmap;
unsigned int numlockmask = 0;
@ -835,7 +838,7 @@ void wm_settings_message_parse(Wm *wm, char *c, int len)
return;
int op; /* 0 = set, 1 = get */
int i = 0;
size_t i = 0;
char ret[50];
char *token;
char tokens[20][50];

2
wm.h
View File

@ -154,7 +154,7 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client);
void wm_spawn(Wm* wm, char **str);
void wm_switch_ws(Wm* wm, int ws);
void wm_switch_ws(Wm* wm, size_t ws);
void wm_mainloop(Wm* wm);
void wm_init(Wm *wm);
void wm_exit(Wm *wm);