comparison mcabber/mcabber/screen.c @ 2325:c5665d3191aa

Prevent assigning negative values to unsigned variables
author Michał Kępień <bitbucket@kempniu.pl>
date Mon, 24 Sep 2018 21:04:09 +0200
parents 4ddd6f5c3ffc
children 54b4272de463
comparison
equal deleted inserted replaced
2324:4ddd6f5c3ffc 2325:c5665d3191aa
915 return timepreflengths[(n < 3 ? n : 0)]; 915 return timepreflengths[(n < 3 ? n : 0)];
916 } 916 }
917 917
918 guint scr_gettextwidth(void) 918 guint scr_gettextwidth(void)
919 { 919 {
920 return maxX - Roster_Width - scr_getprefixwidth(); 920 int used_width = Roster_Width + scr_getprefixwidth();
921 return maxX > used_width ? maxX - used_width : 0;
921 } 922 }
922 923
923 guint scr_gettextheight(void) 924 guint scr_gettextheight(void)
924 { 925 {
925 // log window, two status bars and one input line 926 // log window, two status bars and one input line
1092 tmp->bd = wb->bd; 1093 tmp->bd = wb->bd;
1093 tmp->bd->refcount++; 1094 tmp->bd->refcount++;
1094 g_free(id); 1095 g_free(id);
1095 } else { // Load buddy history from file (if enabled) 1096 } else { // Load buddy history from file (if enabled)
1096 tmp->bd = g_new0(buffdata, 1); 1097 tmp->bd = g_new0(buffdata, 1);
1097 hlog_read_history(title, &tmp->bd->hbuf, 1098 hlog_read_history(title, &tmp->bd->hbuf, scr_gettextwidth());
1098 maxX - Roster_Width - scr_getprefixwidth());
1099 1099
1100 // Set a readmark to separate new content 1100 // Set a readmark to separate new content
1101 hbuf_set_readmark(tmp->bd->hbuf, TRUE); 1101 hbuf_set_readmark(tmp->bd->hbuf, TRUE);
1102 } 1102 }
1103 1103
1534 mucnicklen = strlen(nicklocaltmp); 1534 mucnicklen = strlen(nicklocaltmp);
1535 g_free(nicklocaltmp); 1535 g_free(nicklocaltmp);
1536 g_free(nicktmp); 1536 g_free(nicktmp);
1537 } 1537 }
1538 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, 1538 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags,
1539 maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, 1539 scr_gettextwidth(), num_history_blocks, mucnicklen, xep184);
1540 mucnicklen, xep184);
1541 g_free(text_locale); 1540 g_free(text_locale);
1542 1541
1543 if (win_entry->bd->cleared) { 1542 if (win_entry->bd->cleared) {
1544 win_entry->bd->cleared = FALSE; 1543 win_entry->bd->cleared = FALSE;
1545 if (g_list_next(win_entry->bd->top)) 1544 if (g_list_next(win_entry->bd->top))