Skip to content

Commit

Permalink
cleanup: fix some infer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Feb 21, 2024
1 parent 06bb243 commit 6e933b2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ static bool chat_onKey(ToxWindow *self, Toxic *toxic, wint_t key, bool ltr)

if (key == L'\t' && ctx->len > 1 && ctx->line[0] == '/') { /* TAB key: auto-complete */
input_ret = true;
int diff = -1;
int diff;

/* TODO: make this not suck */
if (wcsncmp(ctx->line, L"/sendfile ", wcslen(L"/sendfile ")) == 0) {
Expand All @@ -1395,7 +1395,7 @@ static bool chat_onKey(ToxWindow *self, Toxic *toxic, wint_t key, bool ltr)
diff = complete_line(self, toxic, chat_cmd_list, sizeof(chat_cmd_list) / sizeof(char *));
}

if (diff != -1) {
if (diff >= 0) {
if (x + diff > x2 - 1) {
const int wlen = MAX(0, wcswidth(ctx->line, sizeof(ctx->line) / sizeof(wchar_t)));
ctx->start = wlen < x2 ? 0 : wlen - x2 + 1;
Expand Down
1 change: 0 additions & 1 deletion src/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,6 @@ static void conference_onDraw(ToxWindow *self, Toxic *toxic)
mvwaddch(ctx->sidebar, line, 0, ACS_LTEE);
mvwhline(ctx->sidebar, line, 1, ACS_HLINE, SIDEBAR_WIDTH - 1);
wattroff(ctx->sidebar, COLOR_PAIR(PEERLIST_LINE));
++line;

for (uint32_t i = 0;
i < num_peers && i < y2 - header_lines - CHATBOX_HEIGHT;
Expand Down
6 changes: 5 additions & 1 deletion src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ static void friendlist_onDraw(ToxWindow *self, Toxic *toxic)
pthread_mutex_unlock(&Winthread.lock);

if (connection_status != TOX_CONNECTION_NONE) {
int colour = MAGENTA;
int colour;

switch (status) {
case TOX_USER_STATUS_NONE:
Expand All @@ -1211,6 +1211,10 @@ static void friendlist_onDraw(ToxWindow *self, Toxic *toxic)
case TOX_USER_STATUS_BUSY:
colour = RED;
break;

default:
colour = BAR_TEXT;
break;
}

wattron(self->window, COLOR_PAIR(colour) | A_BOLD);
Expand Down
2 changes: 1 addition & 1 deletion src/groupchats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ static bool groupchat_onKey(ToxWindow *self, Toxic *toxic, wint_t key, bool ltr)
input_ret = true;

if (ctx->len > 0) {
int diff = -1;
int diff;

/* TODO: make this not suck */
if (ctx->line[0] != L'/' || wcschr(ctx->line, L' ') != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions src/misc_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ int char_find(int idx, const char *s, char ch)
return 0;
}

int i = idx;
int i;

for (i = idx; s[i]; ++i) {
for (i = idx; s[i] != '\0'; ++i) {
if (s[i] == ch) {
break;
}
Expand Down

0 comments on commit 6e933b2

Please sign in to comment.