Discussion:
[PATCH 0/4] GCC5 warnings
Ben Boeckel
2015-02-22 16:34:22 UTC
Permalink
Rawhide now has GCC5 and these warnings popped up when using it.

Ben Boeckel (4):
fix format specifiers
cast format values where necessary
tty_term: use an unsigned int for flags
getopt: use const for place

client.c | 6 +++---
cmd-capture-pane.c | 2 +-
cmd-respawn-pane.c | 2 +-
colour.c | 2 +-
compat/getopt.c | 4 ++--
format.c | 30 +++++++++++++++---------------
input-keys.c | 8 ++++----
input.c | 2 +-
key-string.c | 2 +-
layout.c | 2 +-
server-client.c | 2 +-
server-fn.c | 4 ++--
server-window.c | 6 +++---
tmux.h | 2 +-
tty-keys.c | 8 ++++----
tty-term.c | 6 +++---
window-choose.c | 2 +-
window-copy.c | 2 +-
18 files changed, 46 insertions(+), 46 deletions(-)
--
2.3.0
Ben Boeckel
2015-02-22 16:34:26 UTC
Permalink
Prevents a warning here about const char* -> char* assignment tossing
away the qualifier. The warning is still there for BSDoptarg, but that
is specified by getopt.h to not be const.

Also fix a stray whitespace error.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
compat/getopt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compat/getopt.c b/compat/getopt.c
index a93f368..03ad9e8 100644
--- a/compat/getopt.c
+++ b/compat/getopt.c
@@ -52,7 +52,7 @@ char *BSDoptarg; /* argument associated with option */
int
BSDgetopt(int nargc, char *const *nargv, const char *ostr)
{
- static char *place = EMSG; /* option letter processing */
+ static const char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */

if (ostr == NULL)
@@ -105,7 +105,7 @@ BSDgetopt(int nargc, char *const *nargv, const char *ostr)
__progname, BSDoptopt);
return (BADCH);
}
- else /* white space */
+ else /* white space */
BSDoptarg = nargv[BSDoptind];
place = EMSG;
++BSDoptind;
--
2.3.0
Ben Boeckel
2015-02-22 16:34:24 UTC
Permalink
The %x and %o specifers require unsigned arguments.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
cmd-capture-pane.c | 2 +-
input-keys.c | 6 +++---
key-string.c | 2 +-
layout.c | 2 +-
tty-keys.c | 8 ++++----
5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index ce60b4c..68fef98 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -74,7 +74,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
tmp[0] = line[i];
tmp[1] = '\0';
} else
- xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
+ xsnprintf(tmp, sizeof tmp, "\\%03o", (unsigned char)line[i]);
buf = cmd_capture_pane_append(buf, len, tmp,
strlen(tmp));
}
diff --git a/input-keys.c b/input-keys.c
index 762e86b..969ec08 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -142,7 +142,7 @@ input_key(struct window_pane *wp, int key)
char *out;
u_char ch;

- log_debug("writing key 0x%x", key);
+ log_debug("writing key 0x%x", (unsigned)key);

/*
* If this is a normal 7-bit key, just send it, with a leading escape
@@ -185,11 +185,11 @@ input_key(struct window_pane *wp, int key)
break;
}
if (i == nitems(input_keys)) {
- log_debug("key 0x%x missing", key);
+ log_debug("key 0x%x missing", (unsigned)key);
return;
}
dlen = strlen(ike->data);
- log_debug("found key 0x%x: \"%s\"", key, ike->data);
+ log_debug("found key 0x%x: \"%s\"", (unsigned)key, ike->data);

/* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE)
diff --git a/key-string.c b/key-string.c
index db96827..ab9f2f9 100644
--- a/key-string.c
+++ b/key-string.c
@@ -236,7 +236,7 @@ key_string_lookup_key(int key)
tmp[0] = key;
tmp[1] = '\0';
} else if (key >= 128)
- xsnprintf(tmp, sizeof tmp, "\\%o", key);
+ xsnprintf(tmp, sizeof tmp, "\\%o", (unsigned)key);

strlcat(out, tmp, sizeof out);
return (out);
diff --git a/layout.c b/layout.c
index b91b86c..9ba8fca 100644
--- a/layout.c
+++ b/layout.c
@@ -86,7 +86,7 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
struct layout_cell *lcchild;

log_debug(
- "%s:%*s%p type %u [parent %p] wp=%p [%u,%u %ux%u]", hdr, n, " ", lc,
+ "%s:%*s%p type %u [parent %p] wp=%p [%u,%u %ux%u]", hdr, (int)n, " ", lc,
lc->type, lc->parent, lc->wp, lc->xoff, lc->yoff, lc->sx, lc->sy);
switch (lc->type) {
case LAYOUT_LEFTRIGHT:
diff --git a/tty-keys.c b/tty-keys.c
index a987c44..42db792 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -326,10 +326,10 @@ tty_keys_add(struct tty *tty, const char *s, int key)

keystr = key_string_lookup_key(key);
if ((tk = tty_keys_find(tty, s, strlen(s), &size)) == NULL) {
- log_debug("new key %s: 0x%x (%s)", s, key, keystr);
+ log_debug("new key %s: 0x%x (%s)", s, (unsigned)key, keystr);
tty_keys_add1(&tty->key_tree, s, key);
} else {
- log_debug("replacing key %s: 0x%x (%s)", s, key, keystr);
+ log_debug("replacing key %s: 0x%x (%s)", s, (unsigned)key, keystr);
tk->key = key;
}
}
@@ -589,7 +589,7 @@ partial_key:
return (0);

complete_key:
- log_debug("complete key %.*s %#x", (int) size, buf, key);
+ log_debug("complete key %.*s %#x", (int) size, buf, (unsigned)key);

/* Remove data from buffer. */
evbuffer_drain(tty->event->input, size);
@@ -615,7 +615,7 @@ complete_key:
return (1);

