Tidy a few warnings.

This commit is contained in:
Nicholas Marriott 2009-01-17 18:47:37 +00:00
parent ff61eee294
commit 0e197b417a
7 changed files with 109 additions and 64 deletions

View File

@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.56 2009-01-15 19:27:31 nicm Exp $ # $Id: GNUmakefile,v 1.57 2009-01-17 18:47:36 nicm Exp $
.PHONY: clean .PHONY: clean
@ -7,7 +7,7 @@ VERSION= 0.6
DATE= $(shell date +%Y%m%d-%H%M) DATE= $(shell date +%Y%m%d-%H%M)
DEBUG= 1 #DEBUG= 1
META?= \002 META?= \002

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.95 2009-01-17 18:38:12 nicm Exp $ # $Id: Makefile,v 1.96 2009-01-17 18:47:36 nicm Exp $
.SUFFIXES: .c .o .y .h .SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html .PHONY: clean update-index.html upload-index.html
@ -11,7 +11,7 @@ REL!= uname -r
DATE!= date +%Y%m%d-%H%M DATE!= date +%Y%m%d-%H%M
# This must be empty as OpenBSD includes it in default CFLAGS. # This must be empty as OpenBSD includes it in default CFLAGS.
DEBUG= #DEBUG=
META?= \002 # C-b META?= \002 # C-b

View File

