Fix clang -Wextra except -Wunused-parameter.
Patch status: superseded
Patch by Peter Boström
Long description:
Cleared all warnings that occur when passing
CFLAGS="-Wall -Wextra -Wno-unused-parameter" to make using clang 3.3 on
Linux x86-64.
To apply this patch, use:
curl http://cr.i3wm.org/patch/353/raw.patch | git am
b/i3-config-wizard/main.c
38 |
@@ -299,7 +299,7 @@ static char *rewrite_binding(const char *input) {
|
39 |
|
40 |
/* The "<=" operator is intentional: We also handle the terminating 0-byte
|
41 |
* explicitly by looking for an 'end' token. */
|
42 |
- while ((walk - input) <= len) {
|
43 |
+ while ((size_t)(walk - input) <= len) {
|
44 |
/* Skip whitespace before every token, newlines are relevant since they
|
45 |
* separate configuration directives. */
|
46 |
while ((*walk == ' ' || *walk == '\t') && *walk != '\0')
|
b/i3-msg/main.c
51 |
@@ -135,7 +135,7 @@ yajl_callbacks reply_callbacks = {
|
52 |
int main(int argc, char *argv[]) {
|
53 |
socket_path = getenv("I3SOCK");
|
54 |
int o, option_index = 0;
|
55 |
- int message_type = I3_IPC_MESSAGE_TYPE_COMMAND;
|
56 |
+ uint32_t message_type = I3_IPC_MESSAGE_TYPE_COMMAND;
|
57 |
char *payload = NULL;
|
58 |
bool quiet = false;
|
59 |
|
b/i3-nagbar/main.c
64 |
@@ -467,7 +467,7 @@ int main(int argc, char *argv[]) {
|
65 |
uint32_t top_end_x;
|
66 |
uint32_t bottom_start_x;
|
67 |
uint32_t bottom_end_x;
|
68 |
- } __attribute__((__packed__)) strut_partial = {0,};
|
69 |
+ } __attribute__((__packed__)) strut_partial = {};
|
70 |
|
71 |
strut_partial.top = font.height + 6;
|
72 |
strut_partial.top_start_x = 0;
|
b/i3bar/src/child.c
77 |
@@ -28,7 +28,7 @@
|
78 |
#include "common.h"
|
79 |
|
80 |
/* Global variables for child_*() */
|
81 |
-i3bar_child child = { 0 };
|
82 |
+i3bar_child child = {};
|
83 |
|
84 |
/* stdin- and sigchild-watchers */
|
85 |
ev_io *stdin_io;
|
b/i3bar/src/xcb.c
90 |
@@ -417,7 +417,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
91 |
const size_t len = namelen + strlen("workspace \"\"") + 1;
|
92 |
char *buffer = scalloc(len+num_quotes);
|
93 |
strncpy(buffer, "workspace \"", strlen("workspace \""));
|
94 |
- int inpos, outpos;
|
95 |
+ size_t inpos, outpos;
|
96 |
for (inpos = 0, outpos = strlen("workspace \"");
|
97 |
inpos < namelen;
|
98 |
inpos++, outpos++) {
|
99 |
@@ -1523,7 +1523,7 @@ void reconfig_windows(bool redraw_bars) {
|
100 |
uint32_t top_end_x;
|
101 |
uint32_t bottom_start_x;
|
102 |
uint32_t bottom_end_x;
|
103 |
- } __attribute__((__packed__)) strut_partial = {0,};
|
104 |
+ } __attribute__((__packed__)) strut_partial = {};
|
105 |
switch (config.position) {
|
106 |
case POS_NONE:
|
107 |
break;
|
108 |
@@ -1716,7 +1716,7 @@ void draw_bars(bool unhide) {
|
109 |
outputs_walk->bargc,
|
110 |
MAX(0, (int16_t)(statusline_width - outputs_walk->rect.w + 4)), 0,
|
111 |
MAX(0, (int16_t)(outputs_walk->rect.w - statusline_width - traypx - 4)), 3,
|
112 |
- MIN(outputs_walk->rect.w - traypx - 4, statusline_width), font.height + 2);
|
113 |
+ MIN(outputs_walk->rect.w - traypx - 4, (int)statusline_width), font.height + 2);
|
114 |
}
|
115 |
|
116 |
if (!config.disable_ws) {
|
b/include/randr.h
121 |
@@ -85,7 +85,7 @@ Output *get_output_by_name(const char *name);
|
122 |
* if there is no output which contains these coordinates.
|
123 |
*
|
124 |
*/
|
125 |
-Output *get_output_containing(int x, int y);
|
126 |
+Output *get_output_containing(unsigned int x, unsigned int y);
|
127 |
|
128 |
/*
|
129 |
* In contained_by_output, we check if any active output contains part of the container.
|
b/libi3/get_exe_path.c
134 |
@@ -30,7 +30,7 @@ char *get_exe_path(const char *argv0) {
|
135 |
#endif
|
136 |
ssize_t linksize;
|
137 |
|
138 |
- while ((linksize = readlink(exepath, destpath, destpath_size)) == destpath_size) {
|
139 |
+ while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t) destpath_size) {
|
140 |
destpath_size = destpath_size * 2;
|
141 |
destpath = srealloc(destpath, destpath_size);
|
142 |
}
|
b/libi3/ipc_send_message.c
147 |
@@ -33,7 +33,7 @@ int ipc_send_message(int sockfd, const uint32_t message_size,
|
148 |
.type = message_type
|
149 |
};
|
150 |
|
151 |
- int sent_bytes = 0;
|
152 |
+ size_t sent_bytes = 0;
|
153 |
int n = 0;
|
154 |
|
155 |
/* This first loop is basically unnecessary. No operating system has
|
b/src/assignments.c
160 |
@@ -28,7 +28,7 @@ void run_assignments(i3Window *window) {
|
161 |
continue;
|
162 |
|
163 |
bool skip = false;
|
164 |
- for (int c = 0; c < window->nr_assignments; c++) {
|
165 |
+ for (size_t c = 0; c < window->nr_assignments; c++) {
|
166 |
if (window->ran_assignments[c] != current)
|
167 |
continue;
|
168 |
|
b/src/click.c
173 |
@@ -152,15 +152,15 @@ static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click
|
174 |
return tiling_resize_for_border(con, BORDER_TOP, event);
|
175 |
}
|
176 |
|
177 |
- if (event->event_x >= 0 && event->event_x <= bsr.x &&
|
178 |
- event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height)
|
179 |
+ if (event->event_x >= 0 && event->event_x <= (int32_t)bsr.x &&
|
180 |
+ event->event_y >= (int32_t)bsr.y && event->event_y <= (int32_t)(con->rect.height + bsr.height))
|
181 |
return tiling_resize_for_border(con, BORDER_LEFT, event);
|
182 |
|
183 |
- if (event->event_x >= (con->window_rect.x + con->window_rect.width) &&
|
184 |
- event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height)
|
185 |
+ if (event->event_x >= (int32_t)(con->window_rect.x + con->window_rect.width) &&
|
186 |
+ event->event_y >= (int32_t)bsr.y && event->event_y <= (int32_t)(con->rect.height + bsr.height))
|
187 |
return tiling_resize_for_border(con, BORDER_RIGHT, event);
|
188 |
|
189 |
- if (event->event_y >= (con->window_rect.y + con->window_rect.height))
|
190 |
+ if (event->event_y >= (int32_t)(con->window_rect.y + con->window_rect.height))
|
191 |
return tiling_resize_for_border(con, BORDER_BOTTOM, event);
|
192 |
|
193 |
return false;
|
b/src/commands_parser.c
198 |
@@ -232,7 +232,7 @@ struct CommandResult *parse_command(const char *input) {
|
199 |
|
200 |
/* The "<=" operator is intentional: We also handle the terminating 0-byte
|
201 |
* explicitly by looking for an 'end' token. */
|
202 |
- while ((walk - input) <= len) {
|
203 |
+ while ((size_t)(walk - input) <= len) {
|
204 |
/* skip whitespace and newlines before every token */
|
205 |
while ((*walk == ' ' || *walk == '\t' ||
|
206 |
*walk == '\r' || *walk == '\n') && *walk != '\0')
|
b/src/config.c
211 |
@@ -175,7 +175,7 @@ void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch) {
|
212 |
}
|
213 |
|
214 |
xcb_keycode_t *walk = bind->translated_to;
|
215 |
- for (int i = 0; i < bind->number_keycodes; i++)
|
216 |
+ for (size_t i = 0; i < bind->number_keycodes; i++)
|
217 |
grab_keycode_for_binding(conn, bind, *walk++);
|
218 |
}
|
219 |
}
|
b/src/config_parser.c
224 |
@@ -159,7 +159,7 @@ static const char *get_string(const char *identifier) {
|
225 |
return NULL;
|
226 |
}
|
227 |
|
228 |
-static const long get_long(const char *identifier) {
|
229 |
+static long get_long(const char *identifier) {
|
230 |
for (int c = 0; c < 10; c++) {
|
231 |
if (stack[c].identifier == NULL)
|
232 |
break;
|
233 |
@@ -346,7 +346,7 @@ struct ConfigResult *parse_config(const char *input, struct context *context) {
|
234 |
|
235 |
/* The "<=" operator is intentional: We also handle the terminating 0-byte
|
236 |
* explicitly by looking for an 'end' token. */
|
237 |
- while ((walk - input) <= len) {
|
238 |
+ while ((size_t)(walk - input) <= len) {
|
239 |
/* Skip whitespace before every token, newlines are relevant since they
|
240 |
* separate configuration directives. */
|
241 |
while ((*walk == ' ' || *walk == '\t') && *walk != '\0')
|
242 |
@@ -585,7 +585,7 @@ struct ConfigResult *parse_config(const char *input, struct context *context) {
|
243 |
y(map_close);
|
244 |
|
245 |
/* Skip the rest of this line, but continue parsing. */
|
246 |
- while ((walk - input) <= len && *walk != '\n')
|
247 |
+ while ((size_t)(walk - input) <= len && *walk != '\n')
|
248 |
walk++;
|
249 |
|
250 |
free(position);
|
b/src/display_version.c
255 |
@@ -135,7 +135,7 @@ void display_running_version(void) {
|
256 |
|
257 |
sasprintf(&exepath, "/proc/%d/exe", getpid());
|
258 |
|
259 |
- while ((linksize = readlink(exepath, destpath, destpath_size)) == destpath_size) {
|
260 |
+ while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t)destpath_size) {
|
261 |
destpath_size = destpath_size * 2;
|
262 |
destpath = srealloc(destpath, destpath_size);
|
263 |
}
|
264 |
@@ -151,7 +151,7 @@ void display_running_version(void) {
|
265 |
free(exepath);
|
266 |
sasprintf(&exepath, "/proc/%s/exe", pid_from_atom);
|
267 |
|
268 |
- while ((linksize = readlink(exepath, destpath, destpath_size)) == destpath_size) {
|
269 |
+ while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t)destpath_size) {
|
270 |
destpath_size = destpath_size * 2;
|
271 |
destpath = srealloc(destpath, destpath_size);
|
272 |
}
|
b/src/fake_outputs.c
277 |
@@ -18,7 +18,7 @@ static int num_screens;
|
278 |
* Looks in outputs for the Output whose start coordinates are x, y
|
279 |
*
|
280 |
*/
|
281 |
-static Output *get_screen_at(int x, int y) {
|
282 |
+static Output *get_screen_at(unsigned int x, unsigned int y) {
|
283 |
Output *output;
|
284 |
TAILQ_FOREACH(output, &outputs, outputs)
|
285 |
if (output->rect.x == x && output->rect.y == y)
|
b/src/floating.c
290 |
@@ -535,12 +535,12 @@ void floating_resize_window(Con *con, const bool proportional,
|
291 |
* a bitmask of the nearest borders (BORDER_LEFT, BORDER_RIGHT, …) */
|
292 |
border_t corner = 0;
|
293 |
|
294 |
- if (event->event_x <= (con->rect.width / 2))
|
295 |
+ if (event->event_x <= (int16_t)(con->rect.width / 2))
|
296 |
corner |= BORDER_LEFT;
|
297 |
else corner |= BORDER_RIGHT;
|
298 |
|
299 |
int cursor = 0;
|
300 |
- if (event->event_y <= (con->rect.height / 2)) {
|
301 |
+ if (event->event_y <= (int16_t)(con->rect.height / 2)) {
|
302 |
corner |= BORDER_TOP;
|
303 |
cursor = (corner & BORDER_LEFT) ?
|
304 |
XCURSOR_CURSOR_TOP_LEFT_CORNER : XCURSOR_CURSOR_TOP_RIGHT_CORNER;
|
b/src/handlers.c
309 |
@@ -1034,7 +1034,7 @@ static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
|
310 |
struct property_handler_t *handler = NULL;
|
311 |
xcb_get_property_reply_t *propr = NULL;
|
312 |
|
313 |
- for (int c = 0; c < sizeof(property_handlers) / sizeof(struct property_handler_t); c++) {
|
314 |
+ for (size_t c = 0; c < sizeof(property_handlers) / sizeof(struct property_handler_t); c++) {
|
315 |
if (property_handlers[c].atom != atom)
|
316 |
continue;
|
317 |
|
b/src/log.c
322 |
@@ -250,7 +250,7 @@ static void vlog(const bool print, const char *fmt, va_list args) {
|
323 |
|
324 |
/* If there is no space for the current message in the ringbuffer, we
|
325 |
* need to wrap and write to the beginning again. */
|
326 |
- if (len >= (logbuffer_size - (logwalk - logbuffer))) {
|
327 |
+ if (len >= (size_t)(logbuffer_size - (logwalk - logbuffer))) {
|
328 |
loglastwrap = logwalk;
|
329 |
logwalk = logbuffer + sizeof(i3_shmlog_header);
|
330 |
store_log_markers();
|
b/src/manage.c
335 |
@@ -252,7 +252,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
336 |
cwindow->dock = W_DOCK_BOTTOM;
|
337 |
} else {
|
338 |
DLOG("Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
|
339 |
- if (geom->y < (search_at->rect.height / 2)) {
|
340 |
+ if (geom->y < (int16_t)(search_at->rect.height / 2)) {
|
341 |
DLOG("geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
|
342 |
geom->y, (search_at->rect.height / 2));
|
343 |
cwindow->dock = W_DOCK_TOP;
|
b/src/randr.c
348 |
@@ -77,7 +77,7 @@ Output *get_first_output(void) {
|
349 |
* if there is no output which contains these coordinates.
|
350 |
*
|
351 |
*/
|
352 |
-Output *get_output_containing(int x, int y) {
|
353 |
+Output *get_output_containing(unsigned int x, unsigned int y) {
|
354 |
Output *output;
|
355 |
TAILQ_FOREACH(output, &outputs, outputs) {
|
356 |
if (!output->active)
|
b/src/util.c
361 |
@@ -224,7 +224,7 @@ char *store_restart_layout(void) {
|
362 |
return NULL;
|
363 |
}
|
364 |
|
365 |
- int written = 0;
|
366 |
+ size_t written = 0;
|
367 |
while (written < length) {
|
368 |
int n = write(fd, payload + written, length - written);
|
369 |
/* TODO: correct error-handling */
|
370 |
@@ -242,7 +242,7 @@ char *store_restart_layout(void) {
|
371 |
}
|
372 |
written += n;
|
373 |
#if YAJL_MAJOR >= 2
|
374 |
- printf("written: %d of %zd\n", written, length);
|
375 |
+ printf("written: %zd of %zd\n", written, length);
|
376 |
#else
|
377 |
printf("written: %d of %d\n", written, length);
|
378 |
#endif
|
b/src/window.c
383 |
@@ -32,7 +32,7 @@ void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool bef
|
384 |
FREE(win->class_class);
|
385 |
|
386 |
win->class_instance = sstrdup(new_class);
|
387 |
- if ((strlen(new_class) + 1) < xcb_get_property_value_length(prop))
|
388 |
+ if ((strlen(new_class) + 1) < (size_t)xcb_get_property_value_length(prop))
|
389 |
win->class_class = sstrdup(new_class + strlen(new_class) + 1);
|
390 |
else win->class_class = NULL;
|
391 |
LOG("WM_CLASS changed to %s (instance), %s (class)\n",
|
b/src/xinerama.c
396 |
@@ -22,7 +22,7 @@ static int num_screens;
|
397 |
* Looks in outputs for the Output whose start coordinates are x, y
|
398 |
*
|
399 |
*/
|
400 |
-static Output *get_screen_at(int x, int y) {
|
401 |
+static Output *get_screen_at(unsigned int x, unsigned int y) {
|
402 |
Output *output;
|
403 |
TAILQ_FOREACH(output, &outputs, outputs)
|
404 |
if (output->rect.x == x && output->rect.y == y)
|