discard_key:
- log_debug("discard key %.*s %#x", (int) size, buf, key);
+ log_debug("discard key %.*s %#x", (int) size, buf, (unsigned)key);

/* Remove data from buffer. */
evbuffer_drain(tty->event->input, size);
--
2.3.0
Nicholas Marriott
2015-02-22 17:32:57 UTC
Permalink
Post by Ben Boeckel
} else
- xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
+ xsnprintf(tmp, sizeof tmp, "\\%03o", (unsigned char)line[i]);
%hho and (u_char)?
Post by Ben Boeckel
buf = cmd_capture_pane_append(buf, len, tmp,
strlen(tmp));
}
diff --git a/input-keys.c b/input-keys.c
index 762e86b..969ec08 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -142,7 +142,7 @@ input_key(struct window_pane *wp, int key)
char *out;
u_char ch;
- log_debug("writing key 0x%x", key);
+ log_debug("writing key 0x%x", (unsigned)key);
(u_int) not (unsigned) please.
Ben Boeckel
2015-02-22 16:34:25 UTC
Permalink
Signed-off-by: Ben Boeckel <***@gmail.com>
---
tmux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tmux.h b/tmux.h
index e296ac7..1ba0e83 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1093,7 +1093,7 @@ struct tty_term {

#define TERM_256COLOURS 0x1
#define TERM_EARLYWRAP 0x2
- int flags;
+ unsigned int flags;

LIST_ENTRY(tty_term) entry;
};
--
2.3.0
Nicholas Marriott
2015-02-22 18:46:33 UTC
Permalink
I always use int for flags.
Post by Ben Boeckel
---
tmux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tmux.h b/tmux.h
index e296ac7..1ba0e83 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1093,7 +1093,7 @@ struct tty_term {
#define TERM_256COLOURS 0x1
#define TERM_EARLYWRAP 0x2
- int flags;
+ unsigned int flags;
LIST_ENTRY(tty_term) entry;
};
--
2.3.0
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Ben Boeckel
2015-02-22 19:03:17 UTC
Permalink
Post by Nicholas Marriott
I always use int for flags.
Any reason why? It changes the meaning of some bits, but I can use u_int
for its format usage as well (it is %x).

--Ben
Nicholas Marriott
2015-02-22 19:39:21 UTC
Permalink
No particular reason but I don't think we should change them, I'd just
cast it or leave the warning.
Post by Ben Boeckel
Post by Nicholas Marriott
I always use int for flags.
Any reason why? It changes the meaning of some bits, but I can use u_int
for its format usage as well (it is %x).
--Ben
Ben Boeckel
2015-02-22 16:34:23 UTC
Permalink
GCC5 is warning about these things more it seems.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
client.c | 6 +++---
cmd-respawn-pane.c | 2 +-
colour.c | 2 +-
format.c | 30 +++++++++++++++---------------
input-keys.c | 2 +-
input.c | 2 +-
server-client.c | 2 +-
server-fn.c | 4 ++--
server-window.c | 6 +++---
tty-term.c | 6 +++---
window-choose.c | 2 +-
window-copy.c | 2 +-
12 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/client.c b/client.c
index 042ec92..c16afac 100644
--- a/client.c
+++ b/client.c
@@ -561,7 +561,7 @@ client_dispatch_wait(void *data0)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;

- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_EXIT:
case MSG_SHUTDOWN:
@@ -608,7 +608,7 @@ client_dispatch_wait(void *data0)
fatalx("bad MSG_VERSION size");

fprintf(stderr, "protocol version mismatch "
- "(client %u, server %u)\n", PROTOCOL_VERSION,
+ "(client %d, server %u)\n", PROTOCOL_VERSION,
imsg.hdr.peerid);
client_exitval = 1;

@@ -652,7 +652,7 @@ client_dispatch_attached(void)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;

- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_DETACH:
case MSG_DETACHKILL:
diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c
index 4703153..6575e8e 100644
--- a/cmd-respawn-pane.c
+++ b/cmd-respawn-pane.c
@@ -59,7 +59,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (!args_has(self->args, 'k') && wp->fd != -1) {
if (window_pane_index(wp, &idx) != 0)
fatalx("index not found");
- cmdq_error(cmdq, "pane still active: %s:%u.%u",
+ cmdq_error(cmdq, "pane still active: %s:%d.%u",
s->name, wl->idx, idx);
return (CMD_RETURN_ERROR);
}
diff --git a/colour.c b/colour.c
index b5efd6f..82f8533 100644
--- a/colour.c
+++ b/colour.c
@@ -147,7 +147,7 @@ colour_tostring(int c)
static char s[32];

if (c & 0x100) {
- xsnprintf(s, sizeof s, "colour%u", c & ~0x100);
+ xsnprintf(s, sizeof s, "colour%d", c & ~0x100);
return (s);
}

diff --git a/format.c b/format.c
index 776de96..164fef0 100644
--- a/format.c
+++ b/format.c
@@ -504,7 +504,7 @@ format_defaults_session(struct format_tree *ft, struct session *s)
format_add(ft, "session_created_string", "%s", tim);

format_add(ft, "session_attached", "%u", s->attached);
- format_add(ft, "session_many_attached", "%u", s->attached > 1);
+ format_add(ft, "session_many_attached", "%d", s->attached > 1);
}

