mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 15:03:27 +01:00
Merge pull request #240 from s3erios/master
Fix some 'clang --analyze' warnings
This commit is contained in:
commit
6876df4a45
@ -130,11 +130,12 @@ static int save_blocklist(char *path)
|
||||
exit_toxic_err("Failed in save_blocklist", FATALERR_MEMORY);
|
||||
|
||||
int i;
|
||||
int ret = -1;
|
||||
int count = 0;
|
||||
|
||||
for (i = 0; i < Blocked.max_idx; ++i) {
|
||||
if (count > Blocked.num_blocked)
|
||||
return -1;
|
||||
goto on_error;
|
||||
|
||||
if (Blocked.list[i].active) {
|
||||
BlockedFriend tmp;
|
||||
@ -155,17 +156,14 @@ static int save_blocklist(char *path)
|
||||
|
||||
FILE *fp = fopen(path, "wb");
|
||||
|
||||
if (fp == NULL) {
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
if (fp == NULL)
|
||||
goto on_error;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if (fwrite(data, len, 1, fp) != 1)
|
||||
ret = -1;
|
||||
if (fwrite(data, len, 1, fp) == 1)
|
||||
ret = 0;
|
||||
|
||||
fclose(fp);
|
||||
on_error:
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
@ -107,15 +107,6 @@ static void line_info_root_fwd(struct history *hst)
|
||||
hst->line_root = tmp;
|
||||
}
|
||||
|
||||
/* adds a line_info line to queue */
|
||||
static void line_info_add_queue(struct history *hst, struct line_info *line)
|
||||
{
|
||||
if (hst->queue_sz >= MAX_QUEUE)
|
||||
return;
|
||||
|
||||
hst->queue[hst->queue_sz++] = line;
|
||||
}
|
||||
|
||||
/* returns ptr to queue item 0 and removes it from queue */
|
||||
static struct line_info *line_info_ret_queue(struct history *hst)
|
||||
{
|
||||
@ -140,6 +131,10 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint
|
||||
uint8_t colour, const char *msg, ...)
|
||||
{
|
||||
struct history *hst = self->chatwin->hst;
|
||||
|
||||
if (hst->queue_sz >= MAX_QUEUE)
|
||||
return;
|
||||
|
||||
struct line_info *new_line = calloc(1, sizeof(struct line_info));
|
||||
|
||||
if (new_line == NULL)
|
||||
@ -205,7 +200,7 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint
|
||||
new_line->bold = bold;
|
||||
new_line->colour = colour;
|
||||
|
||||
line_info_add_queue(hst, new_line);
|
||||
hst->queue[hst->queue_sz++] = new_line;
|
||||
}
|
||||
|
||||
/* adds a single queue item to hst if possible. only called once per call to line_info_print() */
|
||||
|
Loading…
Reference in New Issue
Block a user