@ -1,4 +1,4 @@
/* $Id: cmd-choose-session.c,v 1.1 2009-01-15 19:27:31 nicm Exp $ */ /* $Id: cmd-choose-session.c,v 1.2 2009-01-17 18:47:36 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -63,7 +63,7 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return; return;
idx = 0; cur = idx = 0;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i); s = ARRAY_ITEM(&sessions, i);
if (s == NULL) if (s == NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-choose-window.c,v 1.3 2009-01-15 19:41:12 nicm Exp $ */ /* $Id: cmd-choose-window.c,v 1.4 2009-01-17 18:47:36 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -64,7 +64,7 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return; return;
idx = 0; cur = idx = 0;
RB_FOREACH(wm, winlinks, &s->windows) { RB_FOREACH(wm, winlinks, &s->windows) {
w = wm->window; w = wm->window;

148
grid.c
View File

@ -1,4 +1,4 @@
/* $Id: grid.c,v 1.6 2009-01-11 02:23:52 nicm Exp $ */ /* $Id: grid.c,v 1.7 2009-01-17 18:47:36 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -37,34 +37,51 @@
/* Default grid cell data. */ /* Default grid cell data. */
const struct grid_cell grid_default_cell = { ' ', 0, 0, 8, 8 }; const struct grid_cell grid_default_cell = { ' ', 0, 0, 8, 8 };
#ifdef DEBUG
#define grid_check_x(gd, px) do { \
if ((px) >= (gd)->sx) \
log_fatalx("x out of range: %u", px); \
} while (0)
#define grid_check_y(gd, py) do { \
if ((py) >= (gd)->hsize + (gd)->sy) \
log_fatalx("y out of range: %u", py); \
} while (0)
#else
#define grid_check_x(gd, px) do { \
if ((px) >= (gd)->sx) { \
log_debug("x out of range: %u", px); \
return; \
} \
} while (0)
#define grid_check_y(gd, py) do { \
if ((py) >= (gd)->hsize + (gd)->sy) { \
log_debug("y out of range: %u", py); \
return; \
} \
} while (0)
#endif
#define grid_put_cell(gd, px, py, gc) do { \ #define grid_put_cell(gd, px, py, gc) do { \
memcpy(&gd->data[py][px], gc, sizeof gd->data[py][px]); \ memcpy(&gd->data[py][px], gc, sizeof gd->data[py][px]); \
} while (0) } while (0)
int grid_check_x(struct grid_data *, u_int);
int grid_check_y(struct grid_data *, u_int);
#ifdef DEBUG
int
grid_check_x(struct grid_data *gd, u_int px)
{
if ((px) >= (gd)->sx)
log_fatalx("x out of range: %u", px);
return (0);
}
int
grid_check_y(struct grid_data *gd, u_int py)
{
if ((py) >= (gd)->hsize + (gd)->sy)
log_fatalx("y out of range: %u", py);
return (0);
}
#else
int
grid_check_x(struct grid_data *gd, u_int px)
{
if ((px) >= (gd)->sx) {
log_debug("x out of range: %u", px);
return (-1);
}
return (0);
}
int
grid_check_y(struct grid_data *gd, u_int py)
{
if ((py) >= (gd)->hsize + (gd)->sy) {
log_debug("y out of range: %u", py);
return (-1);
}
return (0);
}
#endif
/* Create a new grid. */ /* Create a new grid. */
struct grid_data * struct grid_data *
grid_create(u_int sx, u_int sy, u_int hlimit) grid_create(u_int sx, u_int sy, u_int hlimit)
@ -160,8 +177,10 @@ grid_expand_line(struct grid_data *gd, u_int py, u_int sx)
const struct grid_cell * const struct grid_cell *
grid_peek_cell(struct grid_data *gd, u_int px, u_int py) grid_peek_cell(struct grid_data *gd, u_int px, u_int py)
{ {
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_y(gd, py); return (&grid_default_cell);
if (grid_check_y(gd, py) != 0)
return (&grid_default_cell);
if (px >= gd->size[py]) if (px >= gd->size[py])
return (&grid_default_cell); return (&grid_default_cell);
@ -172,8 +191,10 @@ grid_peek_cell(struct grid_data *gd, u_int px, u_int py)
struct grid_cell * struct grid_cell *
grid_get_cell(struct grid_data *gd, u_int px, u_int py) grid_get_cell(struct grid_data *gd, u_int px, u_int py)
{ {
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_y(gd, py); return (NULL);
if (grid_check_y(gd, py) != 0)
return (NULL);
grid_expand_line(gd, py, px + 1); grid_expand_line(gd, py, px + 1);
return (&gd->data[py][px]); return (&gd->data[py][px]);
@ -184,8 +205,10 @@ void
grid_set_cell( grid_set_cell(
struct grid_data *gd, u_int px, u_int py, const struct grid_cell *gc) struct grid_data *gd, u_int px, u_int py, const struct grid_cell *gc)
{ {
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_y(gd, py); return;
if (grid_check_y(gd, py) != 0)
return;
grid_expand_line(gd, py, px + 1); grid_expand_line(gd, py, px + 1);
grid_put_cell(gd, px, py, gc); grid_put_cell(gd, px, py, gc);
@ -210,10 +233,14 @@ grid_clear(struct grid_data *gd, u_int px, u_int py, u_int nx, u_int ny)
return; return;
} }
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_x(gd, px + nx - 1); return;
grid_check_y(gd, py); if (grid_check_x(gd, px + nx - 1) != 0)
grid_check_y(gd, py + ny - 1); return;
if (grid_check_y(gd, py) != 0)
return;
if (grid_check_y(gd, py + ny - 1) != 0)
return;
for (yy = py; yy < py + ny; yy++) { for (yy = py; yy < py + ny; yy++) {
for (xx = px; xx < px + nx; xx++) { for (xx = px; xx < px + nx; xx++) {
@ -236,10 +263,14 @@ grid_fill(struct grid_data *gd,
if (nx == 0 || ny == 0) if (nx == 0 || ny == 0)
return; return;
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_x(gd, px + nx - 1); return;
grid_check_y(gd, py); if (grid_check_x(gd, px + nx - 1) != 0)
grid_check_y(gd, py + ny - 1); return;
if (grid_check_y(gd, py) != 0)
return;
if (grid_check_y(gd, py + ny - 1) != 0)
return;
for (yy = py; yy < py + ny; yy++) { for (yy = py; yy < py + ny; yy++) {
for (xx = px; xx < px + nx; xx++) { for (xx = px; xx < px + nx; xx++) {
@ -260,8 +291,10 @@ grid_clear_lines(struct grid_data *gd, u_int py, u_int ny)
if (ny == 0) if (ny == 0)
return; return;
grid_check_y(gd, py); if (grid_check_y(gd, py) != 0)
grid_check_y(gd, py + ny - 1); return;
if (grid_check_y(gd, py + ny - 1) != 0)
return;
for (yy = py; yy < py + ny; yy++) { for (yy = py; yy < py + ny; yy++) {
if (gd->data[yy] != NULL) { if (gd->data[yy] != NULL) {
@ -291,10 +324,14 @@ grid_move_lines(struct grid_data *gd, u_int dy, u_int py, u_int ny)
if (ny == 0 || py == dy) if (ny == 0 || py == dy)
return; return;
grid_check_y(gd, py); if (grid_check_y(gd, py) != 0)
grid_check_y(gd, py + ny - 1); return;
grid_check_y(gd, dy); if (grid_check_y(gd, py + ny - 1) != 0)
grid_check_y(gd, dy + ny - 1); return;
if (grid_check_y(gd, dy) != 0)
return;
if (grid_check_y(gd, dy + ny - 1) != 0)
return;
/* Free any lines which are being replaced. */ /* Free any lines which are being replaced. */
for (yy = dy; yy < dy + ny; yy++) { for (yy = dy; yy < dy + ny; yy++) {
@ -326,9 +363,12 @@ grid_clear_cells(struct grid_data *gd, u_int px, u_int py, u_int nx)
if (nx == 0) if (nx == 0)
return; return;
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_x(gd, px + nx - 1); return;
grid_check_y(gd, py); if (grid_check_x(gd, px + nx - 1) != 0)
return;
if (grid_check_y(gd, py) != 0)
return;
for (xx = px; xx < px + nx; xx++) { for (xx = px; xx < px + nx; xx++) {
if (xx >= gd->size[py]) if (xx >= gd->size[py])
@ -348,10 +388,14 @@ grid_move_cells(struct grid_data *gd, u_int dx, u_int px, u_int py, u_int nx)
if (nx == 0 || px == dx) if (nx == 0 || px == dx)
return; return;
grid_check_x(gd, px); if (grid_check_x(gd, px) != 0)
grid_check_x(gd, px + nx - 1); return;
grid_check_x(gd, dx + nx - 1); if (grid_check_x(gd, px + nx - 1) != 0)
grid_check_y(gd, py); return;
if (grid_check_x(gd, dx + nx - 1) != 0)
return;
if (grid_check_y(gd, py) != 0)
return;
grid_expand_line(gd, py, px + nx); grid_expand_line(gd, py, px + nx);
grid_expand_line(gd, py, dx + nx); grid_expand_line(gd, py, dx + nx);

View File

@ -1,4 +1,4 @@
/* $Id: screen-write.c,v 1.24 2009-01-11 23:31:46 nicm Exp $ */ /* $Id: screen-write.c,v 1.25 2009-01-17 18:47:36 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -589,7 +589,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
*/ */
for (xx = s->cx + 1; xx < s->cx + width; xx++) { for (xx = s->cx + 1; xx < s->cx + width; xx++) {
ic = grid_view_get_cell(gd, xx, s->cy); ic = grid_view_get_cell(gd, xx, s->cy);
ic->flags |= GRID_FLAG_PADDING; if (ic != NULL)
ic->flags |= GRID_FLAG_PADDING;
} }
/* Write the actual cell. */ /* Write the actual cell. */

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.63 2009-01-15 23:42:21 nicm Exp $ */ /* $Id: status.c,v 1.64 2009-01-17 18:47:37 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -44,7 +44,7 @@ status_redraw(struct client *c)
struct session *s = c->session; struct session *s = c->session;
struct winlink *wl; struct winlink *wl;
struct window_pane *wp; struct window_pane *wp;
struct screen *sc; struct screen *sc = NULL;
char *left, *right, *text, *ptr; char *left, *right, *text, *ptr;
size_t llen, rlen, offset, xx, yy, sy; size_t llen, rlen, offset, xx, yy, sy;
size_t size, start, width; size_t size, start, width;