/* Set default format keys for a client. */
@@ -573,7 +573,7 @@ format_defaults_window(struct format_tree *ft, struct window *w)
format_add(ft, "window_height", "%u", w->sy);
format_add(ft, "window_layout", "%s", layout);
format_add(ft, "window_panes", "%u", window_count_panes(w));
- format_add(ft, "window_zoomed_flag", "%u",
+ format_add(ft, "window_zoomed_flag", "%d",
!!(w->flags & WINDOW_ZOOMED));

free(layout);
@@ -598,13 +598,13 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
format_add(ft, "window_flags", "%s", flags);
format_add(ft, "window_active", "%d", wl == s->curw);

- format_add(ft, "window_bell_flag", "%u",
+ format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
- format_add(ft, "window_activity_flag", "%u",
+ format_add(ft, "window_activity_flag", "%d",
!!(wl->flags & WINLINK_ACTIVITY));
- format_add(ft, "window_silence_flag", "%u",
+ format_add(ft, "window_silence_flag", "%d",
!!(wl->flags & WINLINK_SILENCE));
- format_add(ft, "window_last_flag", "%u",
+ format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));

free(flags);
@@ -624,7 +624,7 @@ format_defaults_pane_tabs(struct format_tree *ft, struct window_pane *wp)

if (EVBUFFER_LENGTH(buffer) > 0)
evbuffer_add(buffer, ",", 1);
- evbuffer_add_printf(buffer, "%d", i);
+ evbuffer_add_printf(buffer, "%u", i);
}

format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
@@ -697,16 +697,16 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
free(cmd);
}

- format_add(ft, "cursor_x", "%d", wp->base.cx);
- format_add(ft, "cursor_y", "%d", wp->base.cy);
- format_add(ft, "scroll_region_upper", "%d", wp->base.rupper);
- format_add(ft, "scroll_region_lower", "%d", wp->base.rlower);
- format_add(ft, "saved_cursor_x", "%d", wp->ictx.old_cx);
- format_add(ft, "saved_cursor_y", "%d", wp->ictx.old_cy);
+ format_add(ft, "cursor_x", "%u", wp->base.cx);
+ format_add(ft, "cursor_y", "%u", wp->base.cy);
+ format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
+ format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
+ format_add(ft, "saved_cursor_x", "%u", wp->ictx.old_cx);
+ format_add(ft, "saved_cursor_y", "%u", wp->ictx.old_cy);

format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
- format_add(ft, "alternate_saved_x", "%d", wp->saved_cx);
- format_add(ft, "alternate_saved_y", "%d", wp->saved_cy);
+ format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
+ format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);

format_add(ft, "cursor_flag", "%d",
!!(wp->base.mode & MODE_CURSOR));
diff --git a/input-keys.c b/input-keys.c
index ef652ee..762e86b 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -218,7 +218,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
* legacy format.
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
- len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
+ len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c",
m->sgr_xb, m->x + 1, m->y + 1,
m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
diff --git a/input.c b/input.c
index de11f62..80fed9e 100644
--- a/input.c
+++ b/input.c
@@ -1747,7 +1747,7 @@ input_exit_osc(struct input_ctx *ictx)
screen_set_cursor_colour(ictx->ctx.s, "");
break;
default:
- log_debug("%s: unknown '%u'", __func__, option);
+ log_debug("%s: unknown '%d'", __func__, option);
break;
}
}
diff --git a/server-client.c b/server-client.c
index 3ca9907..f7ce35c 100644
--- a/server-client.c
+++ b/server-client.c
@@ -833,7 +833,7 @@ server_client_msg_dispatch(struct client *c)
continue;
}

- log_debug("got %d from client %d", imsg.hdr.type, c->ibuf.fd);
+ log_debug("got %u from client %d", imsg.hdr.type, c->ibuf.fd);
switch (imsg.hdr.type) {
case MSG_IDENTIFY_FLAGS:
case MSG_IDENTIFY_TERM:
diff --git a/server-fn.c b/server-fn.c
index 1ed3a01..ad82540 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -43,7 +43,7 @@ server_fill_environ(struct session *s, struct environ *env)
} else
idx = -1;
pid = getpid();
- xsnprintf(var, sizeof var, "%s,%ld,%d", socket_path, pid, idx);
+ xsnprintf(var, sizeof var, "%s,%ld,%u", socket_path, pid, idx);
environ_set(env, "TMUX", var);
}

@@ -64,7 +64,7 @@ server_write_client(struct client *c, enum msgtype type, const void *buf,

if (c->flags & CLIENT_BAD)
return (-1);
- log_debug("writing %d to client %d", type, c->ibuf.fd);
+ log_debug("writing %u to client %d", type, c->ibuf.fd);
error = imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1,
(void *) buf, len);
if (error == 1)
diff --git a/server-window.c b/server-window.c
index a14c315..a235570 100644
--- a/server-window.c
+++ b/server-window.c
@@ -90,7 +90,7 @@ server_window_check_bell(struct session *s, struct winlink *wl)
if (c->session->curw->window == w)
status_message_set(c, "Bell in current window");
else if (action == BELL_ANY)
- status_message_set(c, "Bell in window %u", wl->idx);
+ status_message_set(c, "Bell in window %d", wl->idx);
}

return (1);
@@ -124,7 +124,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Activity in window %u", wl->idx);
+ status_message_set(c, "Activity in window %d", wl->idx);
}
}

@@ -175,7 +175,7 @@ server_window_check_silence(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Silence in window %u", wl->idx);
+ status_message_set(c, "Silence in window %d", wl->idx);
}
}

diff --git a/tty-term.c b/tty-term.c
index 365da5f..fa30ab4 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -532,7 +532,7 @@ tty_term_string(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return ("");
if (term->codes[code].type != TTYCODE_STRING)
- log_fatalx("not a string: %d", code);
+ log_fatalx("not a string: %u", code);
return (term->codes[code].value.string);
}

@@ -568,7 +568,7 @@ tty_term_number(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_NUMBER)
- log_fatalx("not a number: %d", code);
+ log_fatalx("not a number: %u", code);
return (term->codes[code].value.number);
}

