/pidgin/main: 4fb8809f2f97: Fix finch warnings about -Wsign-compare
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Thu Aug 22 04:42:39 EDT 2013
Changeset: 4fb8809f2f97482c23a12d582c4b9b724e736501
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-08-22 10:42 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/4fb8809f2f97
Description:
Fix finch warnings about -Wsign-compare
diffstat:
finch/gntrequest.c | 4 ++--
finch/libgnt/gntcolors.c | 2 +-
finch/libgnt/gntentry.c | 11 +++++++----
finch/libgnt/gntentry.h | 2 +-
finch/libgnt/gntmenu.c | 9 +++++----
finch/libgnt/gntmenu.h | 2 +-
finch/libgnt/gntstyle.c | 2 +-
finch/libgnt/gnttextview.c | 2 +-
finch/libgnt/gntwm.c | 3 ++-
9 files changed, 21 insertions(+), 16 deletions(-)
diffs (178 lines):
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -262,7 +262,7 @@ finch_request_action(const char *title,
va_list actions)
{
GntWidget *window, *box, *button, *focus = NULL;
- int i;
+ gsize i;
window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_ACTION);
@@ -281,7 +281,7 @@ finch_request_action(const char *title,
g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i));
g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window);
- if (i == default_value)
+ if (default_value >= 0 && i == (gsize)default_value)
focus = button;
}
diff --git a/finch/libgnt/gntcolors.c b/finch/libgnt/gntcolors.c
--- a/finch/libgnt/gntcolors.c
+++ b/finch/libgnt/gntcolors.c
@@ -296,7 +296,7 @@ int gnt_color_pair(int pair)
{
return (hascolors ? COLOR_PAIR(pair) :
((pair == GNT_COLOR_NORMAL || pair == GNT_COLOR_HIGHLIGHT_D ||
- pair == GNT_COLOR_TITLE_D || pair == GNT_COLOR_DISABLED) ? 0 : A_STANDOUT));
+ pair == GNT_COLOR_TITLE_D || pair == GNT_COLOR_DISABLED) ? 0 : (int)A_STANDOUT));
}
int gnt_color_add_pair(int fg, int bg)
diff --git a/finch/libgnt/gntentry.c b/finch/libgnt/gntentry.c
--- a/finch/libgnt/gntentry.c
+++ b/finch/libgnt/gntentry.c
@@ -184,7 +184,7 @@ static gboolean
show_suggest_dropdown(GntEntry *entry)
{
char *suggest = NULL;
- int len;
+ gsize len;
int offset = 0, x, y;
int count = 0;
GList *iter;
@@ -815,7 +815,7 @@ gnt_entry_key_pressed(GntWidget *widget,
for (str = text; *str; str = next)
{
- int len;
+ gsize len;
next = g_utf8_find_next_char(str, NULL);
len = next - str;
@@ -834,7 +834,7 @@ gnt_entry_key_pressed(GntWidget *widget,
if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max)
continue;
- if (entry->end + len - entry->start >= entry->buffer)
+ if ((gsize)(entry->end + len - entry->start) >= entry->buffer)
{
/* This will cause the buffer to grow */
char *tmp = g_strdup(entry->start);
@@ -1184,8 +1184,11 @@ void gnt_entry_add_to_history(GntEntry *
{
g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */
- if (g_list_length(entry->history) >= entry->histlength)
+ if (entry->histlength >= 0 &&
+ g_list_length(entry->history) >= (gsize)entry->histlength)
+ {
return;
+ }
entry->history = g_list_first(entry->history);
g_free(entry->history->data);
diff --git a/finch/libgnt/gntentry.h b/finch/libgnt/gntentry.h
--- a/finch/libgnt/gntentry.h
+++ b/finch/libgnt/gntentry.h
@@ -178,7 +178,7 @@ void gnt_entry_add_to_history(GntEntry *
* Set the length of history for the entry box.
*
* @param entry The entry box.
- * @param num The maximum length of the history.
+ * @param num The maximum length of the history, -1 for unlimited.
*/
void gnt_entry_set_history_length(GntEntry *entry, int num);
diff --git a/finch/libgnt/gntmenu.c b/finch/libgnt/gntmenu.c
--- a/finch/libgnt/gntmenu.c
+++ b/finch/libgnt/gntmenu.c
@@ -79,7 +79,7 @@ gnt_menu_draw(GntWidget *widget)
GntMenu *menu = GNT_MENU(widget);
GList *iter;
chtype type;
- int i;
+ guint i;
if (menu->type == GNT_MENU_TOPLEVEL) {
wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT));
@@ -277,7 +277,7 @@ static gboolean
gnt_menu_key_pressed(GntWidget *widget, const char *text)
{
GntMenu *menu = GNT_MENU(widget);
- int current = menu->selected;
+ guint current = menu->selected;
if (menu->submenu) {
GntMenu *sub = menu;
@@ -304,9 +304,10 @@ gnt_menu_key_pressed(GntWidget *widget,
if (menu->type == GNT_MENU_TOPLEVEL) {
if (strcmp(text, GNT_KEY_LEFT) == 0) {
- menu->selected--;
- if (menu->selected < 0)
+ if (menu->selected == 0)
menu->selected = g_list_length(menu->list) - 1;
+ else
+ menu->selected--;
} else if (strcmp(text, GNT_KEY_RIGHT) == 0) {
menu->selected++;
if (menu->selected >= g_list_length(menu->list))
diff --git a/finch/libgnt/gntmenu.h b/finch/libgnt/gntmenu.h
--- a/finch/libgnt/gntmenu.h
+++ b/finch/libgnt/gntmenu.h
@@ -65,7 +65,7 @@ struct _GntMenu
GntMenuType type;
GList *list;
- int selected;
+ guint selected;
/* This will keep track of its immediate submenu which is visible so that
* keystrokes can be passed to it. */
diff --git a/finch/libgnt/gntstyle.c b/finch/libgnt/gntstyle.c
--- a/finch/libgnt/gntstyle.c
+++ b/finch/libgnt/gntstyle.c
@@ -168,7 +168,7 @@ void gnt_style_read_workspaces(GntWM *wm
gsize c;
for (i = 1; i < MAX_WORKSPACES; ++i) {
- int j;
+ gsize j;
GntWS *ws;
gchar **titles;
char group[32];
diff --git a/finch/libgnt/gnttextview.c b/finch/libgnt/gnttextview.c
--- a/finch/libgnt/gnttextview.c
+++ b/finch/libgnt/gnttextview.c
@@ -513,7 +513,7 @@ void gnt_text_view_append_text_with_tag(
GntTextFormatFlags flags, const char *tagname)
{
GntWidget *widget = GNT_WIDGET(view);
- int fl = 0;
+ chtype fl = 0;
const char *start, *end;
GList *list = view->list;
GntTextLine *line;
diff --git a/finch/libgnt/gntwm.c b/finch/libgnt/gntwm.c
--- a/finch/libgnt/gntwm.c
+++ b/finch/libgnt/gntwm.c
@@ -427,6 +427,7 @@ switch_window(GntWM *wm, int direction,
w = wm->cws->ordered->data;
orgpos = pos = g_list_index(wm->cws->list, w);
+ g_return_if_fail(pos < 0);
do {
pos += direction;
@@ -434,7 +435,7 @@ switch_window(GntWM *wm, int direction,
if (pos < 0) {
wid = g_list_last(wm->cws->list)->data;
pos = g_list_length(wm->cws->list) - 1;
- } else if (pos >= g_list_length(wm->cws->list)) {
+ } else if ((guint)pos >= g_list_length(wm->cws->list)) {
wid = wm->cws->list->data;
pos = 0;
} else
More information about the Commits
mailing list