@@ -578,6 +578,6 @@ tty_term_flag(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_FLAG)
- log_fatalx("not a flag: %d", code);
+ log_fatalx("not a flag: %u", code);
return (term->codes[code].value.flag);
}
diff --git a/window-choose.c b/window-choose.c
index 6914167..8bed8d4 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -98,7 +98,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
item->pos = ARRAY_LENGTH(&data->list) - 1;
item->state = 0;

- data->width = xsnprintf(tmp, sizeof tmp , "%u", item->pos);
+ data->width = xsnprintf(tmp, sizeof tmp , "%d", item->pos);
}

void
diff --git a/window-copy.c b/window-copy.c
index 223df88..074e731 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1216,7 +1216,7 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
limit = screen_size_x(s) + 1;
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
xoff = size = xsnprintf(hdr, limit,
- "Repeat: %u", data->numprefix);
+ "Repeat: %d", data->numprefix);
} else {
xoff = size = xsnprintf(hdr, limit,
"%s: %s", data->inputprompt, data->inputstr);
--
2.3.0
Nicholas Marriott
2015-02-22 17:33:41 UTC
Permalink
Looks good but I think PROTOCOL_VERSION should just be made unsigned.
Post by Ben Boeckel
GCC5 is warning about these things more it seems.
---
client.c | 6 +++---
cmd-respawn-pane.c | 2 +-
colour.c | 2 +-
format.c | 30 +++++++++++++++---------------
input-keys.c | 2 +-
input.c | 2 +-
server-client.c | 2 +-
server-fn.c | 4 ++--
server-window.c | 6 +++---
tty-term.c | 6 +++---
window-choose.c | 2 +-
window-copy.c | 2 +-
12 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/client.c b/client.c
index 042ec92..c16afac 100644
--- a/client.c
+++ b/client.c
@@ -561,7 +561,7 @@ client_dispatch_wait(void *data0)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
@@ -608,7 +608,7 @@ client_dispatch_wait(void *data0)
fatalx("bad MSG_VERSION size");
fprintf(stderr, "protocol version mismatch "
- "(client %u, server %u)\n", PROTOCOL_VERSION,
+ "(client %d, server %u)\n", PROTOCOL_VERSION,
imsg.hdr.peerid);
client_exitval = 1;
@@ -652,7 +652,7 @@ client_dispatch_attached(void)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c
index 4703153..6575e8e 100644
--- a/cmd-respawn-pane.c
+++ b/cmd-respawn-pane.c
@@ -59,7 +59,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (!args_has(self->args, 'k') && wp->fd != -1) {
if (window_pane_index(wp, &idx) != 0)
fatalx("index not found");
- cmdq_error(cmdq, "pane still active: %s:%u.%u",
+ cmdq_error(cmdq, "pane still active: %s:%d.%u",
s->name, wl->idx, idx);
return (CMD_RETURN_ERROR);
}
diff --git a/colour.c b/colour.c
index b5efd6f..82f8533 100644
--- a/colour.c
+++ b/colour.c
@@ -147,7 +147,7 @@ colour_tostring(int c)
static char s[32];
if (c & 0x100) {
- xsnprintf(s, sizeof s, "colour%u", c & ~0x100);
+ xsnprintf(s, sizeof s, "colour%d", c & ~0x100);
return (s);
}
diff --git a/format.c b/format.c
index 776de96..164fef0 100644
--- a/format.c
+++ b/format.c
@@ -504,7 +504,7 @@ format_defaults_session(struct format_tree *ft, struct session *s)
format_add(ft, "session_created_string", "%s", tim);
format_add(ft, "session_attached", "%u", s->attached);
- format_add(ft, "session_many_attached", "%u", s->attached > 1);
+ format_add(ft, "session_many_attached", "%d", s->attached > 1);
}
/* Set default format keys for a client. */
@@ -573,7 +573,7 @@ format_defaults_window(struct format_tree *ft, struct window *w)
format_add(ft, "window_height", "%u", w->sy);
format_add(ft, "window_layout", "%s", layout);
format_add(ft, "window_panes", "%u", window_count_panes(w));
- format_add(ft, "window_zoomed_flag", "%u",
+ format_add(ft, "window_zoomed_flag", "%d",
!!(w->flags & WINDOW_ZOOMED));
free(layout);
@@ -598,13 +598,13 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
format_add(ft, "window_flags", "%s", flags);
format_add(ft, "window_active", "%d", wl == s->curw);
- format_add(ft, "window_bell_flag", "%u",
+ format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
- format_add(ft, "window_activity_flag", "%u",
+ format_add(ft, "window_activity_flag", "%d",
!!(wl->flags & WINLINK_ACTIVITY));
- format_add(ft, "window_silence_flag", "%u",
+ format_add(ft, "window_silence_flag", "%d",
!!(wl->flags & WINLINK_SILENCE));
- format_add(ft, "window_last_flag", "%u",
+ format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));
free(flags);
@@ -624,7 +624,7 @@ format_defaults_pane_tabs(struct format_tree *ft, struct window_pane *wp)
if (EVBUFFER_LENGTH(buffer) > 0)
evbuffer_add(buffer, ",", 1);
- evbuffer_add_printf(buffer, "%d", i);
+ evbuffer_add_printf(buffer, "%u", i);
}
format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
@@ -697,16 +697,16 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
free(cmd);
}
- format_add(ft, "cursor_x", "%d", wp->base.cx);
- format_add(ft, "cursor_y", "%d", wp->base.cy);
- format_add(ft, "scroll_region_upper", "%d", wp->base.rupper);
- format_add(ft, "scroll_region_lower", "%d", wp->base.rlower);
- format_add(ft, "saved_cursor_x", "%d", wp->ictx.old_cx);
- format_add(ft, "saved_cursor_y", "%d", wp->ictx.old_cy);
+ format_add(ft, "cursor_x", "%u", wp->base.cx);
+ format_add(ft, "cursor_y", "%u", wp->base.cy);
+ format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
+ format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
+ format_add(ft, "saved_cursor_x", "%u", wp->ictx.old_cx);
+ format_add(ft, "saved_cursor_y", "%u", wp->ictx.old_cy);
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
- format_add(ft, "alternate_saved_x", "%d", wp->saved_cx);
- format_add(ft, "alternate_saved_y", "%d", wp->saved_cy);
+ format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
+ format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);
format_add(ft, "cursor_flag", "%d",
!!(wp->base.mode & MODE_CURSOR));
diff --git a/input-keys.c b/input-keys.c
index ef652ee..762e86b 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -218,7 +218,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
* legacy format.
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
- len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
+ len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c",
m->sgr_xb, m->x + 1, m->y + 1,
m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
diff --git a/input.c b/input.c
index de11f62..80fed9e 100644
--- a/input.c
+++ b/input.c
@@ -1747,7 +1747,7 @@ input_exit_osc(struct input_ctx *ictx)
screen_set_cursor_colour(ictx->ctx.s, "");
break;
- log_debug("%s: unknown '%u'", __func__, option);
+ log_debug("%s: unknown '%d'", __func__, option);
break;
}
}
diff --git a/server-client.c b/server-client.c
index 3ca9907..f7ce35c 100644
--- a/server-client.c
+++ b/server-client.c
@@ -833,7 +833,7 @@ server_client_msg_dispatch(struct client *c)
continue;
}
- log_debug("got %d from client %d", imsg.hdr.type, c->ibuf.fd);
+ log_debug("got %u from client %d", imsg.hdr.type, c->ibuf.fd);
switch (imsg.hdr.type) {
diff --git a/server-fn.c b/server-fn.c
index 1ed3a01..ad82540 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -43,7 +43,7 @@ server_fill_environ(struct session *s, struct environ *env)
} else
idx = -1;
pid = getpid();
- xsnprintf(var, sizeof var, "%s,%ld,%d", socket_path, pid, idx);
+ xsnprintf(var, sizeof var, "%s,%ld,%u", socket_path, pid, idx);
environ_set(env, "TMUX", var);
}
@@ -64,7 +64,7 @@ server_write_client(struct client *c, enum msgtype type, const void *buf,
if (c->flags & CLIENT_BAD)
return (-1);
- log_debug("writing %d to client %d", type, c->ibuf.fd);
+ log_debug("writing %u to client %d", type, c->ibuf.fd);
error = imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1,
(void *) buf, len);
if (error == 1)
diff --git a/server-window.c b/server-window.c
index a14c315..a235570 100644
--- a/server-window.c
+++ b/server-window.c
@@ -90,7 +90,7 @@ server_window_check_bell(struct session *s, struct winlink *wl)
if (c->session->curw->window == w)
status_message_set(c, "Bell in current window");
else if (action == BELL_ANY)
- status_message_set(c, "Bell in window %u", wl->idx);
+ status_message_set(c, "Bell in window %d", wl->idx);
}
return (1);
@@ -124,7 +124,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Activity in window %u", wl->idx);
+ status_message_set(c, "Activity in window %d", wl->idx);
}
}
@@ -175,7 +175,7 @@ server_window_check_silence(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Silence in window %u", wl->idx);
+ status_message_set(c, "Silence in window %d", wl->idx);
}
}
diff --git a/tty-term.c b/tty-term.c
index 365da5f..fa30ab4 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -532,7 +532,7 @@ tty_term_string(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return ("");
if (term->codes[code].type != TTYCODE_STRING)
- log_fatalx("not a string: %d", code);
+ log_fatalx("not a string: %u", code);
return (term->codes[code].value.string);
}
@@ -568,7 +568,7 @@ tty_term_number(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_NUMBER)
- log_fatalx("not a number: %d", code);
+ log_fatalx("not a number: %u", code);
return (term->codes[code].value.number);
}
@@ -578,6 +578,6 @@ tty_term_flag(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_FLAG)
- log_fatalx("not a flag: %d", code);
+ log_fatalx("not a flag: %u", code);
return (term->codes[code].value.flag);
}
diff --git a/window-choose.c b/window-choose.c
index 6914167..8bed8d4 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -98,7 +98,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
item->pos = ARRAY_LENGTH(&data->list) - 1;
item->state = 0;
- data->width = xsnprintf(tmp, sizeof tmp , "%u", item->pos);
+ data->width = xsnprintf(tmp, sizeof tmp , "%d", item->pos);
}
void
diff --git a/window-copy.c b/window-copy.c
index 223df88..074e731 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1216,7 +1216,7 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
limit = screen_size_x(s) + 1;
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
xoff = size = xsnprintf(hdr, limit,
- "Repeat: %u", data->numprefix);
+ "Repeat: %d", data->numprefix);
} else {
xoff = size = xsnprintf(hdr, limit,
"%s: %s", data->inputprompt, data->inputstr);
--
2.3.0
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Ben Boeckel
2015-02-22 21:21:01 UTC
Permalink
Signed-off-by: Ben Boeckel <***@gmail.com>
---
tmux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tmux.h b/tmux.h
index e296ac7..87ed093 100644
--- a/tmux.h
+++ b/tmux.h
@@ -19,7 +19,7 @@
#ifndef TMUX_H
#define TMUX_H

-#define PROTOCOL_VERSION 8
+#define PROTOCOL_VERSION 8u

#include <sys/time.h>
#include <sys/uio.h>
--
2.3.0
Nicholas Marriott
2015-03-02 15:04:03 UTC
Permalink
Ok these look good I will apply them when OpenBSD unlocks.
Post by Ben Boeckel
---
tmux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tmux.h b/tmux.h
index e296ac7..87ed093 100644
--- a/tmux.h
+++ b/tmux.h
@@ -19,7 +19,7 @@
#ifndef TMUX_H
#define TMUX_H
-#define PROTOCOL_VERSION 8
+#define PROTOCOL_VERSION 8u
#include <sys/time.h>
#include <sys/uio.h>
--
2.3.0
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Nicholas Marriott
2015-03-31 17:45:04 UTC
Permalink
Hi

After some thought I decided to leave PROTOCOL_VERSION as it is. I've
applied most of your second diff (the format specifiers) except I have
left enums as %d (their type is dependent on the compiler and I think
GCC is wrong to warn as if they are unsigned).

I've applied the capture-pane part (%hho) of the last diff but I'm going
to leave the rest, I think casts for %o and %x are just clutter.

Thanks
Post by Ben Boeckel
---
tmux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tmux.h b/tmux.h
index e296ac7..87ed093 100644
--- a/tmux.h
+++ b/tmux.h
@@ -19,7 +19,7 @@
#ifndef TMUX_H
#define TMUX_H
-#define PROTOCOL_VERSION 8
+#define PROTOCOL_VERSION 8u
#include <sys/time.h>
#include <sys/uio.h>
--
2.3.0
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Ben Boeckel
2015-02-22 21:21:04 UTC
Permalink
Prevents a warning here about const char* -> char* assignment tossing
away the qualifier. The warning is still there for BSDoptarg, but that
is specified by getopt.h to not be const.

Also fix a stray whitespace error.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
compat/getopt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compat/getopt.c b/compat/getopt.c
index a93f368..03ad9e8 100644
--- a/compat/getopt.c
+++ b/compat/getopt.c
@@ -52,7 +52,7 @@ char *BSDoptarg; /* argument associated with option */
int
BSDgetopt(int nargc, char *const *nargv, const char *ostr)
{
- static char *place = EMSG; /* option letter processing */
+ static const char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */

if (ostr == NULL)
@@ -105,7 +105,7 @@ BSDgetopt(int nargc, char *const *nargv, const char *ostr)
__progname, BSDoptopt);
return (BADCH);
}
- else /* white space */
+ else /* white space */
BSDoptarg = nargv[BSDoptind];
place = EMSG;
++BSDoptind;
--
2.3.0
Ben Boeckel
2015-02-22 21:21:02 UTC
Permalink
GCC5 is warning about these things more it seems.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
client.c | 4 ++--
cmd-respawn-pane.c | 2 +-
cmd-show-messages.c | 2 +-
colour.c | 2 +-
format.c | 30 +++++++++++++++---------------
input-keys.c | 2 +-
input.c | 2 +-
server-client.c | 2 +-
server-fn.c | 4 ++--
server-window.c | 6 +++---
tty-term.c | 6 +++---
window-choose.c | 2 +-
window-copy.c | 2 +-
13 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/client.c b/client.c
index 042ec92..ca748d7 100644
--- a/client.c
+++ b/client.c
@@ -561,7 +561,7 @@ client_dispatch_wait(void *data0)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;

- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_EXIT:
case MSG_SHUTDOWN:
@@ -652,7 +652,7 @@ client_dispatch_attached(void)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;

- log_debug("got %d from server", imsg.hdr.type);
+ log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_DETACH:
case MSG_DETACHKILL:
diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c
index 4703153..6575e8e 100644
--- a/cmd-respawn-pane.c
+++ b/cmd-respawn-pane.c
@@ -59,7 +59,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (!args_has(self->args, 'k') && wp->fd != -1) {
if (window_pane_index(wp, &idx) != 0)
fatalx("index not found");
- cmdq_error(cmdq, "pane still active: %s:%u.%u",
+ cmdq_error(cmdq, "pane still active: %s:%d.%u",
s->name, wl->idx, idx);
return (CMD_RETURN_ERROR);
}
diff --git a/cmd-show-messages.c b/cmd-show-messages.c
index 308668f..0a6d48a 100644
--- a/cmd-show-messages.c
+++ b/cmd-show-messages.c
@@ -61,7 +61,7 @@ cmd_show_messages_server(struct cmd_q *cmdq)
cmdq_print(cmdq, "started %s", tim);
cmdq_print(cmdq, "socket path %s", socket_path);
cmdq_print(cmdq, "debug level %d", debug_level);
- cmdq_print(cmdq, "protocol version %d", PROTOCOL_VERSION);
+ cmdq_print(cmdq, "protocol version %u", PROTOCOL_VERSION);
}

void
diff --git a/colour.c b/colour.c
index b5efd6f..82f8533 100644
--- a/colour.c
+++ b/colour.c
@@ -147,7 +147,7 @@ colour_tostring(int c)
static char s[32];

if (c & 0x100) {
- xsnprintf(s, sizeof s, "colour%u", c & ~0x100);
+ xsnprintf(s, sizeof s, "colour%d", c & ~0x100);
return (s);
}

diff --git a/format.c b/format.c
index 776de96..164fef0 100644
--- a/format.c
+++ b/format.c
@@ -504,7 +504,7 @@ format_defaults_session(struct format_tree *ft, struct session *s)
format_add(ft, "session_created_string", "%s", tim);

format_add(ft, "session_attached", "%u", s->attached);
- format_add(ft, "session_many_attached", "%u", s->attached > 1);
+ format_add(ft, "session_many_attached", "%d", s->attached > 1);
}

/* Set default format keys for a client. */
@@ -573,7 +573,7 @@ format_defaults_window(struct format_tree *ft, struct window *w)
format_add(ft, "window_height", "%u", w->sy);
format_add(ft, "window_layout", "%s", layout);
format_add(ft, "window_panes", "%u", window_count_panes(w));
- format_add(ft, "window_zoomed_flag", "%u",
+ format_add(ft, "window_zoomed_flag", "%d",
!!(w->flags & WINDOW_ZOOMED));

free(layout);
@@ -598,13 +598,13 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
format_add(ft, "window_flags", "%s", flags);
format_add(ft, "window_active", "%d", wl == s->curw);

- format_add(ft, "window_bell_flag", "%u",
+ format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
- format_add(ft, "window_activity_flag", "%u",
+ format_add(ft, "window_activity_flag", "%d",
!!(wl->flags & WINLINK_ACTIVITY));
- format_add(ft, "window_silence_flag", "%u",
+ format_add(ft, "window_silence_flag", "%d",
!!(wl->flags & WINLINK_SILENCE));
- format_add(ft, "window_last_flag", "%u",
+ format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));

free(flags);
@@ -624,7 +624,7 @@ format_defaults_pane_tabs(struct format_tree *ft, struct window_pane *wp)

if (EVBUFFER_LENGTH(buffer) > 0)
evbuffer_add(buffer, ",", 1);
- evbuffer_add_printf(buffer, "%d", i);
+ evbuffer_add_printf(buffer, "%u", i);
}

format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
@@ -697,16 +697,16 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
free(cmd);
}

- format_add(ft, "cursor_x", "%d", wp->base.cx);
- format_add(ft, "cursor_y", "%d", wp->base.cy);
- format_add(ft, "scroll_region_upper", "%d", wp->base.rupper);
- format_add(ft, "scroll_region_lower", "%d", wp->base.rlower);
- format_add(ft, "saved_cursor_x", "%d", wp->ictx.old_cx);
- format_add(ft, "saved_cursor_y", "%d", wp->ictx.old_cy);
+ format_add(ft, "cursor_x", "%u", wp->base.cx);
+ format_add(ft, "cursor_y", "%u", wp->base.cy);
+ format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
+ format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
+ format_add(ft, "saved_cursor_x", "%u", wp->ictx.old_cx);
+ format_add(ft, "saved_cursor_y", "%u", wp->ictx.old_cy);

format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
- format_add(ft, "alternate_saved_x", "%d", wp->saved_cx);
- format_add(ft, "alternate_saved_y", "%d", wp->saved_cy);
+ format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
+ format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);

format_add(ft, "cursor_flag", "%d",
!!(wp->base.mode & MODE_CURSOR));
diff --git a/input-keys.c b/input-keys.c
index ef652ee..762e86b 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -218,7 +218,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
* legacy format.
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
- len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
+ len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c",
m->sgr_xb, m->x + 1, m->y + 1,
m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
diff --git a/input.c b/input.c
index de11f62..80fed9e 100644
--- a/input.c
+++ b/input.c
@@ -1747,7 +1747,7 @@ input_exit_osc(struct input_ctx *ictx)
screen_set_cursor_colour(ictx->ctx.s, "");
break;
default:
- log_debug("%s: unknown '%u'", __func__, option);
+ log_debug("%s: unknown '%d'", __func__, option);
break;
}
}
diff --git a/server-client.c b/server-client.c
index 3ca9907..f7ce35c 100644
--- a/server-client.c
+++ b/server-client.c
@@ -833,7 +833,7 @@ server_client_msg_dispatch(struct client *c)
continue;
}

- log_debug("got %d from client %d", imsg.hdr.type, c->ibuf.fd);
+ log_debug("got %u from client %d", imsg.hdr.type, c->ibuf.fd);
switch (imsg.hdr.type) {
case MSG_IDENTIFY_FLAGS:
case MSG_IDENTIFY_TERM:
diff --git a/server-fn.c b/server-fn.c
index 1ed3a01..ad82540 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -43,7 +43,7 @@ server_fill_environ(struct session *s, struct environ *env)
} else
idx = -1;
pid = getpid();
- xsnprintf(var, sizeof var, "%s,%ld,%d", socket_path, pid, idx);
+ xsnprintf(var, sizeof var, "%s,%ld,%u", socket_path, pid, idx);
environ_set(env, "TMUX", var);
}

@@ -64,7 +64,7 @@ server_write_client(struct client *c, enum msgtype type, const void *buf,

if (c->flags & CLIENT_BAD)
return (-1);
- log_debug("writing %d to client %d", type, c->ibuf.fd);
+ log_debug("writing %u to client %d", type, c->ibuf.fd);
error = imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1,
(void *) buf, len);
if (error == 1)
diff --git a/server-window.c b/server-window.c
index a14c315..a235570 100644
--- a/server-window.c
+++ b/server-window.c
@@ -90,7 +90,7 @@ server_window_check_bell(struct session *s, struct winlink *wl)
if (c->session->curw->window == w)
status_message_set(c, "Bell in current window");
else if (action == BELL_ANY)
- status_message_set(c, "Bell in window %u", wl->idx);
+ status_message_set(c, "Bell in window %d", wl->idx);
}

return (1);
@@ -124,7 +124,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Activity in window %u", wl->idx);
+ status_message_set(c, "Activity in window %d", wl->idx);
}
}

@@ -175,7 +175,7 @@ server_window_check_silence(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
- status_message_set(c, "Silence in window %u", wl->idx);
+ status_message_set(c, "Silence in window %d", wl->idx);
}
}

diff --git a/tty-term.c b/tty-term.c
index 365da5f..fa30ab4 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -532,7 +532,7 @@ tty_term_string(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return ("");
if (term->codes[code].type != TTYCODE_STRING)
- log_fatalx("not a string: %d", code);
+ log_fatalx("not a string: %u", code);
return (term->codes[code].value.string);
}

@@ -568,7 +568,7 @@ tty_term_number(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_NUMBER)
- log_fatalx("not a number: %d", code);
+ log_fatalx("not a number: %u", code);
return (term->codes[code].value.number);
}

@@ -578,6 +578,6 @@ tty_term_flag(struct tty_term *term, enum tty_code_code code)
if (!tty_term_has(term, code))
return (0);
if (term->codes[code].type != TTYCODE_FLAG)
- log_fatalx("not a flag: %d", code);
+ log_fatalx("not a flag: %u", code);
return (term->codes[code].value.flag);
}
diff --git a/window-choose.c b/window-choose.c
index 6914167..8bed8d4 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -98,7 +98,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
item->pos = ARRAY_LENGTH(&data->list) - 1;
item->state = 0;

- data->width = xsnprintf(tmp, sizeof tmp , "%u", item->pos);
+ data->width = xsnprintf(tmp, sizeof tmp , "%d", item->pos);
}

void
diff --git a/window-copy.c b/window-copy.c
index 223df88..074e731 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1216,7 +1216,7 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
limit = screen_size_x(s) + 1;
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
xoff = size = xsnprintf(hdr, limit,
- "Repeat: %u", data->numprefix);
+ "Repeat: %d", data->numprefix);
} else {
xoff = size = xsnprintf(hdr, limit,
"%s: %s", data->inputprompt, data->inputstr);
--
2.3.0
Ben Boeckel
2015-02-22 21:21:03 UTC
Permalink
The %x and %o specifers require unsigned arguments.

Signed-off-by: Ben Boeckel <***@gmail.com>
---
cmd-capture-pane.c | 2 +-
cmd-show-messages.c | 2 +-
input-keys.c | 6 +++---
key-string.c | 2 +-
layout.c | 2 +-
tty-keys.c | 8 ++++----
6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index ce60b4c..ab6cd48 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -74,7 +74,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
tmp[0] = line[i];
tmp[1] = '\0';
} else
- xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
+ xsnprintf(tmp, sizeof tmp, "\\%03hho", (u_char)line[i]);
buf = cmd_capture_pane_append(buf, len, tmp,
strlen(tmp));
}
diff --git a/cmd-show-messages.c b/cmd-show-messages.c
index 0a6d48a..43b6afa 100644
--- a/cmd-show-messages.c
+++ b/cmd-show-messages.c
@@ -77,7 +77,7 @@ cmd_show_messages_terminals(struct cmd_q *cmdq)
LIST_FOREACH(term, &tty_terms, entry) {
cmdq_print(cmdq,
"Terminal %u: %s [references=%u, flags=0x%x]:",
- n, term->name, term->references, term->flags);
+ n, term->name, term->references, (u_int)term->flags);
n++;
for (i = 0; i < NTTYCODE; i++) {
ent = &tty_term_codes[i];
diff --git a/input-keys.c b/input-keys.c
index 762e86b..fadde0d 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -142,7 +142,7 @@ input_key(struct window_pane *wp, int key)
char *out;
u_char ch;

- log_debug("writing key 0x%x", key);
+ log_debug("writing key 0x%x", (u_int)key);

/*
* If this is a normal 7-bit key, just send it, with a leading escape
@@ -185,11 +185,11 @@ input_key(struct window_pane *wp, int key)
break;
}
if (i == nitems(input_keys)) {
- log_debug("key 0x%x missing", key);
+ log_debug("key 0x%x missing", (u_int)key);
return;
}
dlen = strlen(ike->data);
- log_debug("found key 0x%x: \"%s\"", key, ike->data);
+ log_debug("found key 0x%x: \"%s\"", (u_int)key, ike->data);

/* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE)
diff --git a/key-string.c b/key-string.c
index db96827..fb6c53e 100644
--- a/key-string.c
+++ b/key-string.c
@@ -236,7 +236,7 @@ key_string_lookup_key(int key)
tmp[0] = key;
tmp[1] = '\0';
} else if (key >= 128)
- xsnprintf(tmp, sizeof tmp, "\\%o", key);
+ xsnprintf(tmp, sizeof tmp, "\\%o", (u_int)key);

strlcat(out, tmp, sizeof out);
return (out);
diff --git a/layout.c b/layout.c
index b91b86c..9ba8fca 100644
--- a/layout.c
+++ b/layout.c
@@ -86,7 +86,7 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
struct layout_cell *lcchild;

log_debug(
- "%s:%*s%p type %u [parent %p] wp=%p [%u,%u %ux%u]", hdr, n, " ", lc,
+ "%s:%*s%p type %u [parent %p] wp=%p [%u,%u %ux%u]", hdr, (int)n, " ", lc,
lc->type, lc->parent, lc->wp, lc->xoff, lc->yoff, lc->sx, lc->sy);
switch (lc->type) {
case LAYOUT_LEFTRIGHT:
diff --git a/tty-keys.c b/tty-keys.c
index a987c44..0ccd234 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -326,10 +326,10 @@ tty_keys_add(struct tty *tty, const char *s, int key)

keystr = key_string_lookup_key(key);
if ((tk = tty_keys_find(tty, s, strlen(s), &size)) == NULL) {
- log_debug("new key %s: 0x%x (%s)", s, key, keystr);
+ log_debug("new key %s: 0x%x (%s)", s, (u_int)key, keystr);
tty_keys_add1(&tty->key_tree, s, key);
} else {
- log_debug("replacing key %s: 0x%x (%s)", s, key, keystr);
+ log_debug("replacing key %s: 0x%x (%s)", s, (u_int)key, keystr);
tk->key = key;
}
}
@@ -589,7 +589,7 @@ partial_key:
return (0);

complete_key:
- log_debug("complete key %.*s %#x", (int) size, buf, key);
+ log_debug("complete key %.*s %#x", (int) size, buf, (u_int)key);

/* Remove data from buffer. */
evbuffer_drain(tty->event->input, size);
@@ -615,7 +615,7 @@ complete_key:
return (1);

discard_key:
- log_debug("discard key %.*s %#x", (int) size, buf, key);
+ log_debug("discard key %.*s %#x", (int) size, buf, (u_int)key);

/* Remove data from buffer. */
evbuffer_drain(tty->event->input, size);
--
2.3.0
